/* ===== Design tokens — Eezix black & white ===== */
:root {
    --brand: #0a0a0a;
    --brand-dark: #262626;
    --brand-light: #f0f0f0;
    --ink: #0a0a0a;
    --ink-soft: #525252;
    --muted: #a3a3a3;
    --border: #e5e5e5;
    --bg: #fafafa;
    --surface: #ffffff;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --success: #0a0a0a;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04);

    /* Dark surfaces — sidebar, auth brand panel */
    --dark-bg: #0a0a0a;
    --dark-surface: #1a1a1a;
    --dark-border: #262626;
    --dark-text: #ffffff;
    --dark-text-soft: #a3a3a3;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; color: var(--ink); }
a { color: var(--brand); }
p.lead { color: var(--ink-soft); font-size: .95rem; max-width: 640px; }

/* ===== Shell: sidebar + main ===== */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    flex: none;
    background: var(--dark-bg);
    border-right: 1px solid var(--dark-border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 20px;
    font-weight: 800;
    font-size: 1.02rem;
    letter-spacing: -0.01em;
    color: var(--dark-text);
    border-bottom: 1px solid var(--dark-border);
}
.brand-mark {
    width: 26px;
    height: auto;
    max-height: 30px;
    object-fit: contain;
    flex: none;
    display: block;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 16px 12px; flex: 1; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--dark-text-soft);
    text-decoration: none;
    font-size: .92rem;
    font-weight: 500;
    transition: background .12s ease, color .12s ease;
}
.nav-link:hover { background: var(--dark-surface); color: var(--dark-text); }
.nav-link.active { background: var(--dark-surface); color: var(--dark-text); font-weight: 600; }
.nav-link svg { color: inherit; }

.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--dark-border);
}
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--dark-surface); color: var(--dark-text);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem; flex: none;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-info .name { font-size: .87rem; font-weight: 600; color: var(--dark-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info .role { font-size: .76rem; color: var(--dark-text-soft); }
.icon-btn {
    width: 32px; height: 32px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: var(--dark-text-soft); text-decoration: none; flex: none;
    transition: background .12s ease, color .12s ease;
}
.icon-btn:hover { background: var(--dark-surface); color: var(--dark-text); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 20px 32px;
    position: sticky; top: 0; z-index: 10;
}
.topbar-title { margin: 0; font-size: 1.35rem; }

.content { padding: 28px 32px 60px; max-width: 1080px; width: 100%; }

/* ===== Cards ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
a.card { text-decoration: none; color: inherit; display: block; transition: box-shadow .15s ease, border-color .15s ease, transform .15s ease; }
a.card:hover { box-shadow: var(--shadow-md); border-color: #d1d5db; transform: translateY(-1px); }

/* ===== Stat cards ===== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.stat-card .stat-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
.stat-card .stat-label { color: var(--ink-soft); font-size: .85rem; margin-top: 2px; }

/* ===== Nav cards (dashboard shortcuts) ===== */
.nav-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.nav-card { display: flex; gap: 14px; align-items: flex-start; }
.nav-card .nav-card-icon {
    width: 40px; height: 40px; border-radius: 10px; flex: none;
    background: var(--brand-light); color: var(--brand-dark);
    display: flex; align-items: center; justify-content: center;
}
.nav-card h2 { margin: 0 0 4px; font-size: 1.02rem; }
.nav-card p { margin: 0; color: var(--ink-soft); font-size: .87rem; }

/* ===== Forms ===== */
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .87rem; color: var(--ink); }
.field input[type=text], .field input[type=email], .field input[type=url], .field input[type=password], .field input[type=number], .field textarea, .field select {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .95rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--ink);
    transition: border-color .12s ease, box-shadow .12s ease;
}
.field input:focus, .field textarea:focus, .field select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-light);
}
.field textarea { resize: vertical; }
.field input[type=color] { width: 100%; height: 44px; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

.form-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: .87rem;
    font-weight: 600;
    margin-bottom: 16px;
}

/* ===== Template picker (wizard) ===== */
.template-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.template-option {
    position: relative;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    cursor: pointer;
    transition: border-color .12s ease, box-shadow .12s ease;
}
.template-option:hover { border-color: #b0b0b0; }
.template-option input { display: none; }
.template-option.selected { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
.template-option.selected::after {
    content: '✓'; position: absolute; top: 10px; right: 10px;
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--brand); color: #fff;
    font-size: .7rem; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
}
.swatch-row { display: flex; gap: 6px; margin-bottom: 10px; }
.swatch { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }
.template-name { font-weight: 600; font-size: .92rem; }

/* Section-layout picker (reuses .template-grid/.template-option for the card + selected state) */
.layout-thumb { width: 100%; aspect-ratio: 240 / 130; margin-bottom: 10px; border-radius: 6px; overflow: hidden; background: #fbfbfd; }
.layout-thumb svg { display: block; width: 100%; height: 100%; }

/* Section Templates admin: always shows 4 variant cards at a time — a plain
   .template-grid when there are 4 or fewer, this horizontally-scrolling
   slider (reusing the same .template-option cards) once there are more. */
.variant-slider { margin-bottom: 22px; }
.variant-slider-nav { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 10px; }
.variant-slider-track {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    /* No scroll-snap, no CSS scroll-behavior:smooth: the Prev/Next buttons
       (admin/section_templates.php) explicitly scroll with behavior:instant
       — a smooth/animated scroll can silently no-op on some browsers/tabs
       (reduced-motion, a backgrounded tab throttling rAF), which would make
       the controls look broken even though the click registered. */
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.variant-slider-track::-webkit-scrollbar { display: none; }
.variant-slider-track > .template-option {
    flex: 0 0 calc((100% - 3 * 14px) / 4);
}
@media (max-width: 980px) { .variant-slider-track > .template-option { flex-basis: calc((100% - 14px) / 2); } }
@media (max-width: 640px) { .variant-slider-track > .template-option { flex-basis: 85%; } }

/* ===== Template library (admin) — fixed 3-column card grid ===== */
.template-card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 22px; }
.template-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: box-shadow .12s ease; }
.template-card:hover { box-shadow: var(--shadow-sm); }
.template-card .layout-thumb { aspect-ratio: 320 / 210; margin-bottom: 0; border-radius: 0; }
.template-card-body { padding: 16px 18px; }
.template-card-body strong { font-size: 1rem; }
.template-card-body .meta { margin-top: 4px; }
@media (max-width: 980px) { .template-card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .template-card-grid { grid-template-columns: 1fr; } }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 11px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: .92rem;
    cursor: pointer;
    text-decoration: none;
    transition: background .12s ease, box-shadow .12s ease;
    box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 7px 14px; font-size: .82rem; }

/* ===== Lists ===== */
.page-list, .section-list { list-style: none; padding: 0; margin: 0; }
.page-list li, .section-list li {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    transition: box-shadow .12s ease;
}
.page-list li:hover, .section-list li:hover { box-shadow: var(--shadow-sm); }
.page-list .name, .section-list .name { font-weight: 600; }
.page-list .meta, .section-list .meta { color: var(--ink-soft); font-size: .83rem; margin-top: 2px; }
.page-list .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-list .row-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-list .thumb { width: 48px; height: 48px; flex: none; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.page-list .thumb--empty { display: grid; place-items: center; color: var(--ink-soft); }
.section-list .name { display: flex; align-items: center; gap: 8px; }
.section-list li[draggable="true"] { cursor: default; }
.drag-handle { color: var(--ink-soft); cursor: grab; display: flex; flex: none; touch-action: none; }
.drag-handle:active { cursor: grabbing; }
.section-list li.dragging { opacity: .4; }

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    background: var(--brand-light); color: var(--brand-dark);
    font-size: .75rem; font-weight: 700;
    padding: 3px 9px; border-radius: 999px;
}
.badge.muted { background: var(--bg); color: var(--ink-soft); }

/* ===== Repeatable section-editor rows ===== */
.image-field { display: flex; gap: 12px; align-items: flex-start; }
.image-field__preview { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); flex: none; }
.image-field__controls { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.image-field__upload-btn { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; width: max-content; }
.image-field__status { font-size: .78rem; color: var(--ink-soft); min-height: 1.1em; }
.repeat-item { border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 10px; position: relative; background: var(--bg); }
.repeat-item .remove-btn {
    position: absolute; top: 8px; right: 8px;
    background: var(--danger-light); color: var(--danger);
    border: none; border-radius: 6px; padding: 3px 9px; cursor: pointer; font-size: .72rem; font-weight: 700;
}
.add-row-btn {
    background: var(--brand-light); color: var(--brand-dark);
    border: none; padding: 9px 16px; border-radius: var(--radius-sm);
    cursor: pointer; font-weight: 600; font-size: .87rem;
}
.add-row-btn:hover { background: #e5e5e5; }

.empty-state {
    text-align: center; padding: 60px 20px; color: var(--ink-soft);
    background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}

/* ===== Auth (login) page ===== */
body.auth-page { margin: 0; min-height: 100vh; background: var(--surface); }
.auth-shell { display: flex; min-height: 100vh; }

.auth-brand {
    flex: 1 1 46%;
    position: relative;
    overflow: hidden;
    background: linear-gradient(160deg, #000000 0%, #0a0a0a 55%, #1a1a1a 100%);
    color: #fff;
    padding: 56px 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.auth-brand-decor { position: absolute; inset: 0; z-index: 0; }
.auth-brand-decor::before, .auth-brand-decor::after {
    content: ''; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .06);
}
.auth-brand-decor::before { width: 360px; height: 360px; top: -130px; right: -110px; }
.auth-brand-decor::after { width: 280px; height: 280px; bottom: -110px; left: -70px; background: rgba(255, 255, 255, .04); }

.auth-brand-inner { position: relative; z-index: 1; max-width: 420px; }
.auth-brand .login-brand { color: #fff; justify-content: flex-start; margin-bottom: 40px; }
.auth-brand .brand-mark { width: 30px; max-height: 34px; }
.auth-brand h2 { font-size: 1.7rem; line-height: 1.28; margin: 0 0 14px; color: #fff; }
.auth-brand p.lead { color: rgba(255, 255, 255, .72); margin: 0 0 32px; max-width: none; }

.auth-features { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 18px; }
.auth-features li { display: flex; gap: 12px; align-items: flex-start; font-size: .92rem; color: rgba(255, 255, 255, .92); line-height: 1.5; }
.auth-features .feat-icon {
    width: 34px; height: 34px; border-radius: 9px; flex: none;
    background: rgba(255, 255, 255, .15);
    display: flex; align-items: center; justify-content: center;
}

.auth-form-panel { flex: 1 1 54%; display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-form-wrap { width: 100%; max-width: 380px; }
.auth-form-logo { height: 26px; width: auto; margin-bottom: 32px; display: block; }
.auth-form-head { margin-bottom: 26px; }
.auth-form-head h1 { font-size: 1.6rem; margin: 0 0 6px; }
.auth-form-head p { color: var(--ink-soft); margin: 0; font-size: .92rem; }

.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 800; font-size: 1.1rem; }

.input-icon-wrap { position: relative; display: flex; align-items: center; }
.input-icon-wrap svg { position: absolute; left: 13px; color: var(--muted); pointer-events: none; }
.input-icon-wrap input { padding-left: 40px !important; }

.auth-demo-box { margin-top: 24px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; background: var(--bg); }
.auth-demo-row { display: flex; align-items: center; gap: 8px; font-size: .8rem; padding: 4px 0; flex-wrap: wrap; color: var(--ink-soft); }
.auth-demo-row code { background: var(--surface); border: 1px solid var(--border); padding: 1px 6px; border-radius: 4px; color: var(--ink); }

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .auth-shell { flex-direction: column; }
    .auth-brand { flex: none; padding: 36px 28px; }
    .auth-brand h2 { font-size: 1.35rem; }
    .auth-form-panel { padding: 32px 24px 48px; }
}

@media (max-width: 820px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 0 12px; overflow-x: auto; }
    .sidebar-brand { border-bottom: none; padding: 14px 10px; }
    .sidebar-nav { flex-direction: row; padding: 10px; }
    .nav-link span { display: none; }
    .sidebar-user { display: none; }
    .content { padding: 20px 16px 40px; }
    .topbar { padding: 16px 20px; }
}
