:root {
    --bg-body: #f8fafc;
    --surface: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    
    --color-ciencias: #3b82f6;
    --color-letras: #8b5cf6;
    --color-tecnica: #0ea5e9;
    --color-arte: #f97316;
    
    --live-bg: #fef2f2;
    --live-text: #ef4444;
    --waiting-bg: #f0fdf4;
    --waiting-text: #22c55e;
    --ended-bg: #f1f5f9;
    --ended-text: #94a3b8;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Plus Jakarta Sans', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

header {
    margin-bottom: 24px;
    max-width: 500px;
    width: 100%;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    padding: 20px;
    border-radius: 24px;
    color: white;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.15);
    display: flex;
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: 16px;
}

.school-logo {
    width: 65px;
    height: 65px;
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
    flex-shrink: 0;
}

.header-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

header h1 {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(180deg, #ffffff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
}

header p {
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 500;
}

.weekend-msg {
    background: #eff6ff;
    color: #1d4ed8;
    padding: 12px 16px;
    border-radius: 14px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 16px;
    max-width: 500px;
    width: 100%;
    border: 1px solid #bfdbfe;
    display: none;
}

.tabs-container {
    display: flex;
    width: 100%;
    max-width: 500px;
    background: #e2e8f0;
    padding: 4px;
    border-radius: 16px;
    margin-bottom: 24px;
    gap: 2px;
}

.tab-btn {
    flex: 1;
    padding: 12px 0;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    position: relative;
}

.tab-btn.active {
    background: var(--surface);
    color: #1e40af;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.tab-btn.is-today::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background-color: #3b82f6;
    border-radius: 50%;
}

.schedule-panel {
    display: none;
    width: 100%;
    max-width: 500px;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.schedule-panel.active {
    display: block;
}

.class-card {
    background: var(--surface);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.01), 0 2px 4px -1px rgba(0, 0, 0, 0.01);
    border: 1px solid #f1f5f9;
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.class-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
}

.class-card[data-type="ciencias"]::before { background-color: var(--color-ciencias); }
.class-card[data-type="letras"]::before { background-color: var(--color-letras); }
.class-card[data-type="tecnica"]::before { background-color: var(--color-tecnica); }
.class-card[data-type="arte-deporte"]::before { background-color: var(--color-arte); }

.class-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.time-badge {
    font-size: 0.8rem;
    font-weight: 700;
    color: #1e3a8a;
    background: #eff6ff;
    padding: 6px 12px;
    border-radius: 12px;
}

.period-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.class-title {
    font-size: 1.3rem;
    color: var(--text-main);
    font-weight: 800;
    letter-spacing: -0.3px;
    margin-bottom: 4px;
}

.class-teacher {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 16px;
}

.class-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    padding: 10px 14px;
    border-radius: 14px;
    gap: 8px;
    flex-wrap: wrap;
}

.code-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.code-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.code-value {
    font-family: monospace;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    background: #ffffff;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.btn-copy {
    background: transparent;
    border: none;
    color: #3b82f6;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    padding: 4px;
    text-decoration: none;
}

.action-buttons {
    display: flex;
    gap: 6px;
    align-items: center;
}

.btn-classroom {
    background: #10b981;
    color: white;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 10px 14px;
    border-radius: 12px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.15);
}

.btn-classroom:active { transform: scale(0.96); }

.btn-classroom.disabled {
    background: #cbd5e1;
    color: #94a3b8;
    box-shadow: none;
    cursor: not-allowed;
}

.btn-whatsapp {
    background: #25d366;
    color: white;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 10px 14px;
    border-radius: 12px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(37, 211, 102, 0.15);
    text-align: center;
}
.btn-whatsapp:active { transform: scale(0.96); }

.status-pill {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.class-card.state-live {
    border-color: rgba(239, 68, 68, 0.3);
    box-shadow: 0 12px 20px -5px rgba(239, 68, 68, 0.12), 0 4px 12px -2px rgba(239, 68, 68, 0.05);
    background: radial-gradient(circle at top right, #fffdfd 0%, #ffffff 100%);
}
.class-card.state-live .status-pill {
    background: var(--live-bg);
    color: var(--live-text);
    animation: pulseGlow 2s infinite;
}

.class-card.state-ended {
    opacity: 0.5;
    filter: grayscale(40%);
    box-shadow: none;
    background: #fafafa;
}
.class-card.state-ended .status-pill {
    background: var(--ended-bg);
    color: var(--ended-text);
}

.class-card.state-waiting .status-pill {
    background: var(--waiting-bg);
    color: var(--waiting-text);
}

.class-card.break-card {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px dashed #f59e0b;
}
.class-card.break-card::before { background-color: #f59e0b; }
.class-card.break-card .time-badge { background: #f59e0b; color: white; }
.break-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: #b45309;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ================================================================= */
/* NUEVA INTERFAZ DE ADMIN (REDISEÑO TOTAL MODERNO)                 */
/* ================================================================= */

.admin-page-bg {
    background-color: #f1f5f9;
}

.admin-container {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-bottom: 80px;
}

.admin-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #0f172a;
    color: white;
    padding: 18px 24px;
    border-radius: 20px;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.15);
    position: sticky;
    top: 16px;
    z-index: 100;
}
.admin-nav-title { 
    font-size: 1.1rem; 
    font-weight: 800; 
    display: flex; 
    align-items: center; 
    gap: 8px;
}

.admin-logout-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 8px 16px;
    border-radius: 12px;
    transition: all 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.05);
}
.admin-logout-btn:hover { background: rgba(255, 255, 255, 0.2); }

/* Pantalla de Login Premium */
.admin-body-login {
    justify-content: center;
    min-height: 100vh;
}
.admin-login-box {
    background: white;
    padding: 40px 32px;
    border-radius: 32px;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.15);
    width: 100%;
    max-width: 380px;
    text-align: center;
    border: 1px solid #e2e8f0;
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.admin-login-icon { font-size: 2.5rem; margin-bottom: 16px; }
.admin-login-box h2 { font-size: 1.6rem; font-weight: 800; color: #0f172a; margin-bottom: 8px; letter-spacing: -0.5px;}
.admin-login-box p { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 28px; font-weight: 500;}
.admin-login-box input[type="password"] {
    width: 100%;
    padding: 16px;
    border-radius: 16px;
    border: 2px solid #e2e8f0;
    font-size: 1.2rem;
    outline: none;
    text-align: center;
    background: #f8fafc;
    letter-spacing: 6px;
    transition: all 0.3s ease;
    margin-bottom: 16px;
}
.admin-login-box input[type="password"]:focus {
    border-color: #3b82f6;
    background: white;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}
.btn-admin-login {
    width: 100%;
    background: #3b82f6;
    color: white;
    font-size: 1rem;
    font-weight: 700;
    padding: 16px;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 10px 20px -5px rgba(59, 130, 246, 0.4);
}
.btn-admin-login:hover { background: #2563eb; transform: translateY(-2px); }
.btn-admin-login:active { transform: translateY(0); }

.login-error-msg { 
    color: #ef4444; 
    font-size: 0.85rem; 
    font-weight: 700; 
    margin-top: -8px; 
    margin-bottom: 16px; 
    background: #fef2f2; 
    padding: 8px; 
    border-radius: 8px; 
}

/* Tarjeta de Estadísticas Estilo Dashboard */
.stats-card { 
    background: white; 
    border: 1px solid #e2e8f0; 
    border-radius: 24px; 
    padding: 24px; 
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}
.stats-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.stats-header h3 { font-size: 1.15rem; font-weight: 800; color: #0f172a; }
.stats-badge-total { font-size: 0.75rem; background: #eff6ff; color: #2563eb; padding: 6px 12px; border-radius: 10px; font-weight: 700; }
.stats-subtitle { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 20px; font-weight: 500; }
.stats-table-wrapper { border: 1px solid #e2e8f0; border-radius: 16px; overflow: hidden; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.stats-table th { background: #f8fafc; padding: 14px 20px; font-weight: 700; color: var(--text-muted); border-bottom: 1px solid #e2e8f0; text-align: left;}
.stats-table td { padding: 16px 20px; border-bottom: 1px solid #f1f5f9; background: white; color: #334155; }
.stats-table tr:last-child td { border-bottom: none; }
.badge-today { background: #fee2e2; color: #ef4444; padding: 4px 8px; border-radius: 8px; font-size: 0.7rem; font-weight: 800; margin-left: 8px; }

/* Agrupadores por día */
.admin-day-group { 
    display: flex; 
    flex-direction: column; 
    gap: 16px; 
    margin-top: 12px; 
}
.admin-day-title { 
    font-size: 1.4rem; 
    font-weight: 800; 
    color: #0f172a; 
    padding-left: 8px; 
    border-left: 4px solid #3b82f6; 
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.admin-cards-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Tarjetas de Materia Independientes (SaaS UX) */
.admin-materia-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 4px 15px -5px rgba(15, 23, 42, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.admin-materia-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.08);
}
.admin-materia-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px dashed #e2e8f0;
    padding-bottom: 16px;
}
.admin-materia-card-header h4 { font-size: 1.15rem; font-weight: 800; color: #1e293b; letter-spacing: -0.3px; }
.admin-time-tag { font-size: 0.8rem; background: #f1f5f9; color: #475569; padding: 6px 12px; border-radius: 12px; font-weight: 700; border: 1px solid #e2e8f0;}

/* Grid de Formulario Configurable de Inputs */
.admin-input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.admin-field-group { display: flex; flex-direction: column; gap: 8px; }
.admin-field-group label { 
    font-size: 0.75rem; 
    font-weight: 700; 
    color: #475569; 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
}
.admin-field-group input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid #cbd5e1;
    font-size: 0.9rem;
    font-weight: 600;
    outline: none;
    color: #0f172a;
    background: #f8fafc;
    transition: all 0.2s ease;
}
.admin-field-group input:focus {
    border-color: #3b82f6;
    background: white;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}
.admin-field-group input::placeholder {
    color: #94a3b8;
    font-weight: 500;
}

/* Alertas flotantes de éxito */
.success-alert {
    background: #ecfdf5;
    color: #059669;
    padding: 16px;
    border-radius: 16px;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    border: 1px solid #a7f3d0;
    box-shadow: 0 4px 6px -1px rgba(5, 150, 105, 0.1);
    animation: slideUp 0.3s ease;
}

/* Botón Flotante Sticky de Guardado */
.admin-sticky-footer {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 500px;
    z-index: 100;
    padding: 0 16px;
}
.admin-btn-save {
    width: 100%;
    background: #10b981;
    color: white;
    font-size: 1rem;
    font-weight: 800;
    padding: 18px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 15px 30px -5px rgba(16, 185, 129, 0.4);
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}
.admin-btn-save:hover { background: #059669; transform: translateY(-3px); box-shadow: 0 20px 35px -5px rgba(16, 185, 129, 0.5); }
.admin-btn-save:active { transform: translateY(0); }
.save-icon { font-size: 1.2rem; }

/* Animaciones */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseGlow {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Adaptación estricta para celulares */
@media(max-width: 600px) {
    .admin-input-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .admin-container {
        padding-bottom: 100px;
    }
}