@import './aula-clave.css';

:root {
    /* ─── Light Mode Design Tokens (Aula Clave / Stitch) ─── */
    --primary-color: var(--ac-primary, #059669);       /* Emerald 600 – ProfeApp brand */
    --primary-dark-color: var(--ac-primary-hover, #047857); /* Emerald 700 */
    --primary-hover: var(--ac-primary-hover, #047857);      /* Emerald 700 */
    --accent-color: #10b981;       /* Emerald 500 – highlights */

    --bg-color: var(--ac-bg, #f8fafc);           /* Slate 50 */
    --card-bg: var(--ac-surface, #ffffff);
    --surface-2: var(--ac-surface-subtle, #f1f5f9);          /* Subtle secondary surface */
    --text-color: var(--ac-text-main, #0f172a);         /* Slate 900 */
    --text-secondary: var(--ac-text-muted, #64748b);     /* Slate 500 */
    --sidenav-bg: var(--ac-surface, #ffffff);
    --border-color: var(--ac-border, #e2e8f0);
    --table-stripe: #f8fafc;
    --table-hover: #f1f5f9;

    --card-shadow: var(--ac-shadow-sm, 0 1px 4px rgba(0,0,0,0.06));
    --card-hover-shadow: 0 8px 24px rgba(5,150,105,0.12), 0 2px 8px rgba(0,0,0,0.08);

    --radius-card: 16px;
    --radius-btn: 12px;
}

[data-theme="dark"] {
    /* ─── Dark Mode Design Tokens (Aula Clave / Stitch dark) ─── */
    --primary-color: var(--ac-primary, #10b981);      /* Emerald 500 – vibrant on dark */
    --primary-dark-color: var(--ac-primary-hover, #059669);
    --primary-hover: #34d399;
    --accent-color: #34d399;

    --bg-color: var(--ac-bg, #0a0f1a);           /* Ultra dark navy */
    --card-bg: var(--ac-surface, #111827);            /* Dark card */
    --surface-2: var(--ac-surface-subtle, #1e293b);          /* Slightly lighter surface */
    --text-color: var(--ac-text-main, #f1f5f9);         /* Slate 100 */
    --text-secondary: var(--ac-text-muted, #94a3b8);     /* Slate 400 */
    --sidenav-bg: var(--ac-surface, #111827);
    --border-color: var(--ac-border, rgba(255, 255, 255, 0.08));
    --table-stripe: rgba(255, 255, 255, 0.03);
    --table-hover: rgba(255, 255, 255, 0.07);

    --card-shadow: 0 4px 24px rgba(0,0,0,0.4);
    --card-hover-shadow: 0 8px 32px rgba(16,185,129,0.15), 0 4px 16px rgba(0,0,0,0.5);
}

body {
    font-family: 'Inter', 'Roboto', sans-serif;
    margin: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
}

header.legacy-header {
    background-color: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    box-shadow: 0 2px 12px rgba(22, 163, 74, 0.25);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

[data-theme="dark"] header.legacy-header {
    background-color: rgba(10, 15, 26, 0.85);
    box-shadow: 0 1px 0 rgba(255,255,255,0.05), 0 4px 16px rgba(0,0,0,0.4);
}

.header-content {
    display: flex;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.logo-container {
    display: flex;
    align-items: center;
}

header h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 500;
}

.logo {
    height: 32px;
    margin-right: 0.75rem;
    margin-left: 1rem;
}

main {
    padding: 1.5rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    main {
        padding: 1rem 0.5rem;
    }
}

#tools h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: #2c3e50;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

@media (max-width: 480px) {
    .tools-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

.tool-card {
    background-color: var(--card-bg);
    border-radius: var(--radius-card, 16px);
    box-shadow: var(--card-shadow);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .tool-card {
    background: rgba(255,255,255,0.03);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.tool-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--card-hover-shadow);
    border-color: rgba(34,197,94,0.2);
}

.tool-card a {
    text-decoration: none;
    color: inherit;
    display: flex;
    padding: 1.5rem;
    align-items: flex-start;
    height: 100%;
    box-sizing: border-box;
}

.icon-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1.25rem;
    flex-shrink: 0;
    font-size: 1.25rem;
}

.icon-circle.blue {
    background-color: #E3F2FD;
    color: #1976D2;
}

.icon-circle.green {
    background-color: #E8F5E9;
    color: #388E3C;
}

.icon-circle.purple {
    background-color: #F3E5F5;
    color: #7B1FA2;
}

.icon-circle.yellow {
    background-color: #FFF8E1;
    color: #FFA000;
}

.icon-circle.orange {
    background-color: #FFE5E5;
    color: #D84315;
}

.card-content {
    flex: 1;
}

.tool-card h3 {
    margin: 0 0 0.5rem 0;
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 700;
}

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

/* Botones */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: var(--radius-btn, 12px);
    text-decoration: none;
    color: white;
    background-color: var(--primary-color);
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    box-shadow: 0 4px 14px rgba(22,163,74,0.3);
    transition: all 0.25s cubic-bezier(.25, .8, .25, 1);
    letter-spacing: 0.01em;
}

.btn:hover {
    box-shadow: 0 6px 20px rgba(22,163,74,0.4);
    background-color: var(--primary-dark-color);
    transform: translateY(-1px);
}

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

.btn-outline {
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-secondary {
    background-color: #6c757d;
}

.btn-danger {
    background-color: #dc3545;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.875rem;
}

/* Menú de navegación lateral moderno */
.sidenav {
    height: 100vh;
    width: 280px;
    position: fixed;
    z-index: 100000;
    top: 0;
    left: -280px;
    background-color: var(--sidenav-bg);
    overflow-x: hidden;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: none;
    visibility: hidden;
    transform: none !important;
    border-right: 1px solid var(--border-color);
}

[data-theme="dark"] .sidenav {
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.sidenav.open {
    left: 0 !important;
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.2) !important;
    visibility: visible !important;
    display: flex !important;
}

@media (max-width: 480px) {
    .sidenav.open {
        width: 100%;
    }
}

.sidenav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidenav-overlay.active {
    display: block;
    opacity: 1;
}

/* Header del sidebar */
.sidenav-header {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
    min-height: 60px;
}

.sidenav-logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidenav-logo {
    height: 32px;
    width: 32px;
    object-fit: contain;
}

.sidenav-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
}

.sidenav-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: color 0.2s ease;
    border-radius: 4px;
}

.sidenav-close-btn:hover {
    color: var(--text-color);
    background-color: var(--bg-color);
}

.sidenav-close-btn .material-icons-outlined {
    font-size: 24px;
}

/* Navegación del sidebar */
.sidenav-nav {
    flex-grow: 1;
    padding: 1rem;
    overflow-y: auto;
}

.sidenav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.25rem;
    text-decoration: none;
    font-size: 1rem;
    color: var(--text-color);
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.sidenav-link .material-icons-outlined {
    margin-right: 1rem;
    font-size: 24px;
    color: inherit;
}

.sidenav-link:hover {
    background-color: var(--bg-color);
    color: var(--primary-color);
}

.sidenav-link.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(22,163,74,0.3);
}

[data-theme="dark"] .sidenav-link.active {
    background-color: var(--primary-color);
    color: #0a0f1a;
    font-weight: 700;
}

/* Footer del sidebar */
.sidenav-footer {
    padding: 1rem;
    border-top: 1px solid #e5e7eb;
}

.sidenav-user-info {
    color: var(--dark-color);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.sidenav-logout {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    text-decoration: none;
    font-size: 1rem;
    color: #dc2626;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.sidenav-logout .material-icons-outlined {
    margin-right: 1rem;
    font-size: 24px;
}

.sidenav-logout:hover {
    background-color: #fef2f2;
    color: #b91c1c;
}

#menu-icon {
    font-size: 24px;
    cursor: pointer;
    color: white;
}

/* --- Estilos del Acordeón --- */
.accordion-item {
    margin-bottom: 0.5rem;
}

.accordion-header {
    background-color: var(--card-bg);
    color: var(--primary-dark-color);
    cursor: pointer;
    padding: 1rem;
    width: 100%;
    border: none;
    border-radius: 8px;
    text-align: left;
    outline: none;
    font-size: 1.1rem;
    font-weight: 700;
    transition: background-color 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.accordion-header:hover,
.accordion-header.active {
    background-color: var(--bg-color);
}

.accordion-header .icon {
    font-size: 1.5rem;
    font-weight: bold;
    transition: transform 0.3s ease-in-out;
}

.accordion-header.active .icon {
    transform: rotate(90deg);
}

.accordion-panel {
    display: grid;
    grid-template-rows: 0fr;
    overflow: hidden;
    transition: grid-template-rows 0.3s ease-in-out;
    background-color: var(--card-bg);
    border-radius: 0 0 8px 8px;
}

.accordion-panel>* {
    min-height: 0;
}

.accordion-header.active+.accordion-panel {
    grid-template-rows: 1fr;
}

.accordion-panel .card {
    border-top: 1px solid #eee;
    border-radius: 0;
    box-shadow: none;
    margin-top: -1px;
}

/* --- Estilos del Drawer Derecho (Side Panel) --- */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99999;
    /* Ultra high */
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.drawer-overlay.active {
    display: block;
    opacity: 1;
}

.right-drawer {
    position: fixed;
    top: 0;
    right: -450px;
    width: 450px;
    height: 100vh;
    background-color: var(--card-bg);
    z-index: 100000;
    /* Higher than overlay */
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    visibility: hidden;
    transform: none !important;
}

.right-drawer.open {
    right: 0 !important;
    visibility: visible !important;
    display: flex !important;
}

@media (max-width: 600px) {
    .right-drawer {
        width: 100%;
    }
}

.drawer-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-color);
}

.drawer-header h3 {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.25rem;
}

.drawer-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.drawer-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    background-color: var(--bg-color);
}

/* Backward compatibility or overlay-based modal styles (if needed) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: none;
    /* Changed to none by default */
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.modal-content {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    width: 95%;
    max-width: 700px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .modal-content {
        padding: 1.25rem;
        margin: 10px;
    }
}

.close-modal-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 2rem;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}

.modal-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
}

@media (max-width: 600px) {
    .modal-body {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

.student-list-container {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 1rem;
}

.student-list {
    list-style-type: none;
    padding: 0;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
}

.student-list li {
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s;
}

.student-list li:last-child {
    border-bottom: none;
}

.student-list li:hover {
    background-color: var(--bg-color);
}

.student-list li.selected {
    background-color: var(--primary-color);
    color: white;
    font-weight: bold;
}

.modal-footer {
    margin-top: 1.5rem;
    text-align: right;
}

.modal-footer .btn {
    margin-left: 0.5rem;
}

/* --- Estilos para Reportes --- */

/* Contenedor General y Tarjetas */
.card {
    background-color: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h2,
.card h3,
.card h4 {
    margin-top: 0;
    color: var(--primary-dark-color);
}

.filtros-container {
    display: flex;
    gap: 2rem;
    align-items: center;
    flex-wrap: wrap;
}

.filtro-item {
    display: flex;
    flex-direction: column;
}

.filtro-item label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.filtro-item select {
    padding: 0.5rem;
    border-radius: 4px;
    border: 1px solid #ccc;
    min-width: 250px;
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.mt-1 {
    margin-top: 1rem;
}

#absentee-list-container ul {
    list-style-type: disc;
    padding-left: 20px;
}

.report-header h3 {
    color: var(--dark-color);
    margin: 0;
}

/* Sistema de Pestañas */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #ddd;
}

.tab-button {
    padding: 1rem 1.5rem;
    cursor: pointer;
    border: none;
    background-color: transparent;
    font-size: 1.1rem;
    font-weight: 700;
    color: #777;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* --- Vista: Reporte por Alumno --- */

.summary-card {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1.5rem;
    background-color: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

.summary-card .student-photo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary-color);
}

.summary-card .student-info h3 {
    margin: 0 0 0.5rem 0;
}

.summary-card .student-metrics {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.summary-card .metric {
    font-size: 1rem;
    font-weight: 700;
}

.summary-card .metric .value {
    color: var(--primary-dark-color);
}

.summary-card .status {
    font-size: 1rem;
    font-weight: 700;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    color: white;
}

.status.alto {
    background-color: #4CAF50;
}

/* Verde */
.status.regular {
    background-color: #FFC107;
}

/* Ambar */
.status.apoyo {
    background-color: #F44336;
}

/* Rojo */


/* --- Vista: Reporte por Curso --- */

.stats-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.stat-card .stat-title {
    font-size: 1rem;
    color: #666;
    margin: 0 0 0.5rem 0;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-dark-color);
}

.rankings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.rankings-grid ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.rankings-grid li {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid #eee;
}

.rankings-grid li:last-child {
    border-bottom: none;
}

.rankings-grid .student-name {
    font-weight: 500;
}

.rankings-grid .student-average {
    font-weight: 700;
    color: var(--primary-dark-color);
}


/* --- Componentes Comunes de Reportes --- */

.summaries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

#asistencia-summary ul,
#distribucion-calificaciones-summary ul,
#rendimiento-actividades-summary ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#asistencia-summary li,
#distribucion-calificaciones-summary li,
#rendimiento-actividades-summary li {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
}

#asistencia-summary li .value,
#distribucion-calificaciones-summary li .value {
    font-weight: 700;
    color: var(--primary-dark-color);
}

#rendimiento-actividades-summary .rendimiento-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #eee;
}

#rendimiento-actividades-summary .rendimiento-info {
    display: flex;
    flex-direction: column;
}

#rendimiento-actividades-summary .rendimiento-info small {
    color: #666;
    font-size: 0.85rem;
}

#rendimiento-actividades-summary .value {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary-dark-color);
}


/* Tabla Mejorada */
#tabla-calificaciones-container table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

#tabla-calificaciones-container th,
#tabla-calificaciones-container td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

#tabla-calificaciones-container thead th {
    background-color: var(--bg-color);
    font-weight: 700;
    color: var(--primary-dark-color);
}

#tabla-calificaciones-container tbody tr:nth-child(even) {
    background-color: var(--table-stripe);
}

#tabla-calificaciones-container tbody tr:hover {
    background-color: var(--table-hover);
}

/* Iconos (requiere FontAwesome o similar) */
.btn .fas {
    margin-right: 0.5rem;
}

.card h4 .fas {
    margin-right: 0.75rem;
    color: var(--accent-color);
}


/* --- Responsividad --- */
@media (max-width: 992px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }

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

    .filtros-container {
        flex-direction: column;
        align-items: stretch;
    }

    .filtro-item select {
        min-width: 100%;
    }
}

@media (max-width: 768px) {
    .summary-card {
        flex-direction: column;
        text-align: center;
    }

    .summary-card .student-metrics {
        justify-content: center;
    }

    .report-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
}

/* Course Card Small */
.curso-card-sm {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
}

.curso-card-sm:hover {
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
}