* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    display: flex !important;
    flex-direction: column;
    margin: 0 !important;
    padding: 0 !important;
    background-color: #f4f6f8 !important;
    overflow-x: hidden !important;
    min-height: 100vh !important;
}

/* ==========================================
   ESTRUTURA DAS ABAS E GRELHA DO ADMIN
   ========================================== */
.aba-admin { display: none !important; } 
.aba-admin.ativa { 
    display: flex !important; 
    flex-direction: column !important;
    align-items: center !important;
    animation: fadeIn 0.3s; 
    width: 100%;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.grid-estrategia {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 20px;
    align-items: stretch;
    width: 100%;
    box-sizing: border-box;
}

.coluna-esquerda, .coluna-direita {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
}

/* Faz o último cartão de cada coluna preencher e nivelar perfeitamente o rodapé */
.coluna-esquerda > .card-admin:last-child,
.coluna-direita > .card-admin:last-child {
    flex-grow: 1 !important;
}

#card-top-questoes {
    height: 100% !important;
    box-sizing: border-box !important;
}

/* Limitação de largura para as páginas secundárias ficarem bonitas */
#aba-alunos-agrupados > .card-admin,
#aba-equipe > .card-admin,
#aba-adicionar-questao > .card-admin,
#aba-lista-questoes > .card-admin {
    width: 100% !important; 
    max-width: 900px !important; 
    margin: 0 auto !important; 
    box-sizing: border-box !important;
}
#aba-resumo { align-items: stretch !important; }

#app-container {
    flex: 1;
    width: 100% !important;
    max-width: 1200px !important;
    margin: 0 auto !important;
    padding: 20px 15px !important; 
    border-radius: 0;
    box-shadow: none;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
}

.conteudo { padding: 0 !important; width: 100%; box-sizing: border-box; }

/* ==========================================
   BLINDAGEM DA TELA DE LOGIN E CADASTRO
   ========================================== */
#tela-login.ativa, #tela-diretoria-login.ativa, #tela-cadastro.ativa {
    display: flex !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    min-height: 100vh !important;
    height: auto !important;
    background: #f4f6f8 !important;
    align-items: center !important;
    justify-content: flex-start !important;
    z-index: 999999 !important;
    margin: 0 !important;
    padding: 30px 15px 80px 15px !important;
    box-sizing: border-box !important;
    flex-direction: column;
}

.box-login-centralizado {
    width: 100% !important;
    max-width: 400px !important;
    margin: 0 auto !important;
    flex-shrink: 0 !important;
}

.tela { display: none !important; }
.tela.ativa { display: block !important; }

body:has(#tela-login.ativa) #cabecalho-global,
body:has(#tela-cadastro.ativa) #cabecalho-global,
body:has(#tela-diretoria-login.ativa) .cabecalho-fundo,
body:has(#tela-diretoria-login.ativa) #bloco-espaco-menu-id {
    display: none !important;
}

/* --- CABEÇALHO GLOBAL (ALUNO E ADMIN) --- */
.cabecalho-fundo {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #fff;
    width: 100%;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    justify-content: center;
}

#cabecalho-global {
    width: 100%;
    max-width: 1200px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    box-sizing: border-box;
}

.logo-area { display: flex; align-items: center; gap: 15px; }
.user-area { display: flex; align-items: center; gap: 15px; flex-shrink: 0; }
.user-texts { display: flex; flex-direction: column; align-items: flex-end; text-align: right; white-space: nowrap; }
.status-online { font-size: 11px; color: #10b981; font-weight: bold; display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.btn-menu-mobile-header { display: none; }

/* --- MENU DE TOPO E ABAS ADMIN (ESTILO UNIFICADO) --- */
.menu-topo-aluno, .menu-botoes {
    display: none; 
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin: 0 auto 25px auto;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 15px;
    flex-wrap: wrap;
    width: 100%;
    box-sizing: border-box;
}

.menu-topo-aluno.visivel, .menu-botoes { display: flex !important; }

.menu-topo-aluno .nav-item, .menu-botoes .nav-item {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    padding: 10px 20px;
    font-weight: 700;
    color: #475569;
    cursor: pointer;
    border-radius: 8px;
    transition: 0.2s;
    font-size: 14px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.menu-topo-aluno .nav-item:hover, .menu-botoes .nav-item:hover { background: #f1f5f9; }

.menu-topo-aluno .nav-item.ativo, .menu-botoes .nav-item.ativo {
    background: #fbbf24;
    border-color: #f59e0b;
    color: #1e293b;
    box-shadow: 0 4px 10px rgba(251, 191, 36, 0.25);
}

nav.bottom-nav:not(.menu-topo-aluno) { display: none !important; }

/* GAVETA DE MENU */
.bloco-espaco-menu {
    width: 100%;
    display: flex;
    justify-content: center;
    position: sticky;
    top: 76px; 
    z-index: 990;
    background: linear-gradient(180deg, #f4f6f8 80%, transparent);
    padding-bottom: 10px; 
    padding-top: 20px;
    transition: max-height 0.4s ease, padding 0.4s ease, opacity 0.4s ease, margin-bottom 0.4s ease;
    max-height: 200px; 
    overflow: hidden;
    opacity: 1;
}

#container-abas {
    width: 100%;
    max-width: 1200px; 
    padding: 0 15px;
    box-sizing: border-box;
    display: flex;
    align-items: flex-start;
    gap: 15px;
    justify-content: center;
}

.btn-menu-desktop { display: none !important; }

.wrapper-abas {
    overflow: hidden;
    transition: max-width 0.3s ease, max-height 0.3s ease, opacity 0.2s ease;
    width: 100%;
    max-width: 1000px;
    max-height: 200px; 
    opacity: 1;
}

/* ==========================================
   ESTILO DOS CARDS DE RESUMO (KPIs) - FORÇADO
   ========================================== */
.kpi-container {
    display: flex !important;
    gap: 15px !important;
    width: 100% !important;
    flex-wrap: wrap !important;
    margin-bottom: 0px !important;
    padding: 10px !important;
}
.kpi-card {
    flex: 1 !important;
    min-width: 150px !important;
    background: #fff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 20px !important;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
}
.kpi-numero {
    font-size: 28px !important;
    font-weight: 800 !important;
    color: #1e293b !important;
    line-height: 1.2 !important;
}
.kpi-titulo {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #64748b !important;
    text-transform: uppercase !important;
    margin-top: 4px !important;
}

/* --- RODAPÉ GLOBAL --- */
#rodape-global {
    text-align: center;
    padding: 30px 20px;
    color: #94a3b8;
    font-size: 12px;
    margin-top: auto;
    border-top: 1px dashed #cbd5e1;
    width: 100%;
    background-color: transparent;
    display: none; 
}
body:has(#tela-home.ativa) #rodape-global,
body:has(#tela-resultados.ativa) #rodape-global,
body:has(#tela-revisao.ativa) #rodape-global,
body:has(#tela-ranking.ativa) #rodape-global {
    display: block;
}

/* --- COMPONENTES BÁSICOS --- */
.header-logo { display: flex; align-items: center; gap: 18px; font-size: 17px; font-weight: bold; margin-bottom: 35px; color: #222; text-align: left; line-height: 1.4; }
.logo-img { width: 70px; height: 70px; object-fit: contain; border-radius: 50%; box-shadow: 0 4px 10px rgba(0,0,0,0.18); }
.cards-container { display: flex; flex-direction: column; gap: 15px; }
.card { padding: 30px 20px; border-radius: 15px; cursor: pointer; text-align: center; transition: transform 0.2s; }
.card:active { transform: scale(0.98); }
.bg-yellow { background-color: #ffc107; color: white; }
.bg-dark { background-color: #1e293b; color: white; }
.card h2 { font-weight: normal; font-size: 24px; }
.btn-principal { width: 100%; padding: 15px; background-color: #ffc107; color: white; border: none; border-radius: 10px; font-size: 18px; font-weight: bold; cursor: pointer; margin-top: 20px; }
.quiz-header { text-align: center; margin-bottom: 20px; color: #666; font-size: 14px; }
#categoria-atual { display: block; font-weight: bold; color: #ffc107; margin-top: 5px; }
.alternativa { width: 100%; padding: 15px; margin-bottom: 10px; border: 1px solid #ddd; border-radius: 8px; background: white; text-align: left; font-size: 16px; cursor: pointer; }
.alternativa.selecionada { background-color: #fff3cd; border-color: #ffc107; font-weight: bold; box-shadow: 0 0 5px rgba(255, 193, 7, 0.5); }
#box-dica { background: #fff3cd; padding: 15px; border-radius: 8px; margin-top: 15px; color: #856404; font-size: 14px; }
.escondido { display: none !important; }

/* --- FORMULÁRIOS CENTRALIZADOS --- */
.form-group { text-align: left; margin-bottom: 20px; width: 100%; }
.form-group label { display: block; margin-bottom: 8px; color: #555; font-weight: bold; font-size: 14px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 15px; border: 1px solid #ddd; border-radius: 8px; font-size: 16px; outline: none; }
.msg-erro { color: #dc3545; font-size: 14px; margin-bottom: 15px; font-weight: bold; }
.aviso-escola { background-color: #eff6ff; border-left: 4px solid #3b82f6; padding: 15px; border-radius: 8px; margin-bottom: 25px; }
.aviso-escola strong { display: block; color: #1e3a8a; margin-bottom: 5px; }
.aviso-escola p { margin: 0; font-size: 14px; color: #1e40af; }

.card-admin, .box-buscar-aluno, .box-prontuario-card { width: 100% !important; min-width: 0 !important; max-width: 100% !important; box-sizing: border-box !important; margin: 0 !important; padding: 20px !important; }
.card-admin { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 4px 6px rgba(0,0,0,0.02); margin-bottom: 15px !important; }
.card-admin h3 { color: #333; margin-bottom: 5px; font-size: 18px; }

/* TOAST (SISTEMA DE AVISOS FLUTUANTES) */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 999999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast-aviso { min-width: 250px; padding: 15px 20px; border-radius: 8px; color: #fff; background-color: #1e293b; font-size: 14px; font-weight: bold; box-shadow: 0 10px 25px rgba(0,0,0,0.2); display: flex; align-items: center; gap: 12px; animation: slideInToast 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; opacity: 0; transform: translateX(100%); }
.toast-aviso.sucesso { background-color: #10b981; border-left: 6px solid #047857; }
.toast-aviso.erro { background-color: #ef4444; border-left: 6px solid #b91c1c; }
.toast-aviso.info { background-color: #3b82f6; border-left: 6px solid #1d4ed8; }
.toast-aviso.saindo { animation: fadeOutToast 0.3s ease-in forwards; }
@keyframes slideInToast { to { opacity: 1; transform: translateX(0); } }
@keyframes fadeOutToast { to { opacity: 0; transform: translateX(100%); } }

/* ========================================================= */
/* 📱 MAGIA DA RESPONSIVIDADE (COMPUTADOR / TABLET)          */
/* ========================================================= */
@media (min-width: 768px) {
    .cards-container { flex-direction: row; }
    .card { flex: 1; }
    
    .user-info-group {
        display: flex;
        align-items: center;
        gap: 12px;
        white-space: nowrap;
    }
}

@media (max-width: 768px) {
    /* Garante que o cartão de login comece do topo e role suavemente em telas pequenas */
    #tela-login.ativa, #tela-diretoria-login.ativa, #tela-cadastro.ativa {
        justify-content: flex-start !important;
        padding-top: 20px !important;
        padding-bottom: 80px !important;
    }

    /* Ajustes da Grelha Admin no Mobile */
    .grid-estrategia { display: flex !important; flex-direction: column !important; padding: 10px 0 !important; gap: 20px !important; }
    .coluna-esquerda { order: 1 !important; width: 100% !important; }
    .coluna-direita { order: 2 !important; width: 100% !important; }

    /* Mostra o botão Mobile */
    .btn-menu-mobile-header { display: flex !important; }
    
    /* Esconde a logo clássica no mobile */
    .logo-esconder-mobile { display: none !important; }
    
    /* Mantém o Cabeçalho numa LINHA ÚNICA perfeitamente alinhada */
    #cabecalho-global { 
        padding: 12px 15px !important; 
        gap: 10px !important; 
        align-items: center !important; 
        flex-wrap: nowrap !important;
    }

    /* Mantém os 3 filtros rápidos na mesma linha no Mobile */
    .box-buscar-aluno > div:nth-of-type(2) {
        flex-wrap: nowrap !important;
        gap: 6px !important;
    }

    .box-buscar-aluno .btn-filtro {
        flex: 1 !important;
        padding: 6px 4px !important;
        font-size: 11px !important;
        white-space: nowrap !important;
        text-align: center !important;
        justify-content: center !important;
    }
    
    /* BLOCO DIREITO (Nome, Sino, Sair) */
    #bloco-direito-cabecalho {
        width: auto !important;
        flex: 1 !important; 
        flex-wrap: nowrap !important; 
        justify-content: flex-end !important;
        gap: 8px !important; 
    }
    
    /* O NOME DO UTILIZADOR */
    .user-info-text {
        flex: 1 !important; 
        text-align: right !important;
        align-items: flex-end !important;
        margin-right: 5px !important;
        margin-bottom: 0 !important;
    }

    #titulo-boas-vindas {
        max-width: 130px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    
    .logo-mostrar-mobile { display: none !important; }
    
    .texto-sair { display: none !important; }
    .btn-sair { width: 42px !important; padding: 0 !important; }
    
    .menu-topo-aluno, .menu-botoes { padding: 10px; gap: 8px; justify-content: space-between; }
    .menu-topo-aluno .nav-item, .menu-botoes .nav-item { padding: 10px; font-size: 12px; width: calc(50% - 4px); justify-content: center; }
    
    #btn-aba-add-questao { width: 100% !important; order: 5; margin-top: 4px; }
    
    .bloco-espaco-menu { top: 68px; padding-top: 15px; } 
    .bloco-espaco-menu.menu-fechado { max-height: 0 !important; padding-top: 0 !important; padding-bottom: 0 !important; opacity: 0 !important; pointer-events: none !important; }
    .wrapper-abas.fechado { max-width: 1000px; max-height: 0 !important; }

    .kpi-container { gap: 8px !important; flex-wrap: nowrap !important; }
    .kpi-card { padding: 12px 5px !important; min-width: 0 !important; flex: 1 !important; text-align: center !important; }
    .kpi-numero { font-size: 18px !important; }
    .kpi-titulo { font-size: 9px !important; white-space: normal !important; }

    /* ========================================================= */
    /* 📱 CORREÇÃO DOS BOTÕES E LISTAS NO MOBILE                 */
    /* ========================================================= */
    
    /* Fila de Intervenção, Prontos e Pendentes empilhados corretamente */
    #fila-intervencao-lista > div,
    #lista-alunos-prontos > div,
    #lista-alunos-pendentes > div {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
        padding: 14px !important;
    }

    /* Botões "Verificar / Agendar" do painel ocupam a largura ideal */
    #fila-intervencao-lista > div button,
    #lista-alunos-prontos > div button,
    #lista-alunos-pendentes > div button {
        width: 100% !important;
        margin-top: 5px !important;
        padding: 10px !important;
        justify-content: center !important;
        border-radius: 8px !important;
    }

    /* PADRONIZAÇÃO DO BOTÃO DO WHATSAPP (Retangular e elegante) */
    button[onclick*="abrirModalZap"], 
    button[onclick*="abrirModalZapApoio"],
    #lista-alunos-prontos button, 
    #lista-alunos-pendentes button {
        border-radius: 8px !important; /* Remove o formato oval gigante */
        padding: 10px 16px !important;
        font-size: 13px !important;
    }

    /* Badges de erros e unidades quebram linha alinhados */
    #fila-intervencao-lista > div div:nth-child(2),
    #lista-alunos-prontos > div div:nth-child(2),
    #lista-alunos-pendentes > div div:nth-child(2) {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
    }
}

@media (min-width: 769px) {
    .btn-menu-mobile-header { display: none !important; }
    .logo-mostrar-mobile { display: none !important; }
}

/* ========================================== */
/* ESTILOS DA TELA DE REGRAS DO DETRAN (MOBILE) */
/* ========================================== */
@media (max-width: 767px) {
    #tela-tutorial-prova {
        padding: 10px !important;
    }

    #tela-tutorial-prova > div {
        width: 100% !important;
        padding: 10px !important;
        box-sizing: border-box !important;
    }

    #tela-tutorial-prova ul {
        padding: 0 !important;
        margin: 0 !important;
    }

    #tela-tutorial-prova ul li {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        background: #f8fafc !important;
        padding: 16px 12px !important;
        border-radius: 10px !important;
        margin-bottom: 10px !important;
        border: 1px solid #e2e8f0 !important;
    }

    #tela-tutorial-prova ul li strong,
    #tela-tutorial-prova ul li span {
        width: 100% !important;
        display: block !important;
    }

    #tela-tutorial-prova ul li span:first-child {
        font-size: 28px !important;
        margin-bottom: 6px !important;
    }

    #tela-tutorial-prova div[onclick*="check-regras"] {
        padding: 14px !important;
        flex-direction: row !important;
        align-items: center !important;
        text-align: left !important;
    }
}

/* Alinhamento perfeito apenas para a versão Desktop */
@media (min-width: 768px) {
    #tela-tutorial-prova ul li {
        display: flex !important;
        align-items: center !important;
        gap: 15px !important;
        text-align: left !important;
    }

    /* Define uma largura fixa para a área do ícone e do título em negrito no PC */
    #tela-tutorial-prova ul li strong {
        min-width: 160px !important;
        display: inline-block !important;
        text-align: left !important;
    }
}