/* ==========================================================
   TEMA "CIELO Y ORO" — Instituto de Cristo MLLF
   Colores compartidos por todas las páginas del sistema.
   Cambia un color aquí y cambia en todo el sistema.
   ========================================================== */
:root {
    /* Azul real: color principal (menú activo, botones, títulos) */
    --azul-900: #172554;
    --azul-800: #1E3A8A;
    --azul-700: #1D4ED8;
    --azul-600: #2563EB;
    --azul-500: #3B82F6;
    --azul-200: #BFDBFE;
    --azul-100: #DBEAFE;
    --azul-50:  #EFF6FF;

    /* Dorado: acción principal (Registrar) y detalles */
    --oro:        #FBBF24;
    --oro-fuerte: #F59E0B;
    --oro-tinta:  #78350F;
    --oro-suave:  #FEF3C7;

    /* Un color por rol (igual en todo el sistema) */
    --alumno:      #0284C7;
    --alumno-vivo: #0EA5E9;
    --alumno-bg:   #E0F2FE;
    --maestro:      #059669;
    --maestro-vivo: #10B981;
    --maestro-bg:   #D1FAE5;
    --servidor:      #7C3AED;
    --servidor-vivo: #8B5CF6;
    --servidor-bg:   #EDE9FE;

    /* Estados */
    --ok:        #16A34A;
    --ok-bg:     #DCFCE7;
    --ok-tinte:  #F0FDF4;
    --tarde:     #EA580C;
    --tarde-bg:  #FFEDD5;
    --tarde-tinte: #FFF7ED;
    --error:     #DC2626;
    --error-bg:  #FEE2E2;
    --error-tinte: #FEF2F2;

    /* Neutros con tinte azul */
    --tinta:       #0F1B3D;
    --tinta-suave: #5B6785;
    --contorno:    #94A3B8;
    --linea:       #E3E9F5;
    --tarjeta:     #FFFFFF;
    --superficie:  #F1F5FF;
    --fondo:       #F7F9FF;

    --sombra:    0 1px 8px rgba(15, 27, 61, 0.05);
    --sombra-md: 0 10px 28px -12px rgba(29, 78, 216, 0.25);
    --sombra-lg: 0 24px 48px -18px rgba(15, 27, 61, 0.35);
    --radio:     24px;
    --fuente:    'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
}

/* Clases de rol reutilizables: definen --rol / --rol-vivo / --rol-bg */
.r-alumno   { --rol: var(--alumno);   --rol-vivo: var(--alumno-vivo);   --rol-bg: var(--alumno-bg); }
.r-maestro  { --rol: var(--maestro);  --rol-vivo: var(--maestro-vivo);  --rol-bg: var(--maestro-bg); }
.r-servidor { --rol: var(--servidor); --rol-vivo: var(--servidor-vivo); --rol-bg: var(--servidor-bg); }

/* Iconos (Material Symbols) */
.ms { font-family: 'Material Symbols Outlined'; font-weight: normal; font-style: normal; line-height: 1; letter-spacing: normal; text-transform: none; display: inline-block; white-space: nowrap; direction: ltr; -webkit-font-smoothing: antialiased; font-variation-settings: 'FILL' 0, 'wght' 500; }

/* Chips de estado */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 0.72rem; font-weight: 800; padding: 4px 10px; border-radius: 99px; white-space: nowrap; letter-spacing: 0.02em; }
.chip-ok    { background: var(--ok-bg);    color: var(--ok); }
.chip-tarde { background: var(--tarde-bg); color: var(--tarde); }
.chip-error { background: var(--error-bg); color: var(--error); }
.chip-rol   { background: var(--rol-bg);   color: var(--rol); text-transform: capitalize; }
.chip-azul  { background: var(--azul-100); color: var(--azul-700); }
.chip-gris  { background: var(--superficie); color: var(--tinta-suave); }

/* ==========================================================
   DISEÑO COMPARTIDO (menú lateral, barra superior, tarjetas,
   botones). El menú y la barra los dibuja layout.js.
   ========================================================== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { overscroll-behavior: none; }
body { font-family: var(--fuente); color: var(--tinta); background: var(--fondo); min-height: 100vh; font-size: 15px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font-family: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--azul-500); outline-offset: 2px; }

/* --- Menú lateral --- */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 272px; z-index: 1000;
    background: var(--tarjeta); box-shadow: var(--sombra);
    display: flex; flex-direction: column; justify-content: space-between; gap: 16px;
    padding: 20px 14px calc(16px + env(safe-area-inset-bottom, 0px)); overflow-y: auto;
}
.sb-top { display: flex; flex-direction: column; gap: 18px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px; text-decoration: none; }
.brand img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: none; border: 2px solid var(--oro); background: #fff; }
.brand b { display: block; font-size: 1rem; line-height: 1.2; font-weight: 800; }
.brand small { display: block; font-size: 0.66rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--azul-600); margin-top: 2px; }
.live-box { margin: 0 4px; background: var(--superficie); border-radius: 18px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.live-box span:first-child { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; font-weight: 700; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--maestro-vivo); animation: pulso 1.6s infinite; flex: none; display: inline-block; }
@keyframes pulso { 50% { opacity: 0.35; transform: scale(0.85); } }
.live-box .en-vivo { font-size: 0.68rem; font-weight: 800; color: var(--maestro); background: var(--tarjeta); padding: 2px 9px; border-radius: 99px; }
.nav { display: flex; flex-direction: column; gap: 3px; padding: 0 4px; }
.nav-label { font-size: 0.64rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--contorno); padding: 12px 14px 4px; }
.nav-link {
    display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 99px;
    color: var(--tinta-suave); text-decoration: none; font-weight: 700; font-size: 0.88rem; transition: background 0.15s, color 0.15s;
}
.nav-link .ms { font-size: 21px; }
.nav-link:hover { background: var(--superficie); color: var(--tinta); }
.nav-link.active { background: var(--azul-700); color: #fff; box-shadow: 0 8px 18px -8px rgba(29, 78, 216, 0.6); }
.user-card { margin: 0 4px; background: var(--superficie); border-radius: 18px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; }
.user-card .avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--azul-700); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 0.85rem; flex: none; }
.user-card .info { flex: 1; min-width: 0; }
.user-card b { display: block; font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card small { display: block; font-size: 0.7rem; color: var(--tinta-suave); }
.icon-btn { border: none; background: transparent; color: var(--tinta-suave); width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; text-decoration: none; flex: none; }
.icon-btn:hover { background: var(--tarjeta); color: var(--error); }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(15, 27, 61, 0.45); z-index: 999; }
.sidebar-overlay.active { display: block; }

/* --- Barra superior --- */
.topbar {
    position: fixed; top: 0; left: 272px; right: 0; z-index: 900; height: calc(76px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 28px 0; display: flex; align-items: center; justify-content: space-between; gap: 16px;
    background: rgba(247, 249, 255, 0.86); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: var(--sombra);
}
.menu-toggle { display: none; flex: none; width: 44px; height: 44px; border-radius: 14px; border: none; background: var(--tarjeta); color: var(--azul-700); cursor: pointer; place-items: center; box-shadow: var(--sombra); }
.top-titulo { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.05rem; }
.top-titulo .ms { color: var(--azul-600); }
.search-container { position: relative; flex: 1; max-width: 560px; }
.search-container > .ms { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--contorno); font-size: 20px; pointer-events: none; }
.search-container input {
    width: 100%; height: 46px; padding: 0 18px 0 46px; border-radius: 99px; border: 2px solid transparent; outline: none;
    background: var(--tarjeta); color: var(--tinta); font-size: 0.9rem; font-weight: 600; box-shadow: var(--sombra);
}
.search-container input::placeholder { color: var(--contorno); font-weight: 500; }
.search-container input:focus { border-color: var(--azul-500); }
.sugerencias {
    position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 1500; display: none;
    background: var(--tarjeta); border-radius: 18px; list-style: none; padding: 6px; max-height: 300px; overflow-y: auto;
    box-shadow: var(--sombra-lg); border: 1px solid var(--linea);
}
.sugerencias li { padding: 11px 14px; border-radius: 12px; cursor: pointer; font-size: 0.9rem; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.sugerencias li:hover, .sugerencias li.active { background: var(--superficie); color: var(--azul-700); }
.sugerencias li small { background: var(--azul-100); color: var(--azul-700); padding: 2px 8px; border-radius: 6px; font-size: 0.72rem; font-weight: 700; flex: none; }
.sugerencias li.vacio { cursor: default; color: var(--tinta-suave); }
.top-right { display: flex; align-items: center; gap: 10px; flex: none; }
.pill-info { display: flex; align-items: center; gap: 6px; background: var(--tarjeta); padding: 8px 14px; border-radius: 99px; box-shadow: var(--sombra); font-size: 0.78rem; font-weight: 700; color: var(--tinta-suave); }
.pill-info .ms { color: var(--oro-fuerte); font-size: 18px; }

/* --- Contenido --- */
.main-wrap { margin-left: 272px; padding: calc(76px + 26px + env(safe-area-inset-top, 0px)) 28px 40px; display: flex; flex-direction: column; gap: 26px; min-width: 0; max-width: 1500px; }

/* --- Tarjetas --- */
.card { background: var(--tarjeta); border-radius: var(--radio); padding: 24px; box-shadow: var(--sombra); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.card-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.card-title .ico { width: 44px; height: 44px; border-radius: 16px; display: grid; place-items: center; flex: none; background: var(--azul-100); color: var(--azul-700); }
.card-title .ico.oro { background: var(--oro-suave); color: var(--oro-tinta); }
.card-title .ico.verde { background: var(--maestro-bg); color: var(--maestro); }
.card-title .ico.rojo { background: var(--error-bg); color: var(--error); }
.card-title h2 { font-size: 1.15rem; font-weight: 800; line-height: 1.25; }
.card-title p { font-size: 0.8rem; color: var(--tinta-suave); }
.list-hint { text-align: center; color: var(--tinta-suave); font-size: 0.82rem; padding: 24px 10px; }

/* --- Botones --- */
.btn {
    flex: 1; border: none; cursor: pointer; padding: 11px 16px; border-radius: 99px; font-weight: 800; font-size: 0.82rem;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; transition: background 0.15s, transform 0.15s;
    background: var(--superficie); color: var(--tinta); text-decoration: none;
}
.btn:hover { background: var(--azul-100); }
.btn:active { transform: translateY(1px); }
.btn .ms { font-size: 18px; }
.btn-blanco { background: var(--tarjeta); box-shadow: var(--sombra); }
.btn-azul { background: var(--azul-700); color: #fff; }
.btn-azul:hover { background: var(--azul-800); }
.btn-rojo-suave { background: var(--error-bg); color: var(--error); }
.btn-rojo-suave:hover { background: #FECACA; }
.btn-oro {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: none; cursor: pointer; white-space: nowrap;
    background: var(--oro); color: var(--oro-tinta); font-weight: 800; font-size: 0.9rem; padding: 14px 24px; border-radius: 99px;
    box-shadow: 0 10px 22px -10px rgba(245, 158, 11, 0.8); transition: transform 0.15s, background 0.15s; text-decoration: none;
}
.btn-oro:hover { background: var(--oro-fuerte); }
.btn-oro:active { transform: translateY(1px); }
.btn-oro .ms { font-size: 20px; }
.pill { border: none; cursor: pointer; padding: 7px 14px; border-radius: 99px; background: var(--superficie); color: var(--tinta-suave); font-weight: 700; font-size: 0.78rem; }
.pill:hover { color: var(--tinta); }
.pill.is-active { background: var(--azul-700); color: #fff; }

/* --- Avisos (toast) --- */
#toast-container { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); right: 20px; z-index: 10000; display: flex; flex-direction: column-reverse; gap: 10px; max-width: calc(100vw - 40px); }
.toast { padding: 14px 18px; border-radius: 16px; color: #fff; font-weight: 700; font-size: 0.88rem; box-shadow: var(--sombra-lg); animation: toastIn .3s ease-out; }
.toast.success { background: var(--ok); }
.toast.error { background: var(--error); }
.toast.fade-out { animation: toastOut .4s ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(20px); } }

/* --- Responsivo del diseño compartido --- */
@media (max-width: 1100px) {
    .sidebar { transform: translateX(-105%); transition: transform 0.3s ease; box-shadow: var(--sombra-lg); }
    .sidebar.open { transform: translateX(0); }
    .topbar { left: 0; padding-left: 16px; padding-right: 16px; }
    .menu-toggle { display: grid; }
    .main-wrap { margin-left: 0; padding-left: 20px; padding-right: 20px; }
}
@media (max-width: 900px) { .pill-info { display: none; } }
@media (max-width: 640px) {
    .main-wrap { padding: calc(76px + 16px + env(safe-area-inset-top, 0px)) 12px 28px; gap: 18px; }
    .card { padding: 18px; }
    .search-container input { font-size: 16px; } /* evita el zoom automático del iPhone */
    #toast-container { left: 12px; right: 12px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
    .sidebar, .sidebar-overlay, .topbar, #toast-container { display: none !important; }
    .main-wrap { margin: 0 !important; padding: 0 !important; max-width: none; }
    body { background: #fff !important; }
}
