/* ==========================================================================
   layout.css — shell da aplicação (sidebar + topbar) + design tokens
   Carregado DEPOIS de app.css. Preserva todas as classes de componente
   existentes (.card, .hero, .button, .alert, ...). Apenas redefine o shell
   e expande os tokens.
   ========================================================================== */

/* ── Tokens expandidos (escala cinza, status, tipografia, espaçamento) ── */
:root {
    /* identidade (mantém teal existente, refinado) */
    --primary: #0f766e;
    --primary-dark: #115e59;
    --primary-soft: rgba(15, 118, 110, 0.10);
    --accent: #f59e0b;

    /* superfícies */
    --bg: #f4efe6;
    --surface: rgba(255, 255, 255, 0.82);
    --surface-strong: #fffdf8;
    --surface-raised: #ffffff;
    --text: #1d2939;
    --muted: #526071;
    --border: rgba(29, 41, 57, 0.10);
    --border-strong: rgba(29, 41, 57, 0.18);

    /* escala cinza */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* status */
    --success: #16a34a;
    --success-soft: rgba(22, 163, 74, 0.12);
    --warning: #d97706;
    --warning-soft: rgba(217, 119, 6, 0.12);
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.12);
    --info: #2563eb;
    --info-soft: rgba(37, 99, 235, 0.12);

    /* tipografia */
    --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-mono: "Fira Code", "SF Mono", ui-monospace, monospace;
    --fs-xs: 0.75rem;
    --fs-sm: 0.875rem;
    --fs-base: 0.95rem;
    --fs-lg: 1.125rem;
    --fs-xl: 1.5rem;
    --fs-2xl: 2rem;

    /* espaçamento (múltiplos de 4) */
    --sp-1: 0.25rem;
    --sp-2: 0.5rem;
    --sp-3: 0.75rem;
    --sp-4: 1rem;
    --sp-5: 1.5rem;
    --sp-6: 2rem;
    --sp-7: 3rem;

    /* raio / sombra / sidebar */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(29, 41, 57, 0.08);
    --shadow: 0 18px 40px rgba(29, 41, 57, 0.08);
    --sidebar-w: 256px;
    --topbar-h: 60px;
}

/* ── Dark mode ── */
[data-theme="dark"] {
    --bg: #0f172a;
    --surface: rgba(30, 41, 59, 0.72);
    --surface-strong: #1e293b;
    --surface-raised: #1e293b;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: rgba(226, 232, 240, 0.10);
    --border-strong: rgba(226, 232, 240, 0.18);
    --primary-soft: rgba(45, 212, 207, 0.14);
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    background: linear-gradient(180deg, #0f172a 0%, #111c33 100%);
}

body {
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    background: var(--bg);
}

/* ── Neutralizar o header antigo (removido do base.html) ── */
.site-header { display: none !important; }

/* ── Layout: sidebar + topbar + conteúdo ── */
body { margin: 0; min-height: 100vh; }

.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface-strong);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 40;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: var(--fs-lg);
    color: var(--text);
}
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius-sm);
    font-weight: 800;
    font-size: var(--fs-lg);
}
.brand-dot { color: var(--primary); }

.side-nav {
    flex: 1;
    padding: var(--sp-3) var(--sp-2);
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.nav-group { border: 0; }
.nav-group > summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-2) var(--sp-3);
    color: var(--muted);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    border-radius: var(--radius-sm);
    user-select: none;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { background: var(--primary-soft); color: var(--primary-dark); }
.nav-group .chevron { transition: transform 0.15s ease; opacity: 0.6; }
.nav-group[open] > summary .chevron { transform: rotate(180deg); }

.nav-item {
    display: block;
    padding: var(--sp-2) var(--sp-4) var(--sp-2) var(--sp-5);
    color: var(--text);
    font-size: var(--fs-sm);
    border-radius: var(--radius-sm);
    margin: 1px 0;
    border-left: 2px solid transparent;
}
.nav-item:hover { background: var(--gray-100); color: var(--primary-dark); }
.nav-item-active {
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 600;
    border-left-color: var(--primary);
}
[data-theme="dark"] .nav-item:hover { background: rgba(148, 163, 184, 0.10); }

/* topbar */
.topbar {
    position: fixed;
    top: 0; left: var(--sidebar-w); right: 0;
    height: var(--topbar-h);
    background: var(--surface-strong);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-4);
    padding: 0 var(--sp-5);
    z-index: 30;
    backdrop-filter: blur(8px);
}
.topbar-user { display: flex; flex-direction: column; line-height: 1.2; text-align: right; }
.topbar-user small { color: var(--muted); font-size: var(--fs-xs); }
.topbar-tools { display: flex; align-items: center; gap: var(--sp-3); }
.topbar-link { color: var(--muted); font-size: var(--fs-sm); }
.topbar-link:hover { color: var(--primary-dark); }

/* conteúdo deslocado pela sidebar + topbar */
.page-shell {
    margin-left: var(--sidebar-w);
    margin-top: var(--topbar-h);
    padding: var(--sp-5) var(--sp-5) var(--sp-7);
    min-height: calc(100vh - var(--topbar-h));
}
/* quando NÃO autenticado (pre-login/404): centraliza, sem sidebar */
.page-shell-center {
    margin-left: 0;
    margin-top: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-5);
}

/* ── Toggle hambúrguer (hidden no desktop) ── */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: var(--sp-3); left: var(--sp-3);
    z-index: 50;
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 40px; height: 40px;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 0;
}
.sidebar-toggle span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 1px; }

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 35;
}
body.sidebar-open .sidebar-overlay { display: block; }

/* ── Mobile (≤ 900px): sidebar vira overlay ── */
@media (max-width: 900px) {
    .sidebar-toggle { display: flex; }
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow);
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .topbar { left: 0; padding-left: 60px; }
    .page-shell { margin-left: 0; }
}

/* status pills reaproveitam tokens novos se faltarem */
.pill-ok { background: var(--success-soft); color: var(--success); }
.pill-off { background: var(--danger-soft); color: var(--danger); }
