/* =====================================================================
   DULE ACADEMY — Design tokens
   Paleta derivada da marca: azul (#1E5CFF) + laranja (#FF5B26) do
   chevron do logo. O chevron (>>) é o elemento-assinatura da interface:
   aparece nas barras de progresso, nos botões primários e nos estados
   de "próxima aula" — reforçando a ideia de avanço contínuo no
   aprendizado, que é literalmente o que a marca já desenha.
   ===================================================================== */
:root {
    --bg: #0A0E17;
    --bg-elevated: #10141F;
    --surface: #131826;
    --surface-hover: #171D2E;
    --border: #202638;
    --text: #EDF0F7;
    --text-muted: #8891A8;
    --text-faint: #5B6479;

    --blue: #2F6BFF;
    --blue-dim: #1E4FCC;
    --orange: #FF5B26;
    --orange-dim: #D9481A;

    --gradient-brand: linear-gradient(135deg, var(--blue) 0%, #5B8CFF 45%, var(--orange) 100%);

    --success: #22C55E;
    --warning: #F5A524;
    --danger: #F0455C;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --shadow-card: 0 1px 0 rgba(255,255,255,0.03) inset, 0 20px 40px -24px rgba(0,0,0,0.6);

    --font-display: 'Sora', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
}

body {
    background-image:
        radial-gradient(1200px 600px at 100% -10%, rgba(47,107,255,0.10), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(255,91,38,0.08), transparent 60%);
    background-attachment: fixed;
    min-height: 100vh;
}

h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -0.01em; margin: 0; }

a { color: inherit; text-decoration: none; }

::selection { background: rgba(47,107,255,0.35); }

:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* --------------------------------- Buttons --------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 14px;
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--gradient-brand);
    background-size: 160% 160%;
    background-position: 0% 50%;
    color: #08101F;
    box-shadow: 0 8px 24px -8px rgba(47,107,255,0.55);
}
.btn-primary:hover { background-position: 100% 50%; box-shadow: 0 10px 28px -6px rgba(255,91,38,0.4); }

.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text-muted);
}
.btn-ghost:hover { color: var(--text); border-color: #303954; }

.btn-block { width: 100%; }

/* --------------------------------- Forms --------------------------------- */
.field { margin-bottom: 18px; }
.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.field input {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 13px 14px;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(47,107,255,0.15);
    outline: none;
}
.field-row { display: flex; align-items: center; justify-content: space-between; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 18px;
    border: 1px solid;
}
.alert-error { background: rgba(240,69,92,0.08); border-color: rgba(240,69,92,0.35); color: #FF9AA8; }
.alert-success { background: rgba(34,197,94,0.08); border-color: rgba(34,197,94,0.35); color: #7FE3A3; }

/* --------------------------------- Cards --------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

/* --------------------------------- Chevron (signature element) --------------------------------- */
.chevron {
    display: inline-block;
    width: 0.7em;
    height: 0.7em;
    border-right: 2.5px solid currentColor;
    border-top: 2.5px solid currentColor;
    transform: rotate(45deg);
}

.progress-track {
    position: relative;
    height: 8px;
    background: var(--bg-elevated);
    border-radius: 999px;
    overflow: hidden;
}
.progress-fill {
    position: absolute;
    inset: 0 auto 0 0;
    background: var(--gradient-brand);
    border-radius: 999px;
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --------------------------------- Utility --------------------------------- */
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }

/* =====================================================================
   RESPONSIVIDADE
   - Desktop (> 1100px): visual original, sem alterações.
   - Tablet (901–1100px): sidebar mais estreita, espaçamentos menores.
   - Celular/tablet vertical (<= 900px): sidebar vira drawer (ver nav.js).
   - <= 640px: formulários em 1 coluna.  <= 480px: ajustes finos.
   Os seletores [style*="..."] cobrem grids/tabelas declarados inline nas views.
   ===================================================================== */
html { -webkit-text-size-adjust: 100%; }
img, video, iframe { max-width: 100%; }

/* Elementos do menu mobile: escondidos no desktop */
.menu-toggle, .sidebar-close, .nav-backdrop { display: none; }
.menu-toggle, .sidebar-close {
    width: 44px; height: 44px; flex-shrink: 0;
    align-items: center; justify-content: center;
    background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); cursor: pointer; padding: 0;
}
.menu-toggle:hover, .sidebar-close:hover { background: var(--surface-hover); }
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }

/* Filhos de grids inline podem encolher (evita estourar a largura) */
.shell [style*="display:grid"] > * { min-width: 0; }
.shell .sidebar { overflow-y: auto; overscroll-behavior: contain; }

/* Conteúdo HTML das aulas (vem do editor): nunca maior que a tela */
.lesson-content { overflow-wrap: anywhere; }
.lesson-content img, .lesson-content video, .lesson-content iframe { max-width: 100%; height: auto; }
.lesson-content iframe { aspect-ratio: 16/9; }
.lesson-content pre { overflow-x: auto; }
.lesson-content table { display: block; max-width: 100%; overflow-x: auto; }

/* ------------------------------ Tablet ------------------------------ */
@media (min-width: 901px) and (max-width: 1100px) {
    .shell .sidebar { width: 216px; }
    .shell .topbar { padding: 16px 24px; }
    .shell .content { padding: 24px; }
}

/* ------------------- Celular e tablet vertical (drawer) ------------------- */
@media (max-width: 900px) {
    .menu-toggle, .sidebar-close { display: inline-flex; }
    .sidebar-close { margin-left: auto; }

    .shell .sidebar {
        position: fixed; top: 0; left: 0; bottom: 0;
        height: 100vh; height: 100dvh;
        width: min(300px, 86vw);
        z-index: 100;
        transform: translateX(-100%);
        visibility: hidden;                       /* fora da ordem de tab quando fechado */
        transition: transform .25s ease, visibility 0s linear .25s;
    }
    .shell .sidebar.is-open {
        transform: none; visibility: visible;
        transition: transform .25s ease, visibility 0s;
        box-shadow: 24px 0 48px -24px rgba(0,0,0,0.7);
    }
    .nav-backdrop {
        display: block; position: fixed; inset: 0; z-index: 90;
        background: rgba(4,6,12,0.6);
        opacity: 0; pointer-events: none; transition: opacity .25s ease;
    }
    .nav-backdrop.is-visible { opacity: 1; pointer-events: auto; }
    body.nav-open { overflow: hidden; }

    /* Barra superior fica visível durante o estudo, com o botão de menu sempre à mão */
    .shell .main { overflow-x: clip; }
    .shell .topbar {
        position: sticky; top: 0; z-index: 50; gap: 12px; padding: 10px 16px;
        background: rgba(10,14,23,0.92);
        -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    }
    .topbar-user-name { max-width: 38vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .shell .content { padding: 16px; }

    /* Cards com padding generoso no desktop ficam mais compactos */
    .shell .card[style*="padding:28px"], .shell .card[style*="padding:24px"] { padding: 18px !important; }

    /* Layouts em duas colunas (tabela + formulário, perfil) empilham */
    .shell [style*="grid-template-columns:2fr 1fr"] { grid-template-columns: minmax(0, 1fr) !important; }

    /* Tabelas: a rolagem fica dentro do card, nunca na página inteira */
    .shell .card[style*="overflow:hidden"] { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
    .shell .card.video-frame { overflow: hidden !important; }
    table.admin-table { min-width: 520px; }
    table.admin-table th, table.admin-table td { padding: 12px; }
    table.admin-table .btn { min-height: 40px; }

    /* Toque confortável + evita o zoom automático do iOS em campos < 16px */
    .btn { min-height: 44px; }
    .shell .nav-item { min-height: 46px; }
    .shell input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]):not([type=range]),
    .shell select, .shell textarea,
    .field input { font-size: 16px !important; }
    .shell select, .shell .field input { min-height: 46px; }
    .checkbox-row { min-height: 40px; gap: 10px; }
    .checkbox-row input { width: 20px; height: 20px; flex-shrink: 0; }
}

/* ------------------------------ Celular ------------------------------ */
@media (max-width: 640px) {
    .shell [style*="grid-template-columns:1fr 1fr"],
    .shell [style*="grid-template-columns:1fr 2fr"] { grid-template-columns: minmax(0, 1fr) !important; }

    /* Navegação da aula: ações principais primeiro, botões em largura total */
    .lesson-nav { flex-direction: column; align-items: stretch !important; }
    .lesson-nav-actions { order: -1; flex-direction: column; align-items: stretch !important; }
    .lesson-nav .btn, .lesson-nav form { width: 100%; }
}

/* --------------------------- Celular pequeno --------------------------- */
@media (max-width: 480px) {
    .shell .content [style*="minmax(160px"],
    .shell .content [style*="minmax(180px"] {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 12px !important;
    }
    .shell [style*="min-width:220px"], .shell [style*="min-width:240px"] { min-width: 0 !important; }
    .shell h1 { font-size: 20px !important; }
}
