/* ============================================================
   Sistema de Horarios - Centro de Cómputo ENP 5 UNAM
   Colores institucionales: Azul marino UNAM + Oro ENP
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700;800&family=Source+Sans+3:wght@300;400;500;600;700&display=swap');

/* ─── Variables ─── */
:root {
    /* Paleta institucional UNAM / ENP */
    --azul-unam:        #003366;
    --azul-medio:       #004a8f;
    --azul-claro:       #1a6bbf;
    --azul-suave:       #e8f0fb;
    --oro-unam:         #c9a840;
    --oro-claro:        #e6cc66;
    --oro-bg:           #fdf8e8;
    --gris-900:         #1a1a2e;
    --gris-700:         #374151;
    --gris-500:         #6b7280;
    --gris-300:         #d1d5db;
    --gris-100:         #f3f4f6;
    --blanco:           #ffffff;
    --rojo-alerta:      #dc2626;
    --verde-ok:         #059669;

    /* Tipografía */
    --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
    --font-body:    'Source Sans 3', 'Segoe UI', system-ui, sans-serif;

    /* Sombras */
    --shadow-sm:  0 1px 3px rgba(0,51,102,0.08);
    --shadow-md:  0 4px 12px rgba(0,51,102,0.1);
    --shadow-lg:  0 8px 30px rgba(0,51,102,0.15);
    --shadow-oro: 0 4px 20px rgba(201,168,64,0.2);

    /* Bordes */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    /* Transiciones */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--gris-100);
    color: var(--gris-700);
    line-height: 1.6;
    min-height: 100vh;
}

/* ─── Fondo sutil con patrón ─── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(0,51,102,0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(201,168,64,0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* ─── Header institucional ─── */
.header-institucional {
    background: linear-gradient(135deg, var(--azul-unam) 0%, #001a3a 100%);
    color: var(--blanco);
    padding: 0;
    position: relative;
    overflow: hidden;
}

.header-institucional::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--oro-unam), var(--oro-claro), var(--oro-unam));
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    gap: 20px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-logos {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-unam, .logo-enp {
    height: 56px;
    width: auto;
    filter: brightness(0) invert(1);
    opacity: 0.9;
    transition: opacity 0.3s var(--ease);
}

.logo-unam:hover, .logo-enp:hover {
    opacity: 1;
}

.header-text h1 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.header-text .subtitulo {
    font-size: 0.85rem;
    font-weight: 300;
    opacity: 0.8;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.header-text .ciclo {
    display: inline-block;
    margin-top: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--oro-unam);
    color: var(--azul-unam);
    padding: 2px 10px;
    border-radius: 20px;
    letter-spacing: 0.04em;
}

.header-reloj {
    text-align: right;
}

/* ─── Reloj Digital LED ─── */
.reloj-digital {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--oro-claro);
    text-shadow: 0 0 8px rgba(230,204,102,0.4);
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.reloj-fecha {
    font-size: 0.78rem;
    font-weight: 400;
    opacity: 0.7;
    margin-top: 2px;
}

/* ─── Navegación / Barra de filtros ─── */
.nav-filtros {
    background: var(--blanco);
    border-bottom: 1px solid var(--gris-300);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
}

.filtro-grupo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filtro-grupo label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--azul-unam);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.filtro-grupo label svg {
    width: 16px;
    height: 16px;
    color: var(--oro-unam);
}

.filtro-grupo select {
    appearance: none;
    background: var(--blanco);
    border: 2px solid var(--gris-300);
    border-radius: var(--radius-sm);
    padding: 8px 36px 8px 12px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--gris-700);
    cursor: pointer;
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23003366' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.filtro-grupo select:focus {
    outline: none;
    border-color: var(--azul-claro);
    box-shadow: 0 0 0 3px rgba(26,107,191,0.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s var(--ease);
    text-decoration: none;
}

.btn svg {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--azul-unam), var(--azul-medio));
    color: var(--blanco);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--azul-medio), var(--azul-claro));
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-oro {
    background: linear-gradient(135deg, var(--oro-unam), #d4b44a);
    color: var(--azul-unam);
    box-shadow: var(--shadow-oro);
}

.btn-oro:hover {
    background: linear-gradient(135deg, #d4b44a, var(--oro-claro));
    transform: translateY(-1px);
}

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

.btn-outline:hover {
    background: var(--azul-unam);
    color: var(--blanco);
}

.btn-danger {
    background: var(--rojo-alerta);
    color: var(--blanco);
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* ─── Contenido principal ─── */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 32px 48px;
}

/* ─── Cards de estadísticas ─── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--blanco);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--azul-unam);
    transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

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

.stat-card.oro { border-left-color: var(--oro-unam); }
.stat-card.verde { border-left-color: var(--verde-ok); }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.azul { background: var(--azul-suave); color: var(--azul-unam); }
.stat-icon.oro  { background: var(--oro-bg); color: var(--oro-unam); }
.stat-icon.verde { background: #ecfdf5; color: var(--verde-ok); }

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-info .stat-number {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--gris-900);
    line-height: 1;
}

.stat-info .stat-label {
    font-size: 0.8rem;
    color: var(--gris-500);
    font-weight: 500;
    margin-top: 2px;
}

/* ─── Título de sección ─── */
.section-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.section-title h2 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    color: var(--azul-unam);
}

.section-title .badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--oro-bg);
    color: var(--oro-unam);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(201,168,64,0.3);
}

/* ─── Tabla de horarios ─── */
.tabla-wrapper {
    background: var(--blanco);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    animation: fadeSlideUp 0.5s var(--ease);
}

.tabla-header {
    background: linear-gradient(135deg, var(--azul-unam), var(--azul-medio));
    color: var(--blanco);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tabla-header h3 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tabla-header .turno-badge {
    background: var(--oro-unam);
    color: var(--azul-unam);
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
}

.tabla-scroll {
    overflow-x: auto;
}

table.horario-tabla {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

table.horario-tabla thead th {
    background: #f0f4fa;
    color: var(--azul-unam);
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    border-bottom: 2px solid var(--gris-300);
    position: sticky;
    top: 0;
    z-index: 5;
}

table.horario-tabla thead th:first-child {
    background: var(--azul-unam);
    color: var(--blanco);
    width: 80px;
    text-align: center;
}

table.horario-tabla thead th.dia-actual {
    background: var(--oro-bg);
    color: var(--oro-unam);
    border-bottom-color: var(--oro-unam);
}

table.horario-tabla tbody td {
    padding: 10px 12px;
    border: 1px solid #e9ecf1;
    vertical-align: top;
    font-size: 0.85rem;
    min-height: 60px;
    transition: background-color 0.15s var(--ease);
}

table.horario-tabla tbody td:first-child {
    background: #f8f9fc;
    font-weight: 700;
    color: var(--azul-unam);
    text-align: center;
    font-size: 0.9rem;
    white-space: nowrap;
    border-right: 2px solid var(--gris-300);
}

table.horario-tabla tbody tr:hover td {
    background-color: rgba(0,51,102,0.02);
}

table.horario-tabla tbody tr:hover td:first-child {
    background: var(--azul-suave);
}

table.horario-tabla tbody td.dia-actual-col {
    background: rgba(201,168,64,0.04);
}

table.horario-tabla tbody td.hora-actual {
    box-shadow: inset 3px 0 0 var(--oro-unam);
}

/* ─── Celda de clase ─── */
.clase-celda {
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    border-left: 3px solid var(--azul-unam);
    background: var(--azul-suave);
    transition: transform 0.15s var(--ease);
}

.clase-celda:hover {
    transform: scale(1.02);
}

.clase-celda.prestamo {
    border-left-color: var(--gris-500);
    background: #f9fafb;
}

.clase-celda.ete {
    border-left-color: var(--oro-unam);
    background: var(--oro-bg);
}

.clase-materia {
    font-weight: 700;
    color: var(--gris-900);
    font-size: 0.82rem;
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 4px;
}

.clase-materia svg {
    width: 13px;
    height: 13px;
    color: var(--azul-claro);
    flex-shrink: 0;
}

.clase-grupo {
    font-size: 0.75rem;
    color: var(--azul-medio);
    font-weight: 600;
    margin-top: 2px;
}

.clase-profesor {
    font-size: 0.73rem;
    color: var(--gris-500);
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 3px;
}

.clase-profesor svg {
    width: 11px;
    height: 11px;
    flex-shrink: 0;
}

.celda-vacia {
    color: var(--gris-300);
    text-align: center;
    font-size: 0.8rem;
}

/* ─── Mensaje vacío ─── */
.mensaje-vacio {
    text-align: center;
    padding: 60px 20px;
    background: var(--blanco);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.mensaje-vacio svg {
    width: 64px;
    height: 64px;
    color: var(--gris-300);
    margin-bottom: 16px;
}

.mensaje-vacio h3 {
    font-family: var(--font-display);
    color: var(--azul-unam);
    font-size: 1.2rem;
    margin-bottom: 8px;
}

.mensaje-vacio p {
    color: var(--gris-500);
    font-size: 0.9rem;
}

/* ─── Footer ─── */
.footer {
    background: linear-gradient(135deg, var(--azul-unam), #001a3a);
    color: var(--blanco);
    text-align: center;
    padding: 20px 32px;
    font-size: 0.8rem;
    margin-top: 40px;
    position: relative;
}

.footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--oro-unam), var(--oro-claro), var(--oro-unam));
}

.footer a {
    color: var(--oro-claro);
    text-decoration: none;
}

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

.footer .footer-line {
    opacity: 0.7;
}

/* ─── Formularios admin ─── */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--azul-unam);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-group input,
.form-group select,
.form-group textarea {
    border: 2px solid var(--gris-300);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--gris-700);
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--azul-claro);
    box-shadow: 0 0 0 3px rgba(26,107,191,0.12);
}

/* ─── Alertas ─── */
.alerta {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: fadeSlideUp 0.3s var(--ease);
}

.alerta svg { width: 20px; height: 20px; flex-shrink: 0; }

.alerta-exito {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alerta-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alerta-info {
    background: var(--azul-suave);
    color: var(--azul-unam);
    border: 1px solid #bfdbfe;
}

/* ─── Tabla admin ─── */
table.admin-tabla {
    width: 100%;
    border-collapse: collapse;
    background: var(--blanco);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

table.admin-tabla thead th {
    background: var(--azul-unam);
    color: var(--blanco);
    padding: 12px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
}

table.admin-tabla tbody td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--gris-100);
    font-size: 0.9rem;
}

table.admin-tabla tbody tr:hover {
    background: var(--azul-suave);
}

table.admin-tabla .acciones {
    display: flex;
    gap: 6px;
}

/* ─── Login ─── */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--azul-unam) 0%, #001a3a 50%, #000d1f 100%);
    padding: 20px;
}

.login-box {
    background: var(--blanco);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-box .login-logo {
    width: 80px;
    margin-bottom: 16px;
}

.login-box h2 {
    font-family: var(--font-display);
    color: var(--azul-unam);
    margin-bottom: 4px;
}

.login-box .login-sub {
    font-size: 0.85rem;
    color: var(--gris-500);
    margin-bottom: 28px;
}

.login-box .form-group {
    text-align: left;
    margin-bottom: 16px;
}

.login-box .btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 1rem;
}

/* ─── Tabs para admin ─── */
.admin-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--gris-300);
    padding-bottom: 0;
}

.admin-tab {
    padding: 10px 20px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gris-500);
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s var(--ease);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: -2px;
}

.admin-tab:hover {
    color: var(--azul-unam);
}

.admin-tab.active {
    color: var(--azul-unam);
    border-bottom-color: var(--oro-unam);
}

.admin-tab svg {
    width: 16px;
    height: 16px;
}

/* ─── Modal ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s var(--ease);
}

.modal-box {
    background: var(--blanco);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 600px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.3s var(--ease);
}

.modal-box h3 {
    font-family: var(--font-display);
    color: var(--azul-unam);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ─── Animaciones ─── */
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

/* ─── Responsivo ─── */
@media (max-width: 768px) {
    .header-top {
        flex-direction: column;
        padding: 12px 16px;
        text-align: center;
    }

    .header-brand {
        flex-direction: column;
    }

    .header-text h1 {
        font-size: 1.2rem;
    }

    .nav-filtros {
        padding: 12px 16px;
        flex-direction: column;
        align-items: stretch;
    }

    .filtro-grupo {
        flex-direction: column;
        align-items: stretch;
    }

    .main-content {
        padding: 16px;
    }

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

    .login-box {
        padding: 24px;
    }
}

@media (max-width: 480px) {
    .stats-row {
        grid-template-columns: 1fr;
    }

    .header-text h1 {
        font-size: 1rem;
    }
}

/* ─── Impresión ─── */
@media print {
    body { background: white; }
    .header-institucional::after,
    .nav-filtros,
    .footer,
    .stats-row,
    .btn,
    .reloj-digital { display: none; }

    .header-institucional {
        background: white !important;
        color: black !important;
        border-bottom: 2px solid #003366;
    }

    .header-text h1 { color: #003366; }

    .tabla-wrapper { box-shadow: none; }
    .tabla-header {
        background: #003366 !important;
        color: white !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    table.horario-tabla thead th {
        background: #e8f0fb !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
