/* ── Google Fonts ─────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Midnight dark defaults — overridden at runtime by theme.js */
    --bg:            #0d0f14;
    --surface:       #151820;
    --surface2:      #1c2030;
    --border:        #252a38;
    --accent:        #3b82f6;
    --accent-rgb:    59,130,246;
    --accent-hover:  #2563eb;
    --accent-text:   #ffffff;
    --accent-d:      #1e3a5f;
    --text:          #e2e8f5;
    --muted:         #525d7a;
    --danger:        #f87171;
    --danger-bg:     rgba(248,113,113,.08);
    --danger-border: rgba(248,113,113,.25);
    --topbar-bg:     rgba(13,15,20,.85);
    --shadow-xs:     0 1px 2px rgba(0,0,0,.4);
    --shadow-sm:     0 2px 8px rgba(0,0,0,.45);
    --shadow-md:     0 4px 20px rgba(0,0,0,.5);
    --shadow-accent: 0 0 0 3px rgba(59,130,246,.25);
    --font-body:     'Inter', system-ui, sans-serif;
    --font-heading:  'Inter', system-ui, sans-serif;
    --font-mono:     'JetBrains Mono', monospace;
    --radius:        8px;
    --radius-sm:     5px;
    --radius-lg:     12px;
    --sidebar-w:     220px;
    --success:       #51cf66;

    /* Project-specific supplementary tokens */
    --font-size:     15px;
}

html, body { height: 100%; }

body {
    font-family: var(--font-body);
    font-size: var(--font-size);
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

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

/* ── Per-theme radial background gradients ───────────────────────────────── */
[data-theme="midnight"][data-mode="dark"] body {
  background-image: radial-gradient(ellipse 80% 50% at 20% 0%, rgba(59,130,246,.05) 0%, transparent 60%);
}
[data-theme="aurora"][data-mode="dark"] body {
  background-image: radial-gradient(ellipse 80% 50% at 15% 0%, rgba(139,92,246,.07) 0%, transparent 60%);
}
[data-theme="sandstone"][data-mode="dark"] body {
  background-image: radial-gradient(ellipse 80% 50% at 10% 0%, rgba(232,160,32,.05) 0%, transparent 60%);
}
[data-theme="tricentris"][data-mode="dark"] body {
  background-image: radial-gradient(ellipse 80% 50% at 20% 0%, rgba(61,186,110,.06) 0%, transparent 60%);
}
[data-theme="midnight"][data-mode="light"] body {
  background-image: radial-gradient(ellipse 80% 50% at 20% 0%, rgba(37,99,235,.06) 0%, transparent 60%);
}
[data-theme="aurora"][data-mode="light"] body {
  background-image: radial-gradient(ellipse 80% 50% at 15% 0%, rgba(124,58,237,.07) 0%, transparent 60%);
}
[data-theme="sandstone"][data-mode="light"] body {
  background-image: radial-gradient(ellipse 80% 50% at 10% 0%, rgba(184,114,10,.06) 0%, transparent 60%);
}
[data-theme="tricentris"][data-mode="light"] body {
  background-image: radial-gradient(ellipse 80% 50% at 20% 0%, rgba(26,122,66,.07) 0%, transparent 60%);
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s;
    text-decoration: none;
}
.btn-primary   { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface2); text-decoration: none; }
.btn-ghost     { background: transparent; color: var(--accent); border-color: transparent; }
.btn-ghost:hover { background: rgba(var(--accent-rgb), .1); text-decoration: none; }
.btn-danger    { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover { background: rgba(var(--accent-rgb), .05); text-decoration: none; }
.btn-sm        { padding: 4px 10px; font-size: 13px; }
.btn-block     { width: 100%; justify-content: center; margin-top: 8px; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-success { background: rgba(81,207,102,.1); border: 1px solid rgba(81,207,102,.25); color: var(--success); }
.alert-error   { background: var(--danger-bg); border: 1px solid var(--danger-border); color: var(--danger); }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.badge-active   { background: rgba(81,207,102,.12); color: var(--success); }
.badge-inactive { background: var(--surface2); color: var(--muted); }
.badge-public   { background: rgba(var(--accent-rgb),.1); color: var(--accent); }
.badge-private  { background: var(--surface2); color: var(--muted); }
.btn-badge {
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: opacity .15s;
}
.btn-badge:hover { opacity: .75; }

/* ═══════════════════════════════════════════════════════════════════════════
   GALLERY PAGE (index.php)
═══════════════════════════════════════════════════════════════════════════ */
.gallery-page {
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.gallery-header {
    padding: 32px 40px 0;
    display: flex;
    align-items: center;
    gap: 16px;
}
.gallery-header h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.3px;
}

.gallery-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    padding: 32px 40px;
    align-content: start;
}

.report-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    color: var(--text);
    transition: background .2s, border-color .2s, transform .2s;
    text-decoration: none;
    position: relative;
}
.report-card:hover {
    background: var(--surface2);
    border-color: var(--accent);
    transform: translateY(-2px);
    text-decoration: none;
    color: var(--text);
}

.report-card-icon svg { width: 48px; height: 48px; }
.report-card-info { flex: 1; }
.report-card-name { display: block; font-size: 16px; font-weight: 600; }
.report-card-desc { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }
.report-card-arrow {
    position: absolute;
    top: 20px; right: 20px;
    font-size: 18px;
    color: var(--muted);
    transition: color .2s, right .2s;
}
.report-card:hover .report-card-arrow { color: var(--accent); right: 16px; }

.report-card-unavailable {
    opacity: .45;
    cursor: default;
    pointer-events: none;
}

.report-card-has-thumb {
    padding-top: 0;
    overflow: hidden;
}
.report-card-thumb {
    display: block;
    width: calc(100% + 40px);
    height: 148px;
    object-fit: cover;
    margin: 0 -20px 16px;
    flex-shrink: 0;
    transition: transform .3s ease, opacity .2s;
}
.report-card-has-thumb:hover .report-card-thumb {
    transform: scale(1.03);
}

.gallery-section-header {
    grid-column: 1 / -1;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    padding: 8px 0 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.gallery-footer {
    padding: 16px 40px;
    text-align: right;
    border-top: 1px solid var(--border);
}
.gallery-footer a { color: var(--muted); font-size: 13px; }
.gallery-footer a:hover { color: var(--text); }

.error-box, .empty-box {
    grid-column: 1 / -1;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    color: var(--muted);
}
.error-box { color: var(--danger); }

/* ═══════════════════════════════════════════════════════════════════════════
   VIEWER PAGE (view.php)
═══════════════════════════════════════════════════════════════════════════ */
.viewer-page {
    background: var(--bg);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.viewer-topbar {
    height: 48px;
    min-height: 48px;
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    z-index: 100;
    transition: opacity .3s;
}

.topbar-home {
    display: flex;
    align-items: center;
    color: var(--muted);
    padding: 6px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    transition: background .15s, color .15s;
}
.topbar-home:hover { background: var(--surface); color: var(--text); text-decoration: none; }

.topbar-title {
    flex: 1;
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.report-switcher {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    max-width: 220px;
}
.report-switcher option { background: var(--surface); }

.btn-fullscreen {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background .15s, color .15s;
}
.btn-fullscreen:hover { background: var(--surface2); color: var(--text); }

.report-container {
    flex: 1;
    width: 100%;
    overflow: hidden;
}

.report-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.embed-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--danger);
    font-size: 15px;
    gap: 8px;
    padding: 40px;
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ADMIN LAYOUT
═══════════════════════════════════════════════════════════════════════════ */
.admin-page {
    display: flex;
    background: var(--bg);
    height: 100vh;
    overflow: hidden;
}

/* Sidebar nav */
.admin-nav {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-weight: 700;
    font-size: 15px;
}

.nav-links {
    list-style: none;
    padding: 12px 0;
    flex: 1;
}
.nav-links li a {
    display: block;
    padding: 9px 20px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
    transition: background .15s, color .15s;
    text-decoration: none;
    border-left: 3px solid transparent;
}
.nav-links li a:hover { background: var(--surface2); color: var(--text); }
.nav-links li a.active { background: var(--surface2); color: var(--text); border-left-color: var(--accent); }

.nav-section {
    padding: 14px 20px 3px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    list-style: none;
}

.nav-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.nav-user  { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.btn-logout {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
    background: var(--surface2);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    transition: color .15s, background .15s;
    text-decoration: none;
}
.btn-logout:hover { color: var(--text); background: var(--border); text-decoration: none; }

/* Main content area */
.admin-content {
    flex: 1;
    min-height: 0;
    padding: 32px 36px;
    max-width: 1100px;
    overflow-x: hidden;
    overflow-y: auto;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.page-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}
.page-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    overflow-x: auto;
    margin-bottom: 24px;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 15px; font-weight: 600; }
.link-muted { color: var(--muted); font-size: 14px; }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}
.stat-value { font-size: 36px; font-weight: 700; color: var(--accent); line-height: 1; }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 6px; text-transform: uppercase; letter-spacing: .5px; }

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
}
.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface2); }
.col-mono  { font-family: var(--font-mono); font-size: 12px; color: var(--muted); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-order { width: 50px; color: var(--muted); }
.col-actions { width: auto; white-space: nowrap; }
.col-actions .btn + .btn { margin-left: 4px; }

/* Drag-and-drop reordering */
.col-drag { width: 28px; padding: 0 4px !important; text-align: center; }
.drag-handle {
    display: inline-block;
    cursor: grab;
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
    opacity: .35;
    user-select: none;
    padding: 4px;
}
.drag-handle:hover { opacity: .8; }
tr[draggable].dragging { opacity: .3; }
tr[draggable].drag-over > td { box-shadow: inset 0 -2px 0 var(--accent); }

/* Quick links */
.quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1px;
    background: var(--border);
}
.quick-link-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 18px 20px;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    transition: background .15s;
}
.quick-link-card:hover { background: var(--surface2); text-decoration: none; }
.quick-link-card strong { font-size: 14px; color: var(--accent); }
.quick-link-card span   { font-size: 13px; color: var(--muted); }

/* Empty state */
.empty-state {
    padding: 40px;
    text-align: center;
    color: var(--muted);
}

/* Text helpers */
.text-muted { color: var(--muted); }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-card { padding: 24px; }
.form-card .card { padding: 24px; }

.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; }
.form-group-sm { min-width: 100px; }

label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}
.req  { color: var(--danger); }
.hint { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 6px; }

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--shadow-accent);
}
input[type="number"] { width: 100%; }

.form-group-check { margin-top: 4px; }
.check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    cursor: pointer;
}
.check-label input[type="checkbox"] { width: auto; }

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.help-box {
    margin-top: 24px;
    background: rgba(var(--accent-rgb), .08);
    border: 1px solid rgba(var(--accent-rgb), .2);
    border-radius: var(--radius);
    padding: 14px 16px;
    font-size: 14px;
    color: var(--text);
    line-height: 1.7;
}
.help-box code {
    font-family: var(--font-mono);
    font-size: 13px;
    background: rgba(var(--accent-rgb), .08);
    padding: 2px 5px;
    border-radius: 3px;
}
.help-box em { font-style: normal; color: var(--accent); font-weight: 600; }

/* ─── Login page ──────────────────────────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    min-height: 100vh;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-md);
}
.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}
.login-card h1 {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}
.login-sub {
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 24px;
}

/* ── Gallery lock page ────────────────────────────────────────────────────── */
.gallery-lock {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}
.gallery-lock-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-md);
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════════════════
   THEME PICKER (sidebar footer)
═══════════════════════════════════════════════════════════════════════════ */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}
.theme-picker-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--muted);
}
.theme-swatches {
    display: flex;
    gap: 6px;
}
.swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    flex: 1;
}
.swatch:hover { border-color: var(--muted); background: var(--surface2); }
.swatch.active { border-color: var(--accent); background: rgba(var(--accent-rgb), .08); }
.swatch-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--c);
}
.swatch-label {
    font-size: 9px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .5px;
}
.swatch.active .swatch-label { color: var(--text); }

#modeToggle {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px 8px;
    cursor: pointer;
    color: var(--muted);
    display: flex;
    align-items: center;
    transition: background .15s, color .15s;
}
#modeToggle:hover { background: var(--border); color: var(--text); }
