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

:root {
    --navy: #1a2744;
    --navy-light: #2c3e6b;
    --blue: #3b6cb4;
    --blue-light: #5a8fd4;
    --blue-pale: #e8f0fe;
    --green: #2e7d32;
    --green-light: #e8f5e9;
    --red: #c62828;
    --red-light: #ffebee;
    --orange: #ef6c00;
    --orange-light: #fff3e0;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-400: #bdbdbd;
    --gray-600: #757575;
    --gray-800: #424242;
    --gray-900: #212121;
    --white: #ffffff;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --transition: 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* ===== Navbar ===== */
.navbar {
    background: var(--navy);
    color: var(--white);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.nav-brand a {
    color: var(--white);
    font-size: 1.2rem;
    font-weight: 700;
    text-decoration: none;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    cursor: pointer;
    margin-left: auto;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;
}

.nav-link {
    color: rgba(255,255,255,0.85);
    font-size: 0.9rem;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius);
    transition: background var(--transition);
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
    text-decoration: none;
    color: var(--white);
}

.nav-user {
    color: rgba(255,255,255,0.7);
    font-size: 0.85rem;
}

/* ===== Nav Dropdown (Admin) ===== */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255,255,255,0.85);
    font-size: 0.9rem;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius);
    transition: background var(--transition);
    font-family: inherit;
}

.nav-dropdown-toggle:hover {
    background: rgba(255,255,255,0.1);
    color: var(--white);
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    z-index: 200;
    overflow: hidden;
}

.nav-dropdown-menu.open {
    display: block;
}

.nav-dropdown-item {
    display: block;
    padding: 0.6rem 1rem;
    color: var(--gray-900);
    font-size: 0.9rem;
    text-decoration: none;
    transition: background var(--transition);
}

.nav-dropdown-item:hover {
    background: var(--gray-100);
    text-decoration: none;
    color: var(--navy);
}

/* ===== Container ===== */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), transform 0.1s;
    min-height: 44px;
    min-width: 44px;
}

.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--blue); color: var(--white); }
.btn-primary:hover { background: var(--blue-light); }

.btn-success { background: var(--green); color: var(--white); }
.btn-danger { background: var(--red); color: var(--white); }
.btn-warning { background: var(--orange); color: var(--white); }

.btn-outline {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.4);
    color: var(--white);
}
.btn-outline:hover { background: rgba(255,255,255,0.1); }

.btn-sm { padding: 0.3rem 0.8rem; font-size: 0.85rem; min-height: 36px; }
.btn-block { width: 100%; }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.3rem;
    color: var(--gray-800);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.95rem;
    background: var(--white);
    transition: border-color var(--transition);
    min-height: 44px;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(59,108,180,0.15);
}

textarea { resize: vertical; min-height: 80px; }

/* ===== Login ===== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}

.login-title {
    text-align: center;
    color: var(--navy);
    font-size: 1.8rem;
    margin-bottom: 0.3rem;
}

.login-subtitle {
    text-align: center;
    color: var(--gray-600);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.tab-group {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--gray-200);
}

.tab-btn {
    flex: 1;
    padding: 0.6rem;
    background: none;
    border: none;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color var(--transition), border-color var(--transition);
}

.tab-btn.active {
    color: var(--blue);
    border-bottom-color: var(--blue);
}

/* ===== Messages ===== */
.msg {
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-top: 1rem;
}

.msg-erro { background: var(--red-light); color: var(--red); }
.msg-sucesso { background: var(--green-light); color: var(--green); }
.msg-aviso { background: var(--orange-light); color: var(--orange); }

/* ===== Cards ===== */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--gray-200);
}

/* ===== Progress Bar ===== */
.progress-bar-container {
    background: var(--gray-200);
    border-radius: 20px;
    height: 24px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue), var(--blue-light));
    border-radius: 20px;
    transition: width 0.4s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 2rem;
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--gray-600);
}

/* ===== Filter Panel ===== */
.filter-panel {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    margin-bottom: 1rem;
}

.filter-panel h3 {
    font-size: 1rem;
    margin-bottom: 0.8rem;
    color: var(--navy);
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.8rem;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.8rem;
}

/* ===== Question Card ===== */
.questao-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.questao-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--gray-600);
}

.questao-enunciado {
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 1.2rem;
    white-space: pre-wrap;
}

.alternativas {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.alternativa-btn {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    padding: 0.8rem 1rem;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    cursor: pointer;
    font-size: 0.95rem;
    text-align: left;
    transition: border-color var(--transition), background var(--transition);
    min-height: 48px;
    width: 100%;
}

.alternativa-btn:hover:not(:disabled) {
    border-color: var(--blue);
    background: var(--blue-pale);
}

.alternativa-btn .letra {
    font-weight: 700;
    color: var(--navy);
    min-width: 1.5rem;
}

.alternativa-btn.correta {
    border-color: var(--green);
    background: var(--green-light);
}

.alternativa-btn.incorreta {
    border-color: var(--red);
    background: var(--red-light);
}

.alternativa-btn.gabarito {
    border-color: var(--green);
    background: var(--green-light);
}

.alternativa-btn:disabled {
    cursor: default;
    opacity: 0.85;
}

/* Feedback */
.feedback {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: var(--radius);
    display: none;
}

.feedback.correto {
    background: var(--green-light);
    border-left: 4px solid var(--green);
    display: block;
}

.feedback.incorreto {
    background: var(--red-light);
    border-left: 4px solid var(--red);
    display: block;
}

.feedback-titulo {
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.feedback-referencia {
    font-size: 0.9rem;
    color: var(--gray-800);
    margin-top: 0.5rem;
    font-style: italic;
    white-space: pre-wrap;
}

/* ===== Status Badges ===== */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-ativa { background: var(--green-light); color: var(--green); }
.badge-suspensa { background: var(--orange-light); color: var(--orange); }
.badge-desativada { background: var(--gray-200); color: var(--gray-600); }
.badge-divergencia { background: var(--red-light); color: var(--red); }
.badge-contexto_insuficiente { background: #fff8e1; color: #f57f17; }

/* ===== Admin Table ===== */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    padding: 0.7rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--navy);
    position: sticky;
    top: 0;
}

tr:hover { background: var(--gray-50); }

/* Checkbox */
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ===== Batch Actions Bar ===== */
.batch-bar {
    background: var(--navy);
    color: var(--white);
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    display: none;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.batch-bar.active { display: flex; }

.batch-bar select {
    min-height: 36px;
    border-radius: var(--radius);
}

/* ===== Upload Area ===== */
.upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}

.upload-area:hover {
    border-color: var(--blue);
    background: var(--blue-pale);
}

.upload-area.dragover {
    border-color: var(--blue);
    background: var(--blue-pale);
}

.upload-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.upload-text { color: var(--gray-600); }

/* Result summary */
.result-summary {
    margin-top: 1rem;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-200);
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.pagination .btn {
    min-width: 40px;
}

.pagination-info {
    font-size: 0.85rem;
    color: var(--gray-600);
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 200;
    padding: 1rem;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 { font-size: 1.2rem; color: var(--navy); }

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-600);
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-600);
}

.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; }

/* ===== Loading ===== */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--gray-600);
}

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--gray-300);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Responsive — Tablet (≤1024px) ===== */
@media (max-width: 1024px) {
    .container { padding: 1rem 0.8rem; }
    .filter-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* ===== Responsive — Mobile (≤768px) ===== */
@media (max-width: 768px) {
    .nav-toggle { display: block; }

    .nav-links {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: var(--navy);
        flex-direction: column;
        padding: 1rem;
        gap: 0.5rem;
        box-shadow: var(--shadow);
    }

    .nav-links.active { display: flex; }

    /* Dropdown mobile: exibe itens inline no menu expandido */
    .nav-dropdown {
        width: 100%;
    }

    .nav-dropdown-toggle {
        width: 100%;
        text-align: left;
        padding: 0.6rem 1rem;
    }

    .nav-dropdown-menu {
        position: static;
        box-shadow: none;
        background: rgba(255,255,255,0.08);
        border-radius: 0;
        display: block;
    }

    .nav-dropdown-item {
        color: rgba(255,255,255,0.8);
        padding: 0.5rem 1.5rem;
        background: none;
    }

    .nav-dropdown-item:hover {
        background: rgba(255,255,255,0.1);
        color: var(--white);
    }

    .container { padding: 1rem 0.5rem; }

    .filter-grid { grid-template-columns: 1fr; }

    .questao-card { padding: 1rem; }

    .alternativa-btn {
        padding: 1rem;
        font-size: 1rem;
    }

    .batch-bar {
        flex-wrap: wrap;
    }

    table { font-size: 0.8rem; }
    th, td { padding: 0.5rem; }

    .modal { padding: 1rem; }

    .login-card { padding: 1.5rem; }
}

/* ===== Report Button hover ===== */
.btn-warning:hover {
    background: #e65100;
}

/* ===== Print Protection ===== */
@media print {
  body {
    display: none !important;
  }
}
