/* ============================================================
   YTG Thumbnail Generator
   Brand: matches the CompEdge Solutions admin portal design
   system - dark navy sidebar + lime green accent, Inter/Space Grotesk
   ============================================================ */

:root {
    --nav-w:      260px;
    --clr-navy:   #0f172a;
    --clr-navy2:  #1e293b;
    --clr-green:  #4ade80;
    --clr-green2: #22c55e;
    --clr-bg:     #f8fafc;
    --clr-card:   #ffffff;
    --clr-border: #e2e8f0;
    --clr-text:   #1e293b;
    --clr-muted:  #64748b;
    --clr-faint:  #94a3b8;
    --clr-danger: #ef4444;
    --clr-warn:   #f59e0b;
    --clr-info:   #3b82f6;
    --r:          10px;
    --r-sm:       6px;
    --shadow:     0 1px 4px rgba(0,0,0,.08);
    --shadow-md:  0 4px 16px rgba(0,0,0,.10);
    --font:       'Inter', system-ui, sans-serif;
    --font-head:  'Space Grotesk', 'Inter', sans-serif;
    --t:          180ms ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
    font-family: var(--font);
    background: var(--clr-bg);
    color: var(--clr-text);
    line-height: 1.5;
    min-height: 100vh;
}

h1, h2, h3, h4, .brand-word {
    font-family: var(--font-head);
    color: var(--clr-navy);
    line-height: 1.2;
}

a { color: var(--clr-green2); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--nav-w);
    flex-shrink: 0;
    background: var(--clr-navy);
    color: #cbd5e1;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar .brand {
    font-family: var(--font-head);
    color: #fff;
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 24px;
    padding: 0 8px;
}

.sidebar .brand span { color: var(--clr-green); }

.sidebar a {
    color: #cbd5e1;
    padding: 10px 12px;
    border-radius: var(--r-sm);
    font-size: 0.92rem;
    transition: background var(--t), color var(--t);
}

.sidebar a:hover,
.sidebar a.active {
    background: var(--clr-navy2);
    color: #fff;
    text-decoration: none;
}

.sidebar a.active { border-left: 3px solid var(--clr-green); }

.sidebar-footer {
    margin-top: auto;
    padding-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-user {
    padding: 0 12px 8px;
    color: #94a3b8;
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.main {
    flex: 1;
    padding: 32px 40px;
    max-width: 1200px;
}

.card {
    background: var(--clr-card);
    border: 1px solid var(--clr-border);
    border-radius: var(--r);
    box-shadow: var(--shadow);
    padding: 24px;
}

.card + .card { margin-top: 20px; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.92rem;
    padding: 10px 18px;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background var(--t), border-color var(--t), transform var(--t);
}

.btn-primary {
    background: var(--clr-green2);
    color: #052e16;
}
.btn-primary:hover { background: var(--clr-green); }

.btn-secondary {
    background: #fff;
    border-color: var(--clr-border);
    color: var(--clr-text);
}
.btn-secondary:hover { background: var(--clr-bg); }

.btn-danger { background: var(--clr-danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn:disabled { opacity: .55; cursor: not-allowed; }

label { font-weight: 600; font-size: 0.88rem; display: block; margin-bottom: 6px; }

input[type=text], input[type=email], input[type=password], textarea, select {
    width: 100%;
    font-family: var(--font);
    font-size: 0.95rem;
    padding: 10px 12px;
    border: 1px solid var(--clr-border);
    border-radius: var(--r-sm);
    background: #fff;
    color: var(--clr-text);
}

textarea { resize: vertical; min-height: 120px; }

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--clr-green2);
    box-shadow: 0 0 0 3px rgba(34,197,94,.15);
}

.field { margin-bottom: 18px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row label { margin: 0; font-weight: 500; }

.badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
}

.badge-green { background: #f0fdf4; color: #15803d; }
.badge-muted { background: #f1f5f9; color: #64748b; }

.alert {
    padding: 12px 16px;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    margin-bottom: 16px;
    font-size: 0.9rem;
}
.alert-error   { background: #fff1f2; color: #be123c; border-color: #fecdd3; }
.alert-info    { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.alert-success { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.muted { color: var(--clr-muted); }
.faint { color: var(--clr-faint); font-size: 0.85rem; }

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--clr-navy);
}

.login-card {
    width: 360px;
    background: #fff;
    border-radius: var(--r);
    box-shadow: var(--shadow-md);
    padding: 32px;
}

.login-card h1 {
    font-size: 1.3rem;
    margin-bottom: 4px;
}

.thumb-preview {
    aspect-ratio: 16 / 9;
    width: 100%;
    border-radius: var(--r-sm);
    border: 1px solid var(--clr-border);
    background: var(--clr-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--clr-faint);
    overflow: hidden;
}

.thumb-preview img { width: 100%; height: 100%; object-fit: cover; }

.ref-image-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.ref-image-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ref-role-select {
    font-size: 0.75rem;
    padding: 4px 6px;
}

.yt-fetch-row {
    margin-top: 14px;
    max-width: 480px;
}

.yt-fetch-row label {
    font-size: 0.82rem;
}

.yt-fetch-controls {
    display: flex;
    gap: 8px;
}

.yt-fetch-controls input[type=text] {
    flex: 1;
    min-width: 0;
}

.yt-fetch-row .faint {
    display: block;
    margin-top: 6px;
    min-height: 1em;
}

.locked {
    opacity: .55;
    pointer-events: none;
}

.ref-image-slot {
    aspect-ratio: 1;
    border: 1px dashed var(--clr-border);
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: var(--clr-bg);
    font-size: 0.75rem;
    color: var(--clr-faint);
    text-align: center;
}

.ref-image-slot img { width: 100%; height: 100%; object-fit: cover; }

/* Only the upload slots (generate.php) get a pointer cursor - the static
   reference-image display on result.php reuses .ref-image-slot but isn't
   clickable, so it's scoped to the .ref-image-item wrapper used only there. */
.ref-image-item .ref-image-slot {
    cursor: pointer;
    transition: border-color var(--t);
}

.ref-image-item .ref-image-slot:hover {
    border-color: var(--clr-green2);
}

.ref-image-slot .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(15,23,42,.75);
    color: #fff;
    border: none;
    border-radius: 999px;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    font-size: 0.75rem;
}

.ref-image-slot .download-btn {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(15,23,42,.75);
    color: #fff;
    border: none;
    border-radius: 999px;
    width: 22px;
    height: 22px;
    line-height: 22px;
    text-align: center;
    cursor: pointer;
    font-size: 0.8rem;
}

.ref-image-slot .download-btn:hover { background: rgba(15,23,42,.92); }

.expand-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(15,23,42,.75);
    color: #fff;
    border: none;
    border-radius: 999px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
}

.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.92);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.lightbox.open { display: flex; }

.lightbox img {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-md);
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,.14);
    border: none;
    color: #fff;
    font-size: 1.8rem;
    line-height: 1;
    width: 48px;
    height: 48px;
    border-radius: 999px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-nav:hover { background: rgba(255,255,255,.26); }
.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }

.lightbox-counter {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: #cbd5e1;
    font-size: 0.85rem;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--clr-border); font-size: 0.9rem; }
th { color: var(--clr-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:hover { background: var(--clr-bg); }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.concept-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.concept-card {
    border: 1px solid var(--clr-border);
    border-radius: var(--r-sm);
    padding: 14px;
    cursor: pointer;
    transition: border-color var(--t), box-shadow var(--t);
}

.concept-card:hover { border-color: var(--clr-green2); }

.concept-card.selected {
    border-color: var(--clr-green2);
    box-shadow: 0 0 0 3px rgba(34,197,94,.15);
}

.concept-card h4 {
    font-size: 0.95rem;
    margin-bottom: 6px;
}

/* ---- Mobile: Steve runs this from his phone, so small screens come first ---- */
@media (max-width: 860px) {
    .app-shell { flex-direction: column; }

    .sidebar {
        width: 100%;
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 12px 16px;
        gap: 6px;
    }

    .sidebar .brand { margin: 0 12px 0 0; white-space: nowrap; }
    .sidebar a { white-space: nowrap; }
    .sidebar a.active { border-left: none; border-bottom: 3px solid var(--clr-green); }
    .sidebar-footer {
        margin: 0 0 0 auto !important;
        padding: 0 !important;
        flex-direction: row !important;
        align-items: center;
        gap: 10px;
    }
    .sidebar-user { padding: 0; max-width: 120px; }

    .main { padding: 20px 16px; max-width: 100%; }

    .card { padding: 18px; }

    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }

    .ref-image-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }

    .concept-grid { grid-template-columns: 1fr; }

    table { min-width: 480px; }

    .login-card { width: 90vw; max-width: 360px; padding: 24px; }

    #craft-btn, #generate-btn, .login-card .btn { width: 100%; justify-content: center; }

    .yt-fetch-controls { flex-direction: column; }
    #fetch-thumb-btn { width: 100%; justify-content: center; }
}

@media (max-width: 420px) {
    .ref-image-grid { grid-template-columns: repeat(2, 1fr); }
    .ref-role-select { font-size: 0.7rem; }
    .lightbox-nav { width: 40px; height: 40px; font-size: 1.4rem; }
    .lightbox-prev { left: 6px; }
    .lightbox-next { right: 6px; }
}
