/* Variables CSS */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-color: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

/* Reset y base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 24px 32px;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 600;
}

.header h1.logo {
    cursor: pointer;
    transition: opacity 0.2s;
}

.header h1.logo:hover {
    opacity: 0.85;
}

.header h1 i {
    margin-right: 12px;
}

/* Navegación */
.main-nav {
    display: flex;
    gap: 8px;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.nav-btn.active {
    background: white;
    color: var(--primary-color);
}

/* Secciones */
.section {
    display: none;
}

.section.active {
    display: block;
}

.section-header {
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.section-header p {
    color: var(--text-secondary);
}

/* Timeline de centros por año */
.timeline-container {
    margin-bottom: 24px;
    overflow-x: auto;
    padding: 20px 0;
}

.timeline {
    display: flex;
    align-items: flex-start;
    gap: 0;
    min-width: max-content;
    padding: 0 10px;
}

.timeline-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
    position: relative;
}

.timeline-logos {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-bottom: 12px;
    min-height: 44px;
}

.timeline-logo {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: 8px;
    background: white;
    padding: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.timeline-line {
    width: 100%;
    height: 3px;
    background: linear-gradient(to right, var(--primary-color), var(--primary-dark));
    margin-bottom: 8px;
}

.timeline-item:first-child .timeline-line {
    background: var(--primary-dark);
}

.timeline-year {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-color);
    padding: 4px 12px;
    border-radius: 20px;
}

.timeline-situacion-row {
    margin-top: 6px;
    min-height: 22px;
}

.timeline-situacion {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 12px;
    display: inline-block;
}

.situacion-fp {
    background: #fef3c7;
    color: #d97706;
    border: 1px solid #fcd34d;
}

.situacion-fc {
    background: #d1fae5;
    color: #059669;
    border: 1px solid #6ee7b7;
}

.situacion-ed {
    background: #e0e7ff;
    color: #4338ca;
    border: 1px solid #a5b4fc;
}

.situacion-dd {
    background: #fce7f3;
    color: #be185d;
    border: 1px solid #f9a8d4;
}

.situacion-co {
    background: #f3e8ff;
    color: #7c3aed;
    border: 1px solid #c4b5fd;
}

/* Cargo info en vista de cursos */
.cargo-info {
    display: none;
    margin-bottom: 16px;
    text-align: center;
}

.cargo-badge {
    display: inline-block;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 8px 20px;
    border-radius: 25px;
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    color: #334155;
    border: 1px solid #cbd5e1;
}

/* Grid de Centros */
.centers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.center-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: all 0.2s;
    cursor: pointer;
}

.center-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.center-card .center-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: var(--radius);
    background: var(--bg-color);
}

.center-image-container {
    position: relative;
    width: 100%;
    height: 150px;
    margin-bottom: 16px;
    border-radius: var(--radius);
    overflow: hidden;
}

.center-image-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    gap: 8px;
}

.center-image-placeholder i {
    font-size: 2rem;
}

.center-image-placeholder span {
    font-size: 0.9rem;
    text-align: center;
    padding: 0 10px;
}

.center-card h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.center-card .years-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.year-badge {
    background: var(--bg-color);
    color: var(--primary-color);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Vista de Cursos */
.courses-view {
    animation: fadeIn 0.3s ease;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.back-btn {
    background: var(--bg-color);
    border: none;
    color: var(--primary-color);
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.back-btn:hover {
    background: var(--border-color);
}

.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.course-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 0;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.25s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 140px;
}

.course-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.course-card .course-info {
    padding: 20px 20px 12px 20px;
    flex: 1;
}

.course-card .course-materia {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    line-height: 1.3;
}

.course-card .course-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.course-card .course-nivel,
.course-card .course-grupo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
    font-weight: 500;
    font-size: 0.8rem;
    border-radius: 20px;
}

.course-card .course-grupo {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    font-weight: 700;
    min-width: 44px;
    padding: 6px 14px;
}

.course-card .student-count {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(to top, var(--bg-color), transparent);
}

.course-card .student-count i {
    color: var(--primary-color);
}

/* Vista de Notas */
.grades-view {
    animation: fadeIn 0.3s ease;
}

.grades-container {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}

.grades-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.grades-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
}

.grades-header .title-nivel {
    font-size: 1rem;
    font-weight: 400;
    color: var(--primary-color);
    margin-left: 12px;
    background: rgba(37, 99, 235, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
    vertical-align: middle;
}

.grades-actions {
    display: flex;
    gap: 8px;
}

/* Botones */
.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--border-color);
}

/* Panel de estadísticas del curso */
.stats-panel {
    background: var(--bg-color);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-item {
    background: var(--card-bg);
    padding: 20px 16px;
    border-radius: var(--radius);
    text-align: center;
}

.stat-item .value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-item .label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 6px;
}

.stat-highlight {
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    border: 1px solid #86efac;
}

.stat-highlight .stat-number {
    font-size: 1.8rem;
    font-weight: 700;
    color: #15803d;
}

.stat-highlight-alt {
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    border: 1px solid #a5b4fc;
}

.stat-highlight-alt .stat-number {
    font-size: 1.8rem;
    font-weight: 700;
    color: #4338ca;
}

.stat-value-row {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
}

.stat-percent {
    font-size: 1rem;
    font-weight: 600;
    opacity: 0.8;
}

.stat-highlight .stat-percent {
    color: #15803d;
}

.stat-highlight-alt .stat-percent {
    color: #4338ca;
}

/* Tablas */
.table-container {
    overflow-x: auto;
}

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

.grades-table th,
.grades-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.grades-table th {
    background: var(--bg-color);
    font-weight: 600;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
}

.grades-table tr:hover {
    background: var(--bg-color);
}

.grades-table .grade-pass {
    color: var(--success-color);
    font-weight: 500;
}

.grades-table .grade-fail {
    color: var(--danger-color);
    font-weight: 500;
}

/* Sección de Estadísticas */
.filters-panel {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
}

.filter-row:last-of-type {
    margin-bottom: 16px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 150px;
    flex: 1;
}

.filter-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.filter-group select {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.95rem;
    background: white;
    cursor: pointer;
}

/* Dashboard de estadísticas */
.stats-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
}

.stat-card .stat-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
}

.stat-card .stat-info {
    display: flex;
    flex-direction: column;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-card .stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Gráficos */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.chart-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}

.chart-card.wide {
    grid-column: span 2;
}

.chart-card h4 {
    margin-bottom: 16px;
    color: var(--text-primary);
}

.chart-container {
    position: relative;
    height: 300px;
}

/* Tabla resumen */
.summary-table-container {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}

.summary-table-container h4 {
    margin-bottom: 16px;
}

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

.summary-table th,
.summary-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.summary-table th {
    background: var(--bg-color);
    font-weight: 600;
    color: var(--text-secondary);
}

.summary-table tr:hover {
    background: var(--bg-color);
}

.summary-materia {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.summary-nivel {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--primary-color);
    font-weight: 500;
    background: rgba(37, 99, 235, 0.1);
    padding: 2px 8px;
    border-radius: 12px;
    margin-top: 4px;
}

/* Footer */
.footer {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 24px;
    margin-top: 40px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    max-width: 1200px;
    margin: 0 auto;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 1.1rem;
}

.footer-links {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.footer-links a {
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.footer-links a:hover {
    opacity: 1;
    text-decoration: underline;
}

.footer-bottom {
    text-align: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.2);
    font-size: 0.85rem;
    opacity: 0.8;
}

@media (max-width: 600px) {
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
    
    .footer-links {
        justify-content: center;
    }
}

/* Utilidades */
.hidden {
    display: none !important;
}

/* Selector de años */
.year-selector {
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.year-selector label {
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}

.year-selector label i {
    color: var(--primary-color);
    font-size: 1.1rem;
}

.year-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.year-btn {
    background: linear-gradient(135deg, #ffffff, #f8fafc);
    border: 2px solid #cbd5e1;
    color: var(--text-primary);
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.25s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    min-width: 100px;
    text-align: center;
}

.year-btn:hover {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.25);
    transform: translateY(-2px);
}

.year-btn.active {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-color: var(--primary-dark);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

/* Animaciones */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

    .header {
        flex-direction: column;
        text-align: center;
        padding: 16px;
    }

    .header h1 {
        font-size: 1.3rem;
    }

    .main-nav {
        width: 100%;
        justify-content: center;
    }

    .nav-btn {
        flex: 1;
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    .section-header h2 {
        font-size: 1.2rem;
    }

    .timeline-logo {
        width: 36px;
        height: 36px;
    }

    .timeline-item {
        min-width: 70px;
    }

    .timeline-year {
        font-size: 0.75rem;
        padding: 3px 8px;
    }

    .centers-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .center-card {
        padding: 16px;
    }

    .courses-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .course-card {
        min-height: 100px;
        padding: 16px;
    }

    .course-card .course-materia {
        font-size: 1rem;
    }

    .breadcrumb {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .back-btn {
        width: 100%;
        justify-content: center;
    }

    .year-selector {
        padding: 12px;
    }

    .year-selector label {
        width: 100%;
    }

    .year-buttons {
        width: 100%;
        justify-content: center;
    }

    .year-btn {
        flex: 1;
        min-width: 80px;
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .grades-container {
        padding: 16px;
    }

    .grades-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .grades-header h3 {
        font-size: 1.1rem;
        text-align: center;
    }

    .grades-actions {
        width: 100%;
    }

    .grades-actions .btn-secondary {
        width: 100%;
        justify-content: center;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .stat-item {
        padding: 14px 10px;
    }

    .stat-item .value {
        font-size: 1.4rem;
    }

    .stat-highlight .stat-number,
    .stat-highlight-alt .stat-number {
        font-size: 1.4rem;
    }

    .grades-table {
        font-size: 0.8rem;
    }

    .grades-table th,
    .grades-table td {
        padding: 8px 6px;
    }

    .filters-panel {
        padding: 16px;
    }

    .filter-row {
        flex-direction: column;
        gap: 12px;
    }

    .filter-group {
        width: 100%;
    }

    .filter-group label {
        font-size: 0.85rem;
    }

    .filter-group select {
        padding: 10px 12px;
        font-size: 0.9rem;
    }

    .stats-dashboard {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-card .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .stat-card .stat-value {
        font-size: 1.2rem;
    }

    .stat-card .stat-label {
        font-size: 0.8rem;
    }

    .charts-grid {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }

    .chart-card {
        padding: 16px;
        grid-column: span 1 !important;
    }

    .chart-card h4 {
        font-size: 0.95rem;
    }

    .chart-container {
        height: 200px;
    }

    .summary-table-container {
        padding: 16px;
        overflow-x: auto;
    }

    .summary-table-container h4 {
        font-size: 1rem;
    }

    .summary-table {
        font-size: 0.8rem;
    }

    .summary-table th,
    .summary-table td {
        padding: 8px 6px;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.1rem;
    }

    .nav-btn {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .nav-btn i {
        display: none;
    }

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

    .stats-dashboard {
        grid-template-columns: 1fr;
    }

    .course-card .student-count {
        font-size: 0.8rem;
    }
}
