/* css/testame.css - V-FINAL (LIMPO, OTIMIZADO & IOS FIX) */

:root {
    /* Paleta de Cores */
    --paper-bg: #fdfbf7;
    --paper-text: #1a1a1a;
    --highlight: #f59e0b; /* Laranja Principal */
    --header-height: 70px;
    
    /* Tema Escuro (App) */
    --bg-app: #0f172a;        /* Fundo Geral */
    --bg-sidebar: #1e293b;    /* Cards e Paineis */
    --border-color: #334155;  /* Bordas Sutis */
    --text-main: #f8fafc;     /* Texto Claro */
    --text-muted: #94a3b8;    /* Texto Secundário */
    
    /* Cores de Estado */
    --success: #10b981;
    --error: #ef4444;
}

/* ============================================================
   1. ESTRUTURA BASE (APP LAYOUT - SEM SCROLL NA JANELA)
   ============================================================ */
* { box-sizing: border-box; }

body.testame-body {
    background-color: var(--bg-app);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    height: 100vh;        
    width: 100vw;
    margin: 0;
    padding: 0;
    display: flex;        
    flex-direction: column;
    overflow: hidden;     /* TRAVA o scroll do navegador (App feel) */
}

/* Header Fixo no Topo */
.testame-header {
    height: var(--header-height);
    background-color: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    z-index: 50;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    position: relative;
}

.header-left, .header-right { display: flex; align-items: center; gap: 10px; }

.logo { 
    font-weight: 800; 
    color: var(--highlight); 
    font-size: 1.4rem; 
    letter-spacing: -0.5px;
}

.header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0,0,0,0.3);
    padding: 5px 15px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    font-family: monospace;
    font-size: 1rem;
    color: var(--highlight);
    display: flex; align-items: center; gap: 8px;
}

/* Container Principal (Onde as telas são renderizadas) */
#testame-app {
    flex: 1;
    width: 100%;
    height: calc(100vh - var(--header-height));
    overflow: hidden; /* O conteúdo interno que deve rolar */
    position: relative;
}

/* ============================================================
   2. BOTÕES GERAIS
   ============================================================ */
.btn-driven-primary {
    background-color: var(--highlight);
    color: #0f172a;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
}
.btn-driven-primary:hover { filter: brightness(1.1); transform: translateY(-2px); }

.btn-share, .btn-ranking, .btn-finish, .btn-icon {
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    display: flex; align-items: center; gap: 6px;
    font-size: 0.9rem;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.btn-share { background-color: var(--highlight); color: #000; padding: 7px 10px;}
.btn-share:hover { filter: brightness(1.1); }

.btn-ranking { border-color: var(--highlight); color: var(--highlight); background: transparent; }
.btn-ranking:hover { background: var(--highlight); color: #000; }

.btn-finish { background-color: #10b981; color: #fff; }
.btn-finish:hover { background-color: #059669; }

.btn-icon { border-color: var(--border-color); color: #ef4444; background: transparent; }
.btn-icon:hover { background: rgba(239,68,68,0.1); border-color: #ef4444; }


/* ============================================================
   3. TELA DE CONFIGURAÇÃO (Card Centralizado)
   ============================================================ */
.config-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-app);
    padding: 1rem;
    overflow-y: auto; /* Garante scroll se necessário */
}

.config-container {
    width: 100%;
    max-width: 600px; /* Otimizado */
    max-height: 80vh;
    background-color: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex; flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    overflow: hidden;
}

.config-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background-color: rgba(0,0,0,0.2);
    flex-shrink: 0;
}
.config-header h2 { margin: 0; color: var(--highlight); font-size: 1.5rem; }
.config-header p { margin: 5px 0 0 0; color: var(--text-muted); font-size: 0.9rem; }

.config-columns-title {
    display: grid;
    grid-template-columns: 1fr 75px 75px; /* Ajustado para mobile */
    gap: 8px;
    padding: 1rem 1.5rem 0.5rem 1rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    border-bottom: 1px solid var(--border-color);
    background-color: rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.config-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.5rem 1rem 1rem;
}

.subject-config-row {
    display: grid;
    grid-template-columns: 1fr 75px 75px;
    gap: 8px;
    align-items: center;
    padding: 0.6rem 0.5rem;
    background-color: rgba(255,255,255,0.03);
    border: 1px solid transparent;
    border-radius: 6px;
    margin-bottom: 8px;
    transition: all 0.2s;
}
.subject-config-row:hover { border-color: var(--highlight); background-color: rgba(255,255,255,0.05); }

.subject-name { font-size: 0.9rem; font-weight: 500; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.form-control {
    width: 100%; background-color: var(--bg-app); border: 1px solid var(--border-color);
    color: #fff; padding: 6px 2px; border-radius: 6px; text-align: center; font-size: 0.95rem;
}
.form-control:focus { outline: none; border-color: var(--highlight); box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2); }

.config-footer {
    padding: 1rem 1.5rem;
    background-color: var(--bg-sidebar);
    border-top: 1px solid var(--border-color);
    display: flex; flex-direction: column; 
    gap: 1rem; align-items: center; text-align: center;
    flex-shrink: 0;
}
@media (min-width: 480px) {
    .config-footer { flex-direction: row; justify-content: space-between; text-align: left; }
    #btn-generate { width: auto; min-width: 200px; }
}
#btn-generate { width: 100%; box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3); }
.total-badge { display: flex; flex-direction: column; font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; }
.total-badge strong { font-size: 1.8rem; color: var(--text-main); font-weight: 800; line-height: 1.1; }


/* ============================================================
   4. TELA DE PROVA (LAYOUT FINAL COM FIX IOS)
   ============================================================ */

/* --- ÁREA DE TRABALHO --- */
.exam-workspace {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-app);
}

/* SIDEBAR DA PROVA (Fixa à Esquerda) */
.exam-sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex; flex-direction: column;
    height: 100%; flex-shrink: 0; z-index: 20;
}
.sidebar-header-content { padding: 1rem; border-bottom: 1px solid var(--border-color); text-align: center; }
.sidebar-scroll-area { flex: 1; overflow-y: auto; padding: 10px; }

#question-nav-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }

.question-nav-btn {
    aspect-ratio: 1; background: transparent; border: 1px solid var(--border-color);
    color: #9ca3af; border-radius: 4px; cursor: pointer; font-weight: 600; font-size: 0.85rem;
    display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.question-nav-btn:hover { border-color: var(--highlight); color: var(--highlight); }
.question-nav-btn.answered { background-color: #065f46; border-color: #059669; color: #fff; }
.question-nav-btn.anulada { text-decoration: line-through; color: #ef4444; border-color: #ef4444; opacity: 0.7; }

/* --- PAPEL DA PROVA (Container de Rolagem Principal - FIX IOS) --- */
.exam-paper-container {
    flex: 1; /* Ocupa espaço restante */
    height: 100%;
    
    /* CORREÇÃO CRÍTICA IOS: BLOCK, NÃO FLEX */
    display: block; 
    overflow-y: auto; 
    -webkit-overflow-scrolling: touch; 
    
    background-color: #111827; 
    padding: 3rem; 
    text-align: center; 
}

/* A Folha A4 */
.exam-paper {
    /* Centralização Clássica */
    display: block;
    margin: 0 auto; 
    text-align: left; 
    
    width: 100%; max-width: 1100px;
    height: auto; min-height: 100%; 
    
    background-color: var(--paper-bg); color: var(--paper-text);
    padding: 4rem;
    box-shadow: 0 0 40px rgba(0,0,0,0.6);
    border-radius: 2px;
    margin-bottom: 100px; position: relative;
    
    /* Fix Renderização */
    transform: translateZ(0); 
}

/* Cabeçalho do Papel */
.paper-header {
    display: flex; justify-content: space-between; align-items: flex-end;
    border-bottom: 2px solid #000; padding-bottom: 1.5rem; margin-bottom: 2.5rem;
}
.paper-header h1 { margin: 0; font-size: 2.2rem; font-weight: 900; line-height: 1; letter-spacing: -1px; color: #000; }
.paper-header p { margin: 0; font-size: 0.85rem; font-weight: 600; color: #666; text-transform: uppercase; }

/* Colunas estilo Jornal */
.exam-content {
    column-count: 2; column-gap: 4rem; column-rule: 1px solid #e5e7eb;
}

.question-block {
    break-inside: avoid; page-break-inside: avoid; display: inline-block; width: 100%;
    margin-bottom: 3rem; font-family: 'Merriweather', serif;
}

.question-header {
    font-family: 'Inter', sans-serif; font-weight: 800; font-size: 0.9rem; margin-bottom: 0.8rem;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 2px solid #000; padding-bottom: 5px; color: #000;
}

.anular-btn {
    font-size: 0.7rem; color: #dc2626; cursor: pointer; border: 1px solid #dc2626;
    padding: 2px 8px; border-radius: 12px; background: transparent; font-weight: 600;
}

.question-text { margin-bottom: 1rem; text-align: justify; line-height: 1.6; color: #1a1a1a; }

/* Alternativas */
.alternatives-list { list-style: none; padding: 0; margin: 0; }
.alternative-item {
    display: flex; flex-wrap: wrap; gap: 0.8rem; padding: 0.6rem 0; cursor: pointer;
    font-family: 'Inter', sans-serif; font-size: 0.9rem; align-items: flex-start;
    border-radius: 4px; transition: background-color 0.2s; color: #1a1a1a;
}
.alternative-item:hover { background-color: rgba(0,0,0,0.05); }
.alternative-item.selected { background-color: rgba(0,0,0,0.03); }
.alternative-item.eliminated { opacity: 0.5; text-decoration: line-through; }

.alt-letter {
    font-weight: 700; min-width: 26px; height: 26px; border-radius: 50%; border: 1px solid #000;
    display: flex; align-items: center; justify-content: center; font-size: 0.8rem; flex-shrink: 0;
    margin-top: 2px; color: #000; position: relative;
}

/* Feedback Visual (Check/X) */
.alternative-item.selected .alt-letter { background-color: var(--highlight); border-color: var(--highlight); color: transparent; }
.alternative-item.selected .alt-letter::after {
    content: "\f00d"; font-family: "Font Awesome 6 Free"; font-weight: 900;
    position: absolute; color: #000; font-size: 0.9rem; top: 50%; left: 50%; transform: translate(-50%, -50%);
}

.alternative-item:has(.alt-feedback.correct) .alt-letter { background: #10b981 !important; border-color: #10b981 !important; color: transparent !important; }
.alternative-item:has(.alt-feedback.correct) .alt-letter::after { content: "\f00c"; font-family: "Font Awesome 6 Free"; font-weight: 900; color: #fff; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }

.alternative-item:has(.alt-feedback.wrong) .alt-letter { background: #ef4444 !important; border-color: #ef4444 !important; color: transparent !important; }
.alternative-item:has(.alt-feedback.wrong) .alt-letter::after { content: "\f00d"; font-family: "Font Awesome 6 Free"; font-weight: 900; color: #fff; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }

/* Feedback Textos */
.feedback-general {
    margin: 1rem 0; padding: 1rem; border: 1px solid var(--highlight);
    background-color: rgba(245, 158, 11, 0.1); color: #b45309; border-radius: 8px;
    font-family: 'Inter', sans-serif; font-size: 0.9rem;
}
.alt-feedback {
    flex-basis: 100%; width: 100%; margin-top: 10px; padding: 10px 15px;
    border-radius: 6px; font-size: 0.9rem; font-weight: 500; line-height: 1.5;
}
.alt-feedback.correct { background-color: #dcfce7; color: #14532d; border-left: 4px solid #166534; }
.alt-feedback.wrong { background-color: #fee2e2; color: #7f1d1d; border-left: 4px solid #991b1b; }
.alt-feedback.wrong-unselected { background: #e0e7ff; color: #3b82f6; border-left: 4px solid #3b82f6; }


/* --- RESPONSIVIDADE PROVA MOBILE --- */
@media (max-width: 768px) {
    .exam-workspace { flex-direction: column; }
    
    .exam-sidebar { 
        width: 100%; height: auto; max-height: 140px; 
        border-right: none; border-bottom: 1px solid #374151; flex-direction: row;
    }
    .sidebar-header-content { display: none; }
    .sidebar-scroll-area { display: flex; gap: 10px; overflow-x: auto; padding: 10px; align-items: center; }
    #question-nav-grid { display: flex; gap: 8px; grid-template-columns: none; }
    .question-nav-btn { min-width: 40px; height: 40px; flex-shrink: 0; }
    
    .exam-paper-container { padding: 0; background-color: var(--paper-bg); }
    .exam-paper { padding: 1.5rem; margin-bottom: 80px; max-width: 100%; border-radius: 0; box-shadow: none; }
    .exam-content { column-count: 1; }
    .paper-header { flex-direction: column; align-items: flex-start; gap: 5px; }
    .question-text { font-size: 0.95rem; }
}


/* ============================================================
   5. TELA DE RANKING & FÓRUM
   ============================================================ */
.ranking-wrapper {
    width: 100%; height: 100%; background-color: var(--bg-app);
    padding: 1.5rem; overflow: hidden; display: flex; flex-direction: column;
}
.ranking-split-layout { display: flex; gap: 1.5rem; height: 100%; width: 100%; }

/* Esquerda */
.ranking-left-col { flex: 3; display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.ranking-header h2 { color: var(--highlight); font-size: 1.8rem; margin: 0; display: flex; align-items: center; gap: 10px; }
.ranking-header p { color: var(--text-muted); font-size: 0.9rem; margin-top: 5px; }

.ranking-card {
    flex: 1; background-color: var(--bg-sidebar); border: 1px solid var(--border-color);
    border-radius: 12px; display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.ranking-table-scroll { flex: 1; overflow: auto; width: 100%; }
.ranking-table { width: 100%; border-collapse: collapse; min-width: 600px; }

.ranking-table thead th {
    position: sticky; top: 0; background-color: var(--bg-sidebar); z-index: 10;
    padding: 1rem; color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase;
    font-weight: 700; border-bottom: 1px solid var(--border-color);
}
.ranking-table td { padding: 1rem; border-bottom: 1px solid var(--border-color); color: var(--text-main); vertical-align: middle; }

/* Colunas Tabela */
.col-pos { width: 60px; text-align: center !important; }
.col-name { text-align: left !important; padding-left: 1.5rem; }
.col-score, .col-anuladas { width: 100px; text-align: center !important; }
.rank-pos.top1 { color: #fbbf24; text-shadow: 0 0 10px rgba(251, 191, 36, 0.3); font-size: 1.3rem; }
.rank-score { font-weight: 800; color: #10b981; }

.rank-user-info { display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.rank-user-name { font-weight: 700; font-size: 1rem; color: var(--text-main); }
.rank-tags-container { display: flex; flex-wrap: wrap; gap: 6px; }
.rank-tag {
    font-size: 0.65rem; color: var(--text-muted); background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color); padding: 2px 6px; border-radius: 4px;
    white-space: nowrap; display: inline-flex; align-items: center; gap: 3px;
}
.rank-tag b { color: var(--highlight); }

/* Direita (Fórum) */
.ranking-right-col { flex: 1; min-width: 350px; max-width: 500px; display: flex; flex-direction: column; }
.forum-section {
    height: 100%; background-color: var(--bg-sidebar); border: 1px solid var(--border-color);
    border-radius: 12px; display: flex; flex-direction: column; overflow: hidden;
}
.forum-title { padding: 1.5rem; font-size: 1.2rem; color: var(--text-main); border-bottom: 1px solid var(--border-color); background-color: rgba(0,0,0,0.2); }
.comment-input-wrapper { padding: 1rem; border-bottom: 1px solid var(--border-color); display: flex; flex-direction: column; gap: 10px; }
.comment-input { width: 100%; background-color: var(--bg-app); border: 1px solid var(--border-color); color: #fff; padding: 10px; border-radius: 8px; resize: none; height: 60px; }
.btn-comment { background-color: var(--highlight); color: #000; border: none; padding: 6px 20px; border-radius: 6px; font-weight: 700; cursor: pointer; align-self: flex-end; }

.comments-list-scroll { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 1rem; }
.comment-item { background-color: rgba(255,255,255,0.03); border: 1px solid var(--border-color); border-radius: 8px; padding: 1rem; }
.comment-header { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 0.8rem; }
.comment-author { color: var(--highlight); font-weight: 700; }
.comment-date { color: var(--text-muted); }
.comment-body { font-size: 0.9rem; margin-bottom: 10px; word-wrap: break-word; }

.comment-actions { display: flex; align-items: center; gap: 15px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.05); font-size: 0.8rem; color: var(--text-muted); }
.action-btn { cursor: pointer; display: flex; align-items: center; gap: 4px; }
.btn-reply-toggle { background: none; border: none; color: var(--text-muted); cursor: pointer; }
.owner-actions { margin-left: auto; display: flex; gap: 10px; padding-left: 10px; border-left: 1px solid var(--border-color); }

.reply-section { margin-top: 10px; margin-left: 15px; padding-left: 10px; border-left: 2px solid var(--border-color); display: flex; flex-direction: column; gap: 8px; }
.reply-item { background-color: rgba(255,255,255,0.03); padding: 8px 10px; border-radius: 6px; font-size: 0.85rem; }
.reply-input-box { margin-top: 10px; margin-left: 15px; display: flex; gap: 8px; }
.input-reply-text { flex: 1; background: rgba(0,0,0,0.3); border: 1px solid var(--border-color); color: #fff; padding: 6px; }
.btn-send-reply { padding: 6px 12px; background: var(--highlight); border: none; border-radius: 4px; font-weight: 700; cursor: pointer; }

/* Questão Embutida */
.embedded-question { margin-top: 10px; background-color: rgba(0,0,0,0.2); border: 1px solid var(--border-color); border-left: 3px solid var(--highlight); border-radius: 8px; padding: 12px; font-size: 0.85rem; }
.eq-header { font-weight: 700; color: var(--highlight); margin-bottom: 8px; text-transform: uppercase; font-size: 0.75rem; }
.eq-enunciado { display: block; margin-bottom: 10px; font-style: italic; opacity: 0.9; }
.eq-details { background-color: rgba(255,255,255,0.05); padding: 10px; border-radius: 6px; border-left: 3px solid var(--success); }


/* ============================================================
   6. LOADER & MODAIS
   ============================================================ */

/* LOADER FIXO CENTRAL */
.loader-container {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    min-height: calc(100vh - var(--header-height));
    color: var(--text-main); text-align: center; background-color: var(--bg-app); z-index: 50; padding: 2rem;
}
.loader-container i { font-size: 4rem; margin-bottom: 1.5rem; }
.loader-container h2 { font-size: 1.5rem; margin-bottom: 1rem; }
.loader-container p { max-width: 300px; line-height: 1.6; }

.drv-progress-container {
    width: 100%; max-width: 300px; height: 8px; background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px; margin: 1.5rem 0 0.5rem 0; overflow: hidden;
}
.drv-progress-bar {
    height: 100%; background-color: var(--highlight); width: 0%; border-radius: 4px;
    transition: width 0.3s ease-out; box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}
#gen-status { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 2rem; height: 1.5em; }

.loading-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--bg-app); display: flex; justify-content: center; align-items: center; z-index: 10000;
}
.loader-spinner { text-align: center; color: var(--highlight); font-size: 24px; }
.loader-spinner i { font-size: 48px; margin-bottom: 10px; }

/* MODAL */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8); z-index: 9999; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(5px);
}
.modal-box {
    background: var(--bg-sidebar); border: 1px solid var(--border-color); border-radius: 16px;
    width: 90%; max-width: 500px; max-height: 85vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.modal-header { padding: 1.5rem; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.modal-header h3 { margin: 0; color: var(--highlight); font-size: 1.2rem; }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 2rem; color: var(--text-main); overflow-y: auto; flex: 1; }
.modal-footer { padding: 1.5rem; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 10px; flex-shrink: 0; }
.btn-modal-primary { background: var(--highlight); color: #000; padding: 10px 20px; border-radius: 6px; border: none; font-weight: 700; cursor: pointer; }
.btn-modal-secondary { background: transparent; color: #fff; border: 1px solid var(--border-color); padding: 10px 20px; border-radius: 6px; cursor: pointer; }

.toast-notification {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-150%);
    background: var(--bg-sidebar); color: #fff; border: 1px solid var(--highlight);
    padding: 12px 24px; border-radius: 50px; display: flex; gap: 10px; align-items: center; z-index: 10000; transition: all 0.4s; opacity: 0;
}
.toast-notification.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ============================================================
   7. DASHBOARD HOME (CARD GRID)
   ============================================================ */
.testame-dashboard { padding: 2rem; background-color: var(--bg-app); height: 100vh; overflow-y: auto; }
.dashboard-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2.5rem; flex-wrap: wrap; gap: 1rem; border-bottom: 1px solid var(--border-color); padding-bottom: 1rem; }
.header-actions { display: flex; align-items: center; gap: 1.5rem; }

.btn-icon-header { background: transparent; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; position: relative; padding: 8px; border-radius: 50%; transition: all 0.2s; display: flex; align-items: center; justify-content: center; }
.btn-icon-header:hover { background-color: rgba(255,255,255,0.05); color: var(--text-main); }
.notification-badge { position: absolute; top: 2px; right: 2px; background-color: var(--error); color: white; font-size: 0.6rem; font-weight: 700; padding: 2px 5px; border-radius: 10px; border: 1px solid var(--bg-sidebar); }

.simulados-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem; padding-bottom: 3rem; }
.simulado-card { background-color: var(--bg-sidebar); border: 1px solid var(--border-color); border-radius: 12px; padding: 1.5rem; display: flex; flex-direction: column; transition: transform 0.2s, border-color 0.2s; position: relative; }
.simulado-card:hover { transform: translateY(-5px); border-color: var(--highlight); box-shadow: 0 10px 25px rgba(0,0,0,0.3); }

.sim-card-header { display: flex; justify-content: space-between; margin-bottom: 1rem; }
.sim-icon { width: 40px; height: 40px; background: rgba(245, 158, 11, 0.1); color: var(--highlight); border-radius: 8px; display: flex; justify-content: center; align-items: center; font-size: 1.2rem; }
.sim-card-body h3 { font-size: 1.2rem; margin: 0 0 5px 0; color: var(--text-main); }
.sim-date { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 1rem; }
.sim-stats { display: flex; gap: 10px; margin-bottom: 1.5rem; }
.stat-pill { background: rgba(255,255,255,0.05); border: 1px solid var(--border-color); padding: 4px 10px; border-radius: 20px; font-size: 0.8rem; color: var(--text-main); display: flex; align-items: center; gap: 5px; }
.stat-pill i { color: var(--highlight); }

.sim-card-footer { margin-top: auto; display: flex; gap: 10px; }
.btn-card-action { flex: 1; padding: 8px; border-radius: 6px; border: 1px solid var(--highlight); background: transparent; color: var(--highlight); font-weight: 600; font-size: 0.85rem; cursor: pointer; text-align: center; text-decoration: none; transition: all 0.2s; display: flex; justify-content: center; align-items: center; gap: 5px; }
.btn-card-action:hover { background: var(--highlight); color: #000; }
.btn-card-action.secondary { border-color: var(--border-color); color: var(--text-muted); }
.btn-card-action.secondary:hover { background: rgba(255,255,255,0.05); color: #fff; }

.btn-icon-small.delete { background: transparent; border: none; color: var(--text-muted); cursor: pointer; padding: 6px; border-radius: 4px; transition: all 0.2s; font-size: 1rem; }
.btn-icon-small.delete:hover { color: var(--error); background-color: rgba(239, 68, 68, 0.1); }
.btn-text-small { background: transparent; border: 1px solid var(--border-color); color: var(--text-muted); font-size: 0.75rem; padding: 2px 8px; border-radius: 4px; cursor: pointer; transition: all 0.2s; }
.btn-text-small:hover { color: var(--text-main); border-color: var(--text-main); background: rgba(255,255,255,0.05); }

/* Notificações Popover */
.notification-panel {
    position: absolute; top: 40px; right: 0; width: 320px; background: var(--bg-sidebar); border: 1px solid var(--border-color); border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.5); display: none; z-index: 100; flex-direction: column;
}
.notification-panel.active { display: flex; animation: slideDown 0.2s ease; }
.notif-header { padding: 12px 16px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; background: rgba(0,0,0,0.2); }
.notif-header h3 { margin: 0; font-size: 0.95rem; color: var(--text-main); }
.notif-list { max-height: 300px; overflow-y: auto; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--border-color); display: flex; gap: 12px; cursor: pointer; transition: background 0.2s; }
.notif-item:hover { background: rgba(255,255,255,0.03); }
.notif-icon { color: var(--highlight); margin-top: 3px; }
.notif-content p { margin: 0; font-size: 0.85rem; color: var(--text-main); line-height: 1.4; }
.notif-time { font-size: 0.7rem; color: var(--text-muted); display: block; margin-top: 4px; }
.notif-empty { padding: 20px; text-align: center; color: var(--text-muted); font-size: 0.9rem; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* Sidebar Badge & Popover */
.sidebar-badge { position: absolute; top: -5px; right: -5px; background-color: var(--error); color: white; font-size: 0.55rem; font-weight: 800; min-width: 14px; height: 14px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 1px solid var(--bg-sidebar); }
.nav-link.highlight-action { color: var(--highlight); font-weight: 600; }
.nav-link.highlight-action i { color: var(--highlight); }
.nav-link.highlight-action:hover { background-color: rgba(245, 158, 11, 0.1); }

.sidebar-popover {
    position: fixed; left: 270px; top: 250px; width: 300px; background: var(--bg-sidebar); border: 1px solid var(--border-color); border-radius: 12px; box-shadow: 5px 5px 20px rgba(0,0,0,0.5); z-index: 1000; display: none; flex-direction: column; animation: fadeInRight 0.2s ease;
}
#main-content.expanded .sidebar-popover { left: 80px; }
@media (max-width: 768px) { .sidebar-popover { left: 50%; top: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 350px; } }
@keyframes fadeInRight { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }

/* Estado Vazio */
.empty-state-card { grid-column: 1 / -1; background: var(--bg-sidebar); border: 2px dashed var(--border-color); padding: 3rem; text-align: center; border-radius: 16px; color: var(--text-muted); }
.empty-state-card i { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }

/* Botões Nav Extras */
.btn-home { background: transparent; border: 1px solid var(--border-color); color: var(--text-muted); padding: 8px 12px; border-radius: 6px; cursor: pointer; font-size: 1rem; transition: all 0.2s; }
.btn-home:hover { border-color: var(--highlight); color: var(--highlight); background-color: rgba(245, 158, 11, 0.1); }

.btn-back-exam { background: transparent; border: 1px solid var(--border-color); color: var(--highlight); padding: 8px 16px; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 0.85rem; display: inline-flex; align-items: center; gap: 8px; margin-bottom: 1rem; align-self: flex-start; transition: all 0.2s; }
.btn-back-exam:hover { background-color: var(--bg-sidebar); border-color: var(--highlight); transform: translateX(-3px); }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-app); }
::-webkit-scrollbar-thumb { background: #4b5563; border-radius: 4px; border: 2px solid var(--bg-app); }
::-webkit-scrollbar-thumb:hover { background: var(--highlight); }

/* ============================================================
   8. RESPONSIVIDADE GLOBAL FINAL
   ============================================================ */
@media (max-width: 900px) {
    /* Reseta layout para bloco com scroll nativo da janela */
    body.testame-body, #testame-app, .ranking-wrapper { overflow: auto !important; height: auto !important; display: block; }
    
    .testame-header { padding: 0 10px; height: 60px; position: relative; }
    .header-left .logo { display: block; font-size: 1.1rem; }
    .share-text, #btn-exit-text { display: none; }
    .header-center { position: static; transform: none; padding: 1px 1px; font-size: 0.8rem; margin: 0 auto; background: rgba(255,255,255,0.05); }

    /* Ranking Mobile */
    .ranking-wrapper { padding: 10px; }
    .ranking-split-layout { flex-direction: column; gap: 2rem; height: auto; }
    .ranking-left-col, .ranking-right-col { flex: none; width: 100%; min-width: 0; max-width: 100%; }
    .ranking-card, .forum-section { height: auto; max-height: 500px; overflow: hidden; display: flex; flex-direction: column; }
    
    .ranking-table-scroll { overflow-x: auto; }
    .ranking-table { min-width: 600px; }
    .ranking-table thead { display: table-header-group; }
    .col-anuladas { display: table-cell; }

    .comment-input-wrapper { flex-direction: column; }
    .btn-comment { width: 100%; }
    .comments-list-scroll { max-height: 400px; }

    /* Loader Mobile (Fix) */
    .loader-container { position: fixed !important; top: 60px !important; left: 0 !important; width: 100% !important; height: calc(100% - 60px) !important; z-index: 9999 !important; background-color: var(--bg-app); }
}

/* ============================================================
   NOVO MODAL DE CRIAÇÃO DE SIMULADO (Hub de Decisão)
   ============================================================ */

/* Grid das Opções (Cards Lado a Lado) */
.source-options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
}

/* Card de Opção (Driven ou Edital) */
.source-card {
    background-color: var(--bg-sidebar); /* Fundo levemente mais claro que o modal */
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.source-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    border-color: var(--highlight); /* Laranja no Hover */
}

/* Ícones dentro do Card */
.source-card i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    display: block;
}

/* Cores específicas para os ícones */
#opt-driven i { color: #f59e0b; } /* Laranja para PDF */
#opt-edital i { color: #10b981; } /* Verde para Texto */

.source-card h4 {
    font-size: 1.2rem;
    margin: 0 0 0.5rem 0;
    color: var(--text-main);
}

.source-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}

/* Área de Texto (Passo 2) */
#edital-text-area {
    width: 100%;
    height: 250px;
    background-color: var(--bg-app); /* Fundo bem escuro para contraste */
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    font-family: 'Courier New', monospace; /* Fonte monoespaçada para código/texto */
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

#edital-text-area:focus {
    outline: none;
    border-color: var(--highlight);
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

#edital-text-area::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

/* Ajuste do Footer do Modal para os Botões */
.modal-footer-custom {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* --- RESPONSIVIDADE MOBILE --- */
@media (max-width: 768px) {
    .source-options-grid {
        grid-template-columns: 1fr; /* Uma coluna no celular */
        gap: 1rem;
    }

    .source-card {
        flex-direction: row; /* Ícone ao lado do texto no mobile */
        text-align: left;
        padding: 1.5rem;
        align-items: flex-start;
    }

    .source-card i {
        margin-bottom: 0;
        margin-right: 1rem;
        font-size: 2rem;
    }
    
    /* Ajuste do Modal em telas pequenas */
    #new-simulado-modal .modal-content {
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* ============================================================
   MODAL DE CRIAÇÃO DE SIMULADO (HUB) - CORREÇÃO FINAL
   ============================================================ */

/* 1. O Fundo Escuro (Overlay) */
#new-simulado-modal.modal-overlay {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.95) !important; /* Fundo quase preto sólido */
    backdrop-filter: blur(5px);
    z-index: 10000 !important; /* Acima de tudo */
    display: none; /* JS controla o flex/none */
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

/* 2. A Caixa do Modal */
#new-simulado-modal .modal-content {
    background-color: #1e293b !important; /* Cor do cartão (Slate 800) */
    border: 1px solid #334155 !important;
    border-radius: 16px !important;
    width: 100%;
    max-width: 700px;
    max-height: 90vh; /* Impede que estoure a tela */
    overflow-y: auto; /* Scroll se necessário */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5) !important;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* 3. Header e Footer */
#new-simulado-modal .modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #334155;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(30, 41, 59, 0.5);
    position: sticky; /* Fixa o topo ao rolar */
    top: 0;
    z-index: 10;
}

#new-simulado-modal .modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: #f8fafc;
}

#new-simulado-modal .modal-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    padding: 0.5rem;
    cursor: pointer;
}

/* 4. Corpo e Texto */
#step-source-selection, #step-text-input {
    padding: 1.5rem;
}

#step-source-selection p {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: #cbd5e1 !important;
    font-size: 1rem;
}

/* --- GRID DAS OPÇÕES (LAYOUT DOS CARDS) --- */
.source-options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Desktop: 2 colunas */
    gap: 1rem;
}

.source-card {
    background-color: #0f172a !important; /* Fundo mais escuro */
    border: 2px solid #334155;
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    
    /* Layout Padrão (Desktop): Vertical */
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    height: 100%;
}

.source-card:hover {
    border-color: #f59e0b;
    transform: translateY(-3px);
}

/* Estilo dos textos dentro do card */
.source-card h4 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #f8fafc;
    margin: 0.5rem 0;
}

.source-card p {
    font-size: 0.85rem;
    color: #94a3b8 !important;
    line-height: 1.4;
    margin: 0 !important;
}

/* Área de Texto (Edital) */
#edital-text-area {
    width: 100%;
    height: 200px;
    background-color: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 1rem;
    color: #f8fafc;
    font-family: monospace;
    font-size: 0.9rem;
    resize: vertical;
}

/* ============================================================
   CORREÇÃO FINAL - MOBILE (POLIMENTO VISUAL)
   ============================================================ */
@media (max-width: 768px) {
    /* 1. Ajuste do Container do Modal */
    #new-simulado-modal .modal-content {
        width: 90% !important;        /* Largura segura */
        max-height: 80vh !important;  /* Altura máx de 80% da tela (deixa ver o fundo escuro em cima e embaixo) */
        margin: 0 auto;
        overflow-y: auto !important;  /* Permite rolar o conteúdo */
        display: block !important;
        border-radius: 16px !important;
    }

    /* 2. Ajuste do Header (Fixo no topo) */
    #new-simulado-modal .modal-header {
        position: sticky;
        top: 0;
        background-color: #1e293b; /* Garante que o texto não passe por trás */
        z-index: 10;
        border-bottom: 1px solid #334155;
        padding: 1rem;
    }

    /* 3. Grid vira Pilha (Com respiro no final) */
    .source-options-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
        padding: 1rem !important;
        padding-bottom: 2rem !important; /* Espaço extra no final para facilitar o scroll */
    }

    /* 4. O Card no Mobile */
    .source-card {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        padding: 1.5rem !important;
        width: 100% !important;
        min-height: auto !important;
        background-color: #0f172a !important;
    }

    /* Ícone */
    .source-card > div:first-child {
        font-size: 2.5rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .source-card i { margin: 0 !important; }

    /* Textos */
    .source-card h4 {
        font-size: 1.1rem !important;
        margin-bottom: 0.5rem !important;
    }

    .source-card p {
        font-size: 0.85rem !important;
        line-height: 1.4 !important;
    }
    
    /* Botões do Footer */
    #new-simulado-modal .modal-footer {
        flex-direction: column-reverse;
        gap: 10px;
        padding: 1rem;
    }
    
    #new-simulado-modal .modal-footer button {
        width: 100%;
        margin: 0;
        padding: 12px;
    }
}

/* --- ADIÇÕES PARA SISTEMA DE PIN/FIXAR --- */

/* Estilo do Card quando Fixado */
.comment-item.comment-pinned-bg {
    background-color: rgba(245, 158, 11, 0.08); /* Fundo sutil laranja */
    border-color: rgba(245, 158, 11, 0.3);
    position: relative;
}

/* Badge "Fixado pelo autor" ao lado do nome */
.pinned-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background-color: var(--highlight);
    color: #000;
    font-size: 0.6rem;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 8px;
    font-weight: 700;
    text-transform: uppercase;
    vertical-align: middle;
}

/* Botão de Ação (Tachinha) */
.action-btn.pin-action {
    color: var(--text-muted);
}
.action-btn.pin-action:hover {
    color: var(--highlight);
}

/* Botão de Ação quando ATIVO (Já fixado) */
.action-btn.pinned.active {
    color: var(--highlight);
    transform: rotate(45deg); /* Efeito visual de tachinha fincada */
}
