@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #0f172a;
    --secondary-color: #1e293b;
    --accent-color: #3b82f6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #334155;
    --border-radius: 16px;
}

body {
    font-family: 'Outfit', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.container {
    max-width: 1000px;
    width: 100%;
}

.header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 30px;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.header h1 { margin: 0; font-size: 1.8em; letter-spacing: 1px; }
.header p { margin: 5px 0 0; opacity: 0.9; }

.controls {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 20px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.class-group {
    flex: 1 1 360px;
}

.student-group {
    flex: 1 1 360px;
}

select {
    width: 100%;
    padding: 12px 40px 12px 16px;
    border-radius: 8px;
    border: 1.5px solid #e2e8f0;
    font-size: 0.95em;
    font-family: inherit;
    color: var(--text-color);
    background-color: #f8fafc;
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' 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 16px center;
    background-size: 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

select:hover {
    border-color: #cbd5e1;
    background-color: #f1f5f9;
}

select:focus {
    border-color: var(--accent-color);
    background-color: #ffffff;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.student-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.info-group {
    display: flex;
    flex-direction: column;
}

.info-label {
    font-size: 0.75em;
    color: #64748b;
    text-transform: uppercase;
    font-weight: bold;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 1.15em;
    font-weight: 600;
    color: var(--primary-color);
}

.status-badge-inactive {
    background-color: #f59e0b;
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8em;
    font-weight: 500;
    margin-left: 8px;
    vertical-align: middle;
}

.freq-green { color: #10b981 !important; }
.freq-yellow { color: #f59e0b !important; }
.freq-red { color: #ef4444 !important; }

.inactive-overlay {
    color: #64748b;
    font-style: italic;
    opacity: 0.7;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 10px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

.stat-item {
    text-align: center;
    padding: 12px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.stat-label { font-size: 0.75em; color: #64748b; display: block; font-weight: 500; }
.stat-value { font-size: 1.25em; font-weight: bold; color: var(--accent-color); }

.table-container {
    width: 100%;
    overflow-x: auto;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    margin-bottom: 20px;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--card-bg);
}

th, td {
    padding: 16px 20px;
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
}

th {
    background-color: var(--secondary-color);
    color: white;
    font-weight: 600;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.subject-td {
    text-align: left;
    font-weight: 500;
    width: 40%;
}

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

tr:hover { background-color: #f8fafc; }

.mencao-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9em;
}

.status-aprovado { color: var(--success-color); font-weight: 600; }
.status-reprovado { color: var(--danger-color); font-weight: 600; }
.status-neutro { color: #64748b; font-weight: 500; }

.grade-low {
    color: var(--danger-color) !important;
    font-weight: bold;
}

.notes-container {
    background-color: #eff6ff;
    border: 1px solid #bfdbfe;
    border-left: 4px solid var(--accent-color);
    padding: 16px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}

#closing-type {
    display: inline-block;
    background-color: var(--secondary-color);
    color: white;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.8em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.preview-note {
    margin: 0;
    font-size: 0.85em;
    font-weight: bold;
    color: var(--accent-color);
    line-height: 1.4;
}

.footer {
    margin-top: 40px;
    text-align: center;
    color: #64748b;
    font-size: 0.9em;
    padding-bottom: 40px;
}

/* Navegação de Estudantes */
.student-navigation {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.btn-nav {
    background-color: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    flex-shrink: 0;
}

.btn-nav:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
    color: var(--primary-color);
}

.btn-nav:active {
    transform: scale(0.95);
}

.btn-nav:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    background-color: #f8fafc;
    border-color: #e2e8f0;
    color: #cbd5e1;
}

/* Frequência Sub-cabeçalho */
.freq-sub {
    font-size: 0.75em;
    font-weight: 500;
    opacity: 0.85;
    color: #cbd5e1;
    display: block;
    margin-top: 4px;
}

@media print {
    body { background: white; padding: 0; }
    .controls, #student-select, .btn-nav { display: none; }
    .container { max-width: 100%; }
    .header, .student-card, table { box-shadow: none; border: 1px solid #eee; }
    .header { background: white; color: black; border-bottom: 2px solid black; }
}

/* Botão do Relatório nos Controles */
.action-group {
    flex: 0 0 auto;
}

.btn-report {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 0.95em;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.25);
    transition: all 0.2s ease-in-out;
    height: 45px;
}

.btn-report:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.35);
    transform: translateY(-1px);
}

.btn-report:active {
    transform: translateY(0);
}

/* Modal Overlay & Container */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.modal-container {
    background: #ffffff;
    width: 100%;
    max-width: 950px;
    max-height: 90vh;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalFadeIn 0.25s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    padding: 20px 24px;
    background: var(--primary-color);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.35em;
    font-weight: 700;
}

.modal-subtitle {
    margin: 4px 0 0 0;
    font-size: 0.85em;
    opacity: 0.8;
}

.btn-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.8em;
    line-height: 1;
    cursor: pointer;
    opacity: 0.75;
    transition: opacity 0.2s;
}

.btn-close:hover {
    opacity: 1;
}

.modal-filters {
    padding: 16px 24px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 180px;
}

.filter-item label {
    font-size: 0.75em;
    font-weight: bold;
    color: #64748b;
    text-transform: uppercase;
}

.filter-item select {
    padding: 8px 32px 8px 12px;
    font-size: 0.9em;
}

.report-stats {
    display: flex;
    gap: 16px;
    padding: 16px 24px;
    background: #ffffff;
}

.report-stat-card {
    flex: 1;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.report-stat-num {
    font-size: 1.5em;
    font-weight: 700;
    color: #dc2626;
}

.report-stat-lbl {
    font-size: 0.75em;
    font-weight: 600;
    color: #991b1b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-body-table {
    flex: 1;
    overflow-y: auto;
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
}

.modal-footer {
    padding: 16px 24px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 0.9em;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: #ffffff;
    color: var(--text-color);
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 0.9em;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

/* Botão do Relatório por Disciplina */
.btn-report-subject {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 0.95em;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(139, 92, 246, 0.25);
    transition: all 0.2s ease-in-out;
    height: 45px;
}

.btn-report-subject:hover {
    background: linear-gradient(135deg, #7c3aed, #5b21b6);
    box-shadow: 0 4px 8px rgba(139, 92, 246, 0.35);
    transform: translateY(-1px);
}

.btn-report-subject:active {
    transform: translateY(0);
}

/* Badge de Alunos Afetados por Disciplina */
.badge-count {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 0.85em;
}

.student-list-pill {
    font-size: 0.8em;
    color: #475569;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
    margin: 2px;
}

/* Botão do Compilado por Turma */
.btn-report-class {
    background: linear-gradient(135deg, #059669, #047857);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 0.95em;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(5, 150, 105, 0.25);
    transition: all 0.2s ease-in-out;
    height: 45px;
}

.btn-report-class:hover {
    background: linear-gradient(135deg, #047857, #065f46);
    box-shadow: 0 4px 8px rgba(5, 150, 105, 0.35);
    transform: translateY(-1px);
}

/* Botão do Relatório por Série */
.btn-report-grade {
    background: linear-gradient(135deg, #d97706, #b45309);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 0.95em;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(217, 119, 6, 0.25);
    transition: all 0.2s ease-in-out;
    height: 45px;
}

.btn-report-grade:hover {
    background: linear-gradient(135deg, #b45309, #92400e);
    box-shadow: 0 4px 8px rgba(217, 119, 6, 0.35);
    transform: translateY(-1px);
}

.group-header-row td {
    background: #f1f5f9 !important;
    color: var(--primary-color) !important;
    font-weight: 700 !important;
    font-size: 1.05em !important;
    text-align: left !important;
    padding: 12px 20px !important;
    border-bottom: 2px solid #cbd5e1 !important;
}

.subject-red-tag {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.85em;
    display: inline-block;
    margin: 2px;
    font-weight: 500;
}

/* Regra de impressão para os modais */
@media print {
    body * {
        visibility: hidden;
    }
    #report-modal, #report-modal *,
    #subject-report-modal, #subject-report-modal *,
    #class-compiled-modal, #class-compiled-modal *,
    #grade-report-modal, #grade-report-modal * {
        visibility: visible;
    }
    #report-modal, #subject-report-modal, #class-compiled-modal, #grade-report-modal {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: auto;
        background: white;
        padding: 0;
    }
    .modal-container {
        box-shadow: none;
        max-width: 100%;
        max-height: none;
        border-radius: 0;
    }
    .btn-close, .modal-filters, .modal-footer {
        display: none !important;
    }
}
