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

/* ─── Acessibilidade (e-MAG) ─────────────────────────────── */
/* Foco visível global — não sobrescreva sem fornecer alternativa. */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Sidebar é dark navy → outline azul-accent some no fundo. Usa azul claro. */
.sidebar-link:focus-visible,
.sidebar-logout:focus-visible {
    outline: 2px solid #fdd29a;
    outline-offset: -2px;
}

/* Skip link "Pular para o conteúdo" — escondido até receber foco. */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 10000;
    background: var(--ink-1);
    color: var(--white);
    padding: 10px 16px;
    border-radius: 0 0 var(--radius) 0;
    font-weight: 600;
    text-decoration: none;
}
.skip-link:focus,
.skip-link:focus-visible {
    left: 0;
    color: var(--white);
}

/* Utilitário sr-only (visualmente escondido, lido por leitores de tela). */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0);
    white-space: nowrap; border: 0;
}

/* ─── Tokens ─────────────────────────────────────────────── */
:root {
    /* Typography */
    --font: 'Inter', system-ui, -apple-system, sans-serif;

    /* Ink (text) */
    --ink-1: #2f2e2e;   /* headings, values */
    --ink-2: #475569;   /* body text */
    --ink-3: #64748b;   /* muted / labels — contraste WCAG AA (4.6:1 sobre branco) */

    /* Surfaces */
    --bg:       #f8fafc;
    --white:    #ffffff;
    --border:   #e2e8f0;
    --border-2: #f1f5f9;

    /* Accent — one color only */
    --accent:    #f79209;
    --accent-lt: #fff7ec;

    /* Semantic */
    --green:    #0a7d38; /* escurecido p/ contraste AA como texto (WCAG 1.4.3) */
    --green-lt: #f0fdf4;
    --red:      #dc2626;
    --red-lt:   #fef2f2;
    --amber:    #b45f06; /* escurecido p/ contraste AA como texto (WCAG 1.4.3) */
    --amber-lt: #fffbeb;

    /* Sidebar */
    --sb-bg:      #2f2e2e;
    --sb-text:    #94a3b8;
    --sb-text-hv: #f1f5f9;
    --sb-hover:   rgba(255,255,255,.05);
    --sb-active:  rgba(255,255,255,.07);
    --sb-divider: rgba(255,255,255,.07);

    /* Spacing */
    --sidebar-w: 240px;
    /* Topbar com a mesma altura do bloco da logo (.sidebar-brand: 92px)
       para as divisórias das duas colunas ficarem alinhadas. */
    --topbar-h:  92px;

    /* Shape */
    --radius-sm: 5px;
    --radius:    7px;
    --radius-lg: 10px;

    /* Shadow — barely there */
    --shadow-xs: 0 1px 2px rgba(47,46,46,.05);
    --shadow-sm: 0 1px 3px rgba(47,46,46,.07), 0 1px 2px rgba(47,46,46,.04);

    /* ─── TEA palette (soft pastels) ─── */
    --tea-teal:    #6cc4bd;   --tea-teal-ink:  #0e4f4a;
    --tea-peach:   #f3b48a;   --tea-peach-ink: #6b3413;
    --tea-blue:    #8fc3e6;   --tea-blue-ink:  #133b5c;
    --tea-amber:   #f3cc66;   --tea-amber-ink: #5a3d04;
    --tea-green:   #a9d8a3;   --tea-green-ink: #1f4e1a;
    --tea-pink:    #f29bab;   --tea-pink-ink:  #6a1d2c;

    --tea-shadow:  0 6px 18px rgba(47,46,46, .08), 0 2px 4px rgba(47,46,46, .04);
}

/* ─── Base ───────────────────────────────────────────────── */
html { -webkit-font-smoothing: antialiased; }

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    color: var(--ink-2);
    /* REVERT: fundo anterior — para voltar, troque o background abaixo por:
    background:
        linear-gradient(rgba(244, 248, 250, .55), rgba(244, 248, 250, .62)),
        url("/assets/img/bg-puzzle.svg") center center / cover no-repeat fixed,
        #f6f2ee;
    */
    background: url("/assets/img/bgteste.jpeg") center center / cover no-repeat fixed, #fcd9a8;
}

/* Compat: body.tea-bg permanece como alias (mesmo efeito que body padrão) */
body.tea-bg { /* mesmo background — mantido por compatibilidade */ }

/* Páginas que querem fundo limpo (ex.: login) podem opt-out */
body.no-tea-bg {
    background: var(--bg);
}

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

/* ─── Login ──────────────────────────────────────────────── */
/* Roxo da logo (SAPRO). Usado apenas no fluxo de login/recuperação
   — o resto do sistema continua com --accent azul. */
.login-page {
    --login-accent:    #f79209;
    --login-accent-hv: #d97a00;
    --login-accent-lt: rgba(247,146,9, .12);

    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    position: relative;
}

.login-page .app-copyright {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 18px;
}

/* Substitui o azul do --accent dentro do bloco do login */
.login-page .form-control:focus {
    border-color: var(--login-accent);
    box-shadow: 0 0 0 3px var(--login-accent-lt);
}

.login-page .btn-primary {
    background: var(--login-accent);
    border-color: var(--login-accent);
}

.login-page .btn-primary:hover {
    background: var(--login-accent-hv);
    border-color: var(--login-accent-hv);
}

.login-page a { color: var(--login-accent); }
.login-page a:hover { color: var(--login-accent-hv); }

.login-page .login-forgot { color: var(--login-accent); }
.login-page .login-forgot:hover { color: var(--login-accent-hv); }

.login-box {
    width: 100%;
    max-width: 380px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 32px 40px;
    box-shadow: var(--shadow-sm);
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.login-logo img {
    max-height: 110px;
    max-width: 260px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.login-logo a { display: inline-flex; }

.login-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--ink-1);
    text-align: center;
    letter-spacing: -.2px;
    margin-bottom: 4px;
}

.login-subtitle {
    text-align: center;
    color: var(--ink-3);
    font-size: 13px;
    margin-bottom: 28px;
}

/* Linha "Senha [Esqueci minha senha]" ao lado do label */
.login-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.login-label-row label { margin-bottom: 0; }

.login-forgot {
    font-size: 12px;
    font-weight: 500;
    color: var(--accent);
}

.login-forgot:hover { text-decoration: underline; }

/* Bloco auxiliar (link "Voltar ao login" etc.) abaixo do form */
.login-aux {
    margin-top: 18px;
    text-align: center;
    font-size: 13px;
}

.login-aux a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--ink-3);
    font-weight: 500;
}

.login-aux a:hover { color: var(--accent); }

.login-aux a svg { width: 13px; height: 13px; }

/* Chip da etapa 2 do login: mostra o e-mail validado com botão "Trocar" */
.login-conta-confirmada {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px 8px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    margin-bottom: 18px;
}

.login-conta-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--login-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.login-conta-email {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    color: var(--ink-1);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.login-conta-trocar {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-3);
    background: transparent;
    text-decoration: none;
    flex-shrink: 0;
    transition: background .15s, color .15s;
}

.login-conta-trocar:hover {
    background: var(--white);
    color: var(--login-accent);
}

.login-conta-trocar svg { width: 13px; height: 13px; }

/* ─── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-2);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 14px;
    color: var(--ink-1);
    background: var(--white);
    transition: border-color .15s, box-shadow .15s;
}

.form-control::placeholder { color: var(--ink-3); }

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(247,146,9,.1);
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
    white-space: nowrap;
    text-decoration: none;
}

.btn:hover { text-decoration: none; }
.btn:active { opacity: .9; }

.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn-primary {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
    width: 100%;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 600;
    justify-content: center;
}

.btn-primary:hover { background: #d97a00; border-color: #d97a00; }

.btn-secondary {
    background: var(--white);
    color: var(--ink-2);
    border-color: var(--border);
}

.btn-secondary:hover { background: var(--bg); }

.btn-ghost {
    background: transparent;
    color: var(--ink-3);
    border-color: transparent;
    padding: 6px 8px;
}

.btn-ghost:hover { background: var(--border-2); color: var(--ink-2); }

.btn-sm { padding: 5px 12px; font-size: 12px; }

.btn-danger-ghost { color: var(--red); }
.btn-danger-ghost:hover { background: var(--red-lt); color: var(--red); }

.btn:disabled,
.btn[aria-disabled="true"] {
    background: #cbd5e1;
    color: #64748b;
    border-color: #cbd5e1;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
}
.btn-secondary:disabled,
.btn-secondary[aria-disabled="true"] {
    background: var(--border-2);
    color: var(--ink-3);
    border-color: var(--border);
}

/* ─── Alerts ─────────────────────────────────────────────── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    border: 1px solid transparent;
    margin-bottom: 16px;
}

.alert svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }

.alert-danger  { background: var(--red-lt);   color: #991b1b; border-color: #fecaca; }
.alert-success { background: var(--green-lt);  color: #166534; border-color: #bbf7d0; }
.alert-warning { background: var(--amber-lt);  color: #92400e; border-color: #fde68a; }
.alert-info    { background: var(--accent-lt); color: #b86500; border-color: #fde3bf; }

/* ─── Layout ─────────────────────────────────────────────── */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #4c4b4b 0%, #363535 50%, #2f2e2e 100%);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.08) transparent;
}

.sidebar-brand {
    min-height: 92px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--sb-divider);
    flex-shrink: 0;
    background: #fff;
}

.sidebar-brand img {
    width: 100%;
    max-width: 100%;
    max-height: 72px;
    height: auto;
    object-fit: contain;
    display: block;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
}

.sidebar-section {
    padding: 16px 16px 4px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: rgba(255,255,255,.6);
    user-select: none;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 12px;
    margin: 1px 6px;
    border-radius: var(--radius-sm);
    color: var(--sb-text);
    font-size: 13.5px;
    font-weight: 450;
    transition: background .12s, color .12s;
    text-decoration: none;
}

.sidebar-link svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: .7;
    transition: opacity .12s;
}

.sidebar-link:hover {
    background: var(--sb-hover);
    color: var(--sb-text-hv);
    text-decoration: none;
}

.sidebar-link:hover svg { opacity: 1; }

.sidebar-link.active {
    background: var(--sb-active);
    color: var(--sb-text-hv);
    font-weight: 500;
}

.sidebar-link.active svg { opacity: 1; }

.sidebar-footer {
    padding: 12px 16px 14px;
    border-top: 1px solid var(--sb-divider);
    flex-shrink: 0;
    background: linear-gradient(180deg, rgba(47,46,46, .7), rgba(47,46,46, .92));
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    position: relative;
    z-index: 2;
}

/* Nav fica acima do puzzle do fundo */
.sidebar-nav {
    position: relative;
    z-index: 2;
}

/* Section labels e links com leve sombra para legibilidade sobre o puzzle */
.sidebar-section,
.sidebar-link {
    text-shadow: 0 1px 2px rgba(47,46,46, .4);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 9px;
}

.sidebar-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,.1);
    color: rgba(255,255,255,.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 12.5px;
    font-weight: 500;
    color: rgba(255,255,255,.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 11px;
    color: rgba(255,255,255,.3);
}

.sidebar-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,.3);
    cursor: pointer;
    text-decoration: none;
    transition: background .12s, color .12s;
    flex-shrink: 0;
}

.sidebar-logout:hover {
    background: rgba(255,255,255,.07);
    color: rgba(255,255,255,.7);
    text-decoration: none;
}

.sidebar-logout svg { width: 14px; height: 14px; }

/* Rodapé legal — exibido no rodapé da sidebar (fundo escuro) e do login (fundo claro) */
.app-copyright {
    font-size: 10px;
    line-height: 1.4;
    text-align: center;
    color: rgba(255,255,255,.32);
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,.08);
}

.login-page .app-copyright {
    color: var(--ink-3);
    border-top: none;
    padding-top: 0;
    margin-top: 24px;
    font-size: 11.5px;
    opacity: .75;
}

/* ─── Main ───────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* ─── Topbar ─────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h);
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

/* Branco sólido, igual ao fundo do bloco da logo (.sidebar-brand) */
.topbar {
    background: #fff;
    border-bottom-color: rgba(226, 232, 240, .6);
}

.topbar-left { display: flex; align-items: center; gap: 8px; }

.topbar-title {
    /* Mesma família, caixa-alta e degradê do lettering da logo (azul → roxo) */
    font-family: 'Montserrat', var(--font);
    font-size: 18px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    background: linear-gradient(100deg, #F59A1A 0%, #E08300 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: #F79209; /* fallback p/ navegadores sem background-clip:text */
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.topbar-user {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 5px 14px 5px 6px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--white);
}

.topbar-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffa63d 0%, #f79209 100%);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.topbar-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink-1);
    letter-spacing: -.1px;
}

/* ─── Page ───────────────────────────────────────────────── */
.page-content {
    padding: 28px 28px 40px;
    flex: 1;
    max-width: 1280px;
}

/* Página de aula: mais largura p/ o vídeo ficar maior (usada em aula.php) */
.page-content-wide { max-width: 1560px; }

.page-header { margin-bottom: 24px; }

.page-header h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--ink-1);
    letter-spacing: -.3px;
    line-height: 1.3;
}

.page-header p {
    font-size: 13.5px;
    color: var(--ink-3);
    margin-top: 3px;
}

/* ─── Stat Cards ─────────────────────────────────────────── */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-xs);
}

.card-stat {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.card-stat-body {}

.card-stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-3);
    letter-spacing: .01em;
    margin-bottom: 6px;
}

.card-stat-value {
    font-size: 26px;
    font-weight: 600;
    color: var(--ink-1);
    letter-spacing: -.5px;
    line-height: 1;
}

.card-stat-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.card-stat-icon svg {
    width: 18px;
    height: 18px;
    color: var(--ink-3);
}

/* ─── TEA Dashboard — cards estilo quebra-cabeça ─────────── */
.tea-dashboard .page-header h1 {
    font-size: 26px;
    font-weight: 600;
    color: var(--ink-1);
    letter-spacing: -.4px;
    line-height: 1.2;
}

.tea-dashboard .page-header p {
    font-size: 14px;
    color: var(--ink-2);
    margin-top: 6px;
}

.tea-dashboard .cards-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 22px;
    margin-bottom: 32px;
}

.tea-card {
    position: relative;
    background: var(--white);
    border: 2px solid rgba(47,46,46, .15);
    border-radius: 8px;
    padding: 24px 30px 24px 28px;
    box-shadow: var(--tea-shadow);
    overflow: visible;
    transition: transform .18s ease, box-shadow .18s ease;
}

.tea-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(47,46,46, .14), 0 4px 8px rgba(47,46,46, .06);
}

/* Pino QUADRADO projetando à DIREITA — conecta com o próximo card */
.tea-card::after {
    content: "";
    position: absolute;
    right: -14px;
    top: 50%;
    transform: translateY(-50%);
    width: 26px;
    height: 30px;
    border-radius: 4px;
    background: inherit;
    border: 2px solid rgba(47,46,46, .15);
    border-left: 0;
    z-index: 2;
}

/* Reentrância QUADRADA à ESQUERDA — recebe o pino do card anterior */
.tea-card::before {
    content: "";
    position: absolute;
    left: -2px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 24px;
    border-radius: 4px;
    background: linear-gradient(rgba(244, 248, 250, .85), rgba(244, 248, 250, .9));
    box-shadow: inset 0 1px 3px rgba(47,46,46, .18);
    z-index: 1;
}

/* Esconde conectores no início/fim de cada linha (4 colunas) */
.tea-card:nth-child(4n+1)::before { display: none; }
.tea-card:nth-child(4n)::after    { display: none; }
.tea-card:last-child::after       { display: none; }

.tea-card-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.tea-card-body { min-width: 0; }

.tea-card-label {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    margin-bottom: 10px;
    opacity: .92;
}

.tea-card-value {
    font-size: 34px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: -.5px;
    display: inline-flex;
    align-items: baseline;
}

.tea-card-value::after {
    content: ")";
    font-weight: 500;
    margin-left: 1px;
    opacity: .85;
}

.tea-card-icon {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    background: rgba(255, 255, 255, .4);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 2px rgba(47,46,46, .12);
}

.tea-card-icon svg {
    width: 32px;
    height: 32px;
    stroke-width: 1.8;
}

/* Variações de cor pastel */
.tea-card--teal  { background: var(--tea-teal);  color: var(--tea-teal-ink);  }
.tea-card--peach { background: var(--tea-peach); color: var(--tea-peach-ink); }
.tea-card--blue  { background: var(--tea-blue);  color: var(--tea-blue-ink);  }
.tea-card--amber { background: var(--tea-amber); color: var(--tea-amber-ink); }
.tea-card--green { background: var(--tea-green); color: var(--tea-green-ink); }
.tea-card--pink  { background: var(--tea-pink);  color: var(--tea-pink-ink);  }

.tea-card--teal  .tea-card-icon svg { color: var(--tea-teal-ink);  }
.tea-card--peach .tea-card-icon svg { color: var(--tea-peach-ink); }
.tea-card--blue  .tea-card-icon svg { color: var(--tea-blue-ink);  }
.tea-card--amber .tea-card-icon svg { color: var(--tea-amber-ink); }
.tea-card--green .tea-card-icon svg { color: var(--tea-green-ink); }
.tea-card--pink  .tea-card-icon svg { color: var(--tea-pink-ink);  }

/* Tabela com toque TEA: container translúcido sobre o fundo */
.tea-dashboard .table-wrap {
    background: rgba(255, 255, 255, .92);
    border: 1px solid rgba(226, 232, 240, .8);
    border-radius: 18px;
    box-shadow: var(--tea-shadow);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.tea-dashboard .table-header {
    padding: 18px 22px;
    border-bottom-color: rgba(226, 232, 240, .6);
}

.tea-dashboard .table-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.tea-dashboard th {
    background: transparent;
    border-bottom-color: rgba(226, 232, 240, .7);
    padding: 12px 22px;
}

.tea-dashboard td {
    padding: 14px 22px;
    border-bottom-color: rgba(226, 232, 240, .5);
}

@media (max-width: 1100px) {
    .tea-dashboard .cards-grid { grid-template-columns: repeat(2, 1fr); }
    .tea-card:nth-child(4n+1)::before,
    .tea-card:nth-child(4n)::after { display: revert; }
    .tea-card:nth-child(2n+1)::before { display: none; }
    .tea-card:nth-child(2n)::after    { display: none; }
}

@media (max-width: 600px) {
    .tea-dashboard .cards-grid { grid-template-columns: 1fr; }
    .tea-card::before,
    .tea-card::after { display: none; }
}

/* ─── Table ──────────────────────────────────────────────── */
.table-wrap {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}

.table-header {
    padding: 14px 20px 13px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.table-header h2,
.table-header h3 {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink-1);
    margin: 0;
}

.table-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-0, #fff);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 10px;
    min-width: 260px;
    transition: border-color .15s, box-shadow .15s;
}
.search-bar:focus-within {
    border-color: var(--accent, #f79209);
    box-shadow: 0 0 0 3px rgba(247,146,9,.15);
}
.search-bar [data-lucide] {
    width: 14px;
    height: 14px;
    color: var(--ink-3);
    flex-shrink: 0;
}
.search-bar input[type="search"] {
    border: 0;
    background: transparent;
    font-size: 13px;
    color: var(--ink-1);
    flex: 1;
    min-width: 0;
    padding: 4px 0;
}
.search-bar input[type="search"]::-webkit-search-cancel-button { display: none; }
.search-bar .search-clear {
    display: inline-flex;
    align-items: center;
    color: var(--ink-3);
    text-decoration: none;
    line-height: 1;
}
.search-bar .search-clear:hover { color: var(--ink-1); }

@media (max-width: 640px) {
    .table-header { flex-direction: column; align-items: stretch; }
    .table-tools  { flex-wrap: wrap; }
    .search-bar   { min-width: 0; width: 100%; }
}

table { width: 100%; border-collapse: collapse; }

th {
    padding: 9px 16px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--ink-3);
    letter-spacing: .04em;
    text-transform: uppercase;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 11px 16px;
    font-size: 13.5px;
    color: var(--ink-2);
    border-bottom: 1px solid var(--border-2);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover td { background: #fafbfc; }

td strong { color: var(--ink-1); font-weight: 500; }

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: .01em;
    white-space: nowrap;
}

.badge-master  { background: #fff7ec; color: #d97a00;        }
.badge-admin   { background: var(--accent-lt); color: #d97a00; }
.badge-aluno   { background: var(--green-lt);  color: #166534; }
.badge-ativo   { background: var(--green-lt);  color: #166534; }
.badge-inativo { background: var(--red-lt);    color: #991b1b; }

/* ─── Breadcrumb ─────────────────────────────────────────── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--ink-3);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.breadcrumb a {
    color: var(--ink-3);
    text-decoration: none;
    transition: color .15s;
}

.breadcrumb a:hover { color: var(--ink-2); text-decoration: none; }

.breadcrumb svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

.breadcrumb-current {
    color: var(--ink-2);
    font-weight: 500;
}

/* ─── Tipo Badge (video/texto/pdf) ───────────────────────── */
.tipo-video  { background: #fff7ec; color: #d97a00; }
.tipo-texto  { background: #f0fdf4; color: #166534; }
.tipo-pdf    { background: #fff7ed; color: #c2410c; }

/* ─── Row Avatar ─────────────────────────────────────────── */
.row-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--border);
    color: var(--ink-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

/* ─── Divider ────────────────────────────────────────────── */
.divider {
    height: 1px;
    background: var(--border);
    margin: 24px 0;
}

/* ─── Select ─────────────────────────────────────────────── */
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
    cursor: pointer;
}

/* ─── Form Panel (create/edit inline) ───────────────────── */
.form-panel {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
    margin-bottom: 20px;
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}

.form-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink-1);
}

.form-panel form {
    padding: 20px 20px 20px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0 20px;
}

/* ─── Toggle checkbox ────────────────────────────────────── */
.toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-2);
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ─── Count Badge ────────────────────────────────────────── */
.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--border);
    color: var(--ink-2); /* fundo cinza exige texto mais escuro p/ AA */
    font-size: 11px;
    font-weight: 600;
    margin-left: 6px;
}

/* ─── Empty State ────────────────────────────────────────── */
.empty-state {
    padding: 48px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.empty-state svg {
    width: 32px;
    height: 32px;
    color: var(--ink-3);
    opacity: .5;
}

.empty-state p {
    font-size: 13.5px;
    color: var(--ink-3);
}

/* ─── Progress Bar ───────────────────────────────────────── */
.progress-bar {
    height: 5px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width .4s ease;
    min-width: 2px;
}

.progress-fill.done { background: var(--green); }

.progress-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11.5px;
    color: var(--ink-3);
    margin-bottom: 5px;
}

/* ─── Course Cards ───────────────────────────────────────── */
.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.course-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-xs);
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s, box-shadow .15s;
}

.course-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(247,146,9,.08);
    text-decoration: none;
    color: inherit;
}

.course-card-title {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--ink-1);
    line-height: 1.4;
}

.course-card-desc {
    font-size: 12.5px;
    color: var(--ink-3);
    line-height: 1.5;
    flex: 1;
}

.course-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--ink-3);
}

.course-card-meta svg {
    width: 12px;
    height: 12px;
}

/* ─── Lesson Layout ──────────────────────────────────────── */
.lesson-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    align-items: start;
}

.lesson-main {}

.lesson-sidebar {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: sticky;
    top: calc(var(--topbar-h) + 16px);
    max-height: calc(100vh - var(--topbar-h) - 60px);
    overflow-y: auto;
}

.lesson-sidebar-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-3);
    text-transform: uppercase;
    letter-spacing: .05em;
    position: sticky;
    top: 0;
    background: var(--white);
    z-index: 1;
}

.lesson-module-title {
    padding: 10px 16px 4px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--ink-3);
    letter-spacing: .02em;
}

.lesson-nav-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 16px;
    font-size: 13px;
    color: var(--ink-2);
    text-decoration: none;
    transition: background .12s;
    border-left: 2px solid transparent;
}

.lesson-nav-link:hover {
    background: var(--bg);
    text-decoration: none;
}

.lesson-nav-link.active {
    background: var(--accent-lt);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 500;
}

.lesson-nav-link.done {
    color: var(--green);
}

.lesson-nav-link svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    opacity: .5;
}

.lesson-nav-link.active svg,
.lesson-nav-link.done  svg { opacity: 1; }

/* Video embed */
.video-wrapper {
    position: relative;
    padding-top: 56.25%;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}

.video-wrapper iframe,
.video-wrapper video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    background: #000;
    object-fit: contain;
}
/* rede de segurança: vídeo nunca ultrapassa a largura da tela */
video { max-width: 100%; }

/* Lesson content card */
.lesson-content-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-xs);
    margin-bottom: 16px;
}

.lesson-content-card h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--ink-1);
    letter-spacing: -.2px;
    margin-bottom: 6px;
}

.lesson-description {
    font-size: 13.5px;
    color: var(--ink-3);
    margin-bottom: 20px;
}

.lesson-text-body {
    font-size: 14px;
    line-height: 1.75;
    color: var(--ink-2);
}

/* Lesson nav footer */
.lesson-nav-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 4px;
}

/* Done indicator */
.done-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 500;
    color: var(--green);
    background: var(--green-lt);
    padding: 4px 10px;
    border-radius: 4px;
}

.done-badge svg { width: 13px; height: 13px; }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 1100px) {
    .cards-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1024px) {
    .lesson-layout { grid-template-columns: 1fr; }
    .lesson-sidebar { position: static; max-height: none; }
}

/* ─── Botão hambúrguer (oculto em desktop) ───────────────── */
.topbar-hamburger {
    display: none;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-right: 4px;
    color: var(--ink-2);
    padding: 0;
}
.topbar-hamburger:hover { background: var(--bg); }
.topbar-hamburger svg { width: 18px; height: 18px; }

/* ─── Backdrop do drawer mobile ─────────────────────────── */
.sapro-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(47,46,46, .45);
    z-index: 998;
}
.sapro-sidebar-backdrop.is-visible { display: block; }

@media (max-width: 768px) {
    /* Sidebar fica oculta: não há logo para alinhar e 92px é alto demais. */
    :root { --topbar-h: 64px; }
    .topbar-title { font-size: 16px; }
    .topbar-name {
        max-width: 130px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .sidebar {
        transform: translateX(-100%);
        transition: transform .22s ease;
        z-index: 999;
    }
    .sidebar.is-open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .cards-grid { grid-template-columns: 1fr 1fr; }
    .page-content { padding: 20px 16px; }
    .course-grid { grid-template-columns: 1fr; }
    .topbar-hamburger { display: inline-flex; }
}

/* ─── Modal de confirmação ───────────────────────────────── */
.sapro-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.sapro-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(47,46,46, .55);
    backdrop-filter: blur(2px);
}
.sapro-modal-box {
    position: relative;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px 24px 20px;
    box-shadow: 0 8px 24px rgba(47,46,46, .15);
    width: 100%;
    max-width: 380px;
}
.sapro-modal-message {
    color: var(--ink-1);
    font-size: 14.5px;
    font-weight: 500;
    line-height: 1.5;
    margin-bottom: 20px;
}
.sapro-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.sapro-modal-actions .btn {
    width: auto;
}

/* ─── Paginação ──────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-top: 1px solid var(--border-2);
    flex-wrap: wrap;
}
.pagination-info {
    font-size: 12.5px;
    color: var(--ink-3);
}
.pagination-controls {
    display: flex;
    gap: 8px;
}

/* ─── Acessibilidade: prefers-reduced-motion ─────────────────── */
/* Quando o usuário pediu menos movimento no SO, neutraliza transitions,
   animations e scroll suave. Preserva acessibilidade de quem tem náusea
   vestibular ou sensibilidade a movimento. (e-MAG / WCAG 2.3.3) */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ─── aria-current="page" — destaque programático do link ativo ─── */
.sidebar-link[aria-current="page"] {
    /* Reforça o estilo .active sem mudar layout — útil quando, por algum
       motivo, a classe .active não foi aplicada mas o aria-current sim. */
    background: var(--sb-active);
    color: var(--sb-text-hv);
}

/* ─── Erro inline por campo (acessibilidade) ─────────────────── */
/* Aparece logo abaixo do <input> quando $erros[$campo] está setado.
   O input recebe aria-invalid="true" + aria-describedby apontando aqui. */
.field-error {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #991b1b;
    margin-top: 4px;
}
.field-error svg { width: 12px; height: 12px; flex-shrink: 0; }

.form-control[aria-invalid="true"] {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .08);
}
