/* --- style.css --- */
:root {
    --bg-color: #f4f7fa;
    --sidebar-bg: #1f2937;
    --main-bg: #ffffff;
    --text-color: #4b5563;
    --heading-color: #111827;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #6b7280;
    --secondary-hover: #4b5563;
    --border-color: #e5e7eb;
    --success-bg: #dcfce7;
    --success-text: #166534;
    --success-color: #166534;
    --success-hover: #088108;
    --error-bg: #fee2e2;
    --error-text: #991b1b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}
.container-xxl {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    align-content: left;
    display: flex;
}

/* --- Layout Principal --- */
.container {
    display: flex;
    min-height: 100vh;
    align-content: left;
}

.sidebar {
    align-content: left;
    width: 280px;
    background-color: var(--sidebar-bg);
    color: white;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.sidebar-header h2 {
    text-align: center;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 2rem;
}

.sidebar-nav a {
    display: block;
    color: #d1d5db;
    text-decoration: none;
    padding: 0.8rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
    background-color: var(--primary-color);
    color: white;
}

.main-content {
    flex-grow: 1;
    padding: 2rem;
}

.main-header {
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.main-header h1 {
    color: var(--heading-color);
    font-size: 2rem;
    font-weight: 600;
}

/* --- Componentes --- */
.card {
    background-color: var(--main-bg);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.btn {
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.2s ease;
}

.btn-primary { background-color: var(--primary-color); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-secondary { background-color: var(--secondary-color); color: white; }
.btn-secondary:hover { background-color: var(--secondary-hover); }
.btn-success { background-color: var(--success-color); color: white; }
.btn-success:hover { background-color: var(--success-hover); }

/* --- Dashboard --- */
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.dashboard .card h3 { color: var(--heading-color); margin-bottom: 1rem; font-weight: 600; }
.dashboard .card .stat { font-size: 3rem; font-weight: 700; color: var(--primary-color); }
.dashboard .card .stat-info { font-size: 1.2rem; }
.quick-actions a { margin-top: 0.5rem; }

/* --- Formulários --- */
.form-container {
    max-width: 800px;
    background-color: var(--main-bg);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.5rem; color: var(--heading-color); }
.form-group input[type="text"], .form-group select, .form-group input[type="file"] {
    width: 100%;
    padding: 0.7rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
}

.form-actions { margin-top: 2rem; text-align: right; }

/* --- Tabelas de Gabarito --- */
.gabarito-table, .gabarito-table-result {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
}
.gabarito-table th, .gabarito-table td,
.gabarito-table-result th, .gabarito-table-result td {
    padding: 0.8rem;
    border: 1px solid var(--border-color);
}
.gabarito-table th, .gabarito-table-result th {
    background-color: #f9fafb;
    font-weight: 600;
}
.gabarito-table input[type="radio"] { transform: scale(1.4); cursor: pointer; }

/* --- Resultados --- */
.resultado-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.resultado-summary .stat { font-size: 3.5rem; }

.gabarito-table-result tr.acerto { background-color: var(--success-bg); }
.gabarito-table-result tr.erro { background-color: var(--error-bg); }
.status-acerto { color: var(--success-text); font-weight: 600; }
.status-erro { color: var(--error-text); font-weight: 600; }

/* --- Alertas --- */
.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 6px;
    border: 1px solid transparent;
}
.alert-success { background-color: var(--success-bg); color: var(--success-text); border-color: #a7f3d0; }
.alert-danger { background-color: var(--error-bg); color: var(--error-text); border-color: #fecaca; }

/* --- Estilos para a Tabela de Dados e Botão Pequeno --- */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th, .data-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: #f9fafb;
    font-weight: 600;
}

.data-table tbody tr:hover {
    background-color: #f9fafb;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
}

/* --- Estilos para o Modal --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #fff;
    margin: 10% auto;
    padding: 25px;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 500px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    position: relative;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
    position: absolute;
    top: 10px;
    right: 15px;
}

.close-button:hover,
.close-button:focus {
    color: #333;
    text-decoration: none;
    cursor: pointer;
}

#modalProvaNome {
    margin-bottom: 1.5rem;
    color: var(--heading-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.gabarito-modal-body {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
}

.gabarito-modal-item {
    background-color: #f9fafb;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
}

.gabarito-modal-item .questao {
    font-weight: 600;
    color: var(--heading-color);
}

.gabarito-modal-item .resposta {
    font-size: 1.2rem;
    color: var(--primary-color);
    font-weight: 700;
}

/* --- Estilos do Gerador --- */
.gerador-container { display: flex; flex-wrap: wrap; gap: 2rem; }
.gerador-controles { flex: 1; min-width: 300px; }
.gerador-preview { flex: 2; min-width: 400px; background-color: #e2e8f0; padding: 2rem; border-radius: 8px; display: flex; justify-content: center; }
.gerador-acoes { display: flex; gap: 1rem; }

/* Folha de resposta (gerador) */
#folhaDeResposta { background-color: white; width: 210mm; min-height: 297mm; padding: 15mm; box-shadow: 0 5px 15px rgba(0,0,0,0.1); color: #000; }
.cabecalho-gabarito { text-align: center; border-bottom: 2px solid #ff0000; padding-bottom: 1rem; margin-bottom: 1rem; }
#previewTitulo { font-size: 1.5rem; font-weight: 700; color: #ff0000; }
.info-aluno { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 1rem; margin-bottom: 1.5rem; font-size: 0.9rem; }
.info-aluno span:nth-child(1), .info-aluno span:nth-child(4) { grid-column: 1 / -1; }
.subtitulo-gabarito { text-align: center; padding: 10px; background-color: #ffffff; border: 1px solid #ff0000; border-bottom: none; font-weight: 600; color: #ff0000; margin-top: 20px; }
.bloco-respostas { border: 1px solid #d1d5db; width: 280px; margin-top: 10px; margin-left: auto; margin-right: auto; }
.bloco-header { display: flex; justify-content: center; align-items: center; padding: 5px 8px; }
.bloco-header h3 { color: rgb(0, 0, 0); margin: 0; font-size: 1rem; font-weight: 600; }
.bloco-superior, .bloco-inferior { display: flex; justify-content: space-between; align-items: center; background-color: white; padding: 5px 8px; }
.marker { width: 15px; height: 15px; background-color: #000; flex-shrink: 0; }
#questoesContainer { padding: 5px 15px; background-color: white; }
.questao-linha { display: flex; align-items: center; padding: 4px 0; border-bottom: none; }
.questao-numero { font-weight: 600; margin-right: 10px; width: 30px; }
.alternativas { display: flex; gap: 10px; }
.alternativa { display: flex; align-items: center; gap: 5px; }
.circulo { width: 20px; height: 20px; border: 1px solid #ff0000; border-radius: 50%; }
.preview-imagem-container img { max-width: 100%; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
#folhaDeResposta { position: relative; }
.page-marker { position: absolute; width: 15px; height: 15px; background-color: #000; }
.page-marker-tl { top: 5mm; left: 5mm; }
.page-marker-tr { top: 5mm; right: 5mm; }
.page-marker-bl { bottom: 5mm; left: 5mm; }
.page-marker-br { bottom: 5mm; right: 5mm; }

/* --- NOVO: Estilo da "Capa" do GABARITO (igual ao modelo Word) --- */
.capa-gabarito-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

/* cada bloco contém até 8 questões (uma grade com 5 linhas A..E) */
.capa-gabarito-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.capa-gabarito-table thead th {
    background: #f9fafb;
    border: 1px solid var(--border-color);
    padding: 6px;
    font-weight: 700;
    text-align: center;
}

.capa-gabarito-table td {
    border: 1px solid var(--border-color);
    text-align: center;
    padding: 8px 4px;
    font-weight: 500;
}

.capa-gabarito-table td.ok {
    color: #dc2626;          /* vermelho suave */
    font-weight: 800;        /* destaca a alternativa correta */
}

.capa-gabarito-table td.dim {
    color: #9ca3af;          /* cinza para as alternativas não corretas */
}

/* impressão limpa para colar no Word */
@media print {
    .sidebar, .main-header, .form-actions { display: none !important; }
    .main-content { padding: 0; }
    .card { box-shadow: none; padding: 0; }
}


/* ========================================
   ESTILOS PARA A PÁGINA DE RESULTADO
   ======================================== */

.results-container h2 {
    color: #333;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.results-container h3 {
    color: #444;
    margin-top: 30px;
    margin-bottom: 15px;
}

/* --- Sumário (Grid de 3 Colunas) --- */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.summary-card {
    background-color: #fdfdfd;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
}

.summary-card h4 {
    margin: 0 0 10px 0;
    font-size: 1.1rem;
    color: #555;
    font-weight: 600;
}

.summary-card .score-lg {
    font-size: 2.2rem;
    font-weight: 700;
    color: #0056b3; /* Azul primário */
}

/* --- Tabela de Respostas --- */
.table-wrapper {
    overflow-x: auto; /* Garante rolagem horizontal em telas pequenas */
    border: 1px solid #ddd;
    border-radius: 8px;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.results-table th,
.results-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #ddd;
    text-align: left;
    line-height: 1.4;
}

.results-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #333;
}

.results-table tbody tr:last-child td {
    border-bottom: none;
}

.results-table tbody tr:nth-child(even) {
    background-color: #fcfcfc;
}

/* Status (Acerto/Erro) na Tabela */
.results-table tr.acerto {
    background-color: #f0fff4; /* Fundo verde claro */
}
.results-table tr.erro {
    background-color: #fff0f1; /* Fundo rosa claro */
}

.status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
}
.status-badge.acerto {
    background-color: #28a745; /* Verde */
}
.status-badge.erro {
    background-color: #dc3545; /* Vermelho */
}

/* --- Imagem de Debug --- */
.debug-image-wrapper {
    border: 1px solid #ccc;
    overflow: auto;
    max-height: 800px; /* Limita altura máxima */
    max-width: 100%;
    border-radius: 8px;
    background-color: #f9f9f9;
}

.debug-image-wrapper img {
    max-width: 100%;
    height: auto;
    display: block;
}