/*
 * USJC UI — componentes reutilizables de la vista móvil (tipo app).
 *
 * Reglas:
 *  - Todo usa el prefijo .usjc-* : ninguna clase de aquí existe en el HTML original,
 *    así que este archivo no cambia nada de las pantallas actuales de escritorio.
 *  - Los valores (colores, radios, espacios) salen de los tokens de :root.
 *    Si se cambia un token, cambia en todos los componentes y en las adaptaciones
 *    de mobile.css, que usan los mismos tokens.
 *  - Para usarlos desde Twig: templates/ui/components.html.twig (macros).
 *  - Guía: docs/vista-movil.md
 */

/* ================================================================
   1. TOKENS
   ================================================================ */
:root {
    /* Color — tomados del tema Blue_Theme de styles.css */
    --usjc-bg: #f4f7fb;
    --usjc-surface: #ffffff;
    --usjc-ink: #2a3547;
    --usjc-muted: #5a6a85;
    --usjc-subtle: #7c8fac;
    --usjc-line: #e3e9f2;
    --usjc-line-strong: #d9e1ec;
    --usjc-navy: #0f1e45;
    --usjc-navy-hover: #1b2d5e;
    --usjc-primary: #5d87ff;
    --usjc-link: #3f63d1;
    --usjc-focus: #a8dcff;

    /* Rellenos de tarjetas (texto oscuro encima: contraste AA) */
    --usjc-fill-blue: #5d87ff;   --usjc-on-blue: #0f1e45;
    --usjc-fill-amber: #ffcf73;  --usjc-on-amber: #2a1c00;
    --usjc-fill-sky: #a8dcff;    --usjc-on-sky: #0b3550;
    --usjc-fill-mint: #9ff0e0;   --usjc-on-mint: #063f35;
    --usjc-fill-coral: #ffc4b3;  --usjc-on-coral: #4a1606;

    /* Tintes suaves (iconos, insignias, alertas) */
    --usjc-tint-primary: #e6edff;  --usjc-on-tint-primary: #3f63d1;
    --usjc-tint-success: #dcf8f2;  --usjc-on-tint-success: #0a6b59;
    --usjc-tint-warning: #fff2db;  --usjc-on-tint-warning: #7a4a00;
    --usjc-tint-danger: #ffe9e3;   --usjc-on-tint-danger: #a3391b;
    --usjc-tint-info: #e2f5ff;     --usjc-on-tint-info: #0b5f8c;
    --usjc-tint-neutral: #eef2f7;  --usjc-on-tint-neutral: #4a5a75;

    /* Forma */
    --usjc-radius-sm: 12px;
    --usjc-radius-field: 14px;
    --usjc-radius-item: 18px;
    --usjc-radius: 22px;
    --usjc-radius-lg: 28px;
    --usjc-pill: 999px;

    /* Espacio */
    --usjc-gap-1: 4px;
    --usjc-gap-2: 8px;
    --usjc-gap-3: 12px;
    --usjc-gap-4: 16px;
    --usjc-gap-5: 20px;
    --usjc-gap-6: 24px;

    /* Tamaños */
    --usjc-touch: 44px;
    --usjc-field-h: 48px;
    --usjc-font: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;

    /* Zonas seguras (notch / barra de inicio del iPhone) */
    --usjc-safe-top: env(safe-area-inset-top, 0px);
    --usjc-safe-bottom: env(safe-area-inset-bottom, 0px);
    --usjc-tabbar-space: calc(104px + var(--usjc-safe-bottom));

    /* Profundidad y campos */
    --usjc-shadow: 0 1px 2px rgba(15, 30, 69, 0.04), 0 6px 18px rgba(15, 30, 69, 0.05);
    --usjc-field-bg: #f2f5fa;
}

@keyframes usjc-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes usjc-fade { from { opacity: 0; } to { opacity: 1; } }

/* Piezas del menú lateral móvil: solo se ven en pantallas pequeñas (mobile.css) */
.usjc-drawer-head,
.usjc-drawer-foot { display: none; }

/* Avatar con iniciales en tarjetas de personas (lo agrega mobile.js) */
.usjc-row-avatar {
    width: 42px; height: 42px; flex: 0 0 42px;
    border-radius: 50%;
    background: #ffd9a8; color: #7a4a10;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700;
}
@media (min-width: 992px) { .usjc-row-avatar { display: none !important; } }

/* ================================================================
   2. TEXTO
   ================================================================ */
.usjc-muted { color: var(--usjc-muted); font-size: 13px; }
.usjc-sr-only {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

/* Encabezado de página: título grande + subtítulo */
.usjc-page-head { margin: 8px 0 20px; }
.usjc-page-head h1 {
    margin: 0;
    font-size: 26px;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.4px;
    color: var(--usjc-ink);
}
.usjc-page-head p {
    margin: 6px 0 0;
    font-size: 14px;
    line-height: 1.45;
    color: var(--usjc-muted);
}

/* Título de sección con enlace opcional a la derecha */
.usjc-section-head {
    margin-top: var(--usjc-gap-6);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--usjc-gap-3);
}
.usjc-section-head h2,
.usjc-section-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--usjc-ink);
}
.usjc-section-title { margin-top: var(--usjc-gap-6); }
.usjc-section-head a {
    font-size: 13px;
    font-weight: 600;
    color: var(--usjc-link);
    text-decoration: none;
}

/* ================================================================
   3. SUPERFICIES
   ================================================================ */
.usjc-card {
    background: var(--usjc-surface);
    border-radius: 20px;
    padding: var(--usjc-gap-4);
}
.usjc-card h3 { margin: 0 0 6px; font-size: 15px; font-weight: 700; color: var(--usjc-ink); }
.usjc-card p { margin: 0; font-size: 14px; color: var(--usjc-muted); line-height: 1.5; }

/* Tarjeta destacada (hero) con figuras decorativas */
.usjc-hero {
    position: relative;
    overflow: hidden;
    margin-top: var(--usjc-gap-5);
    border-radius: var(--usjc-radius-lg);
    padding: 22px;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: var(--usjc-gap-4);
}
.usjc-hero-blue  { background: var(--usjc-fill-blue); color: var(--usjc-on-blue); }
.usjc-hero-sky   { background: #49beff; color: #05263b; }
.usjc-hero-coral { background: var(--usjc-fill-coral); color: var(--usjc-on-coral); }
.usjc-hero-soft  { background: var(--usjc-surface); color: var(--usjc-ink); }
.usjc-hero-text { position: relative; max-width: 230px; }
.usjc-hero-coral .usjc-hero-text,
.usjc-hero-soft .usjc-hero-text { max-width: none; }
.usjc-hero h2 { margin: 0 0 6px; font-size: 25px; font-weight: 800; line-height: 1.1; color: inherit; }
.usjc-hero p { margin: 0; font-size: 13px; font-weight: 500; color: inherit; }
.usjc-hero-actions { position: relative; display: flex; flex-wrap: wrap; gap: var(--usjc-gap-2); }
.usjc-hero-shape { position: absolute; pointer-events: none; }
.usjc-hero-shape-a { right: -26px; top: -30px; width: 130px; height: 130px; border-radius: 50%; border: 26px solid #ffae1f; }
.usjc-hero-shape-b { right: 38px; top: 72px; width: 70px; height: 70px; border-radius: 22px; background: #49beff; transform: rotate(18deg); }
.usjc-hero-sky .usjc-hero-shape-b { background: var(--usjc-primary); }
.usjc-hero-shape-c { right: -14px; bottom: -20px; width: 64px; height: 64px; border-radius: 50%; background: #13deb9; }

/* Mosaico de accesos (2 columnas) */
.usjc-tiles {
    margin-top: var(--usjc-gap-3);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--usjc-gap-3);
}
.usjc-tile {
    min-height: 96px;
    border-radius: var(--usjc-radius);
    padding: var(--usjc-gap-4);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
    text-decoration: none;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
}
.usjc-tile i { font-size: 22px; }
.usjc-tile:hover, .usjc-tile:focus { filter: brightness(0.97); color: inherit; }

.usjc-fill-blue  { background: var(--usjc-fill-blue);  color: var(--usjc-on-blue); }
.usjc-fill-amber { background: var(--usjc-fill-amber); color: var(--usjc-on-amber); }
.usjc-fill-sky   { background: var(--usjc-fill-sky);   color: var(--usjc-on-sky); }
.usjc-fill-mint  { background: var(--usjc-fill-mint);  color: var(--usjc-on-mint); }
.usjc-fill-coral { background: var(--usjc-fill-coral); color: var(--usjc-on-coral); }

/* ================================================================
   4. LISTAS
   ================================================================ */
.usjc-list { background: var(--usjc-surface); border-radius: var(--usjc-radius); padding: 4px 0; }
.usjc-list-item {
    min-height: 60px;
    display: flex;
    align-items: center;
    gap: var(--usjc-gap-3);
    padding: 8px 14px;
    color: var(--usjc-ink);
    text-decoration: none;
}
.usjc-list-item + .usjc-list-item { border-top: 1px solid #eef2f7; }
.usjc-list-text { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: left; }
.usjc-list-text strong { font-size: 15px; font-weight: 600; color: var(--usjc-ink); }
.usjc-list-text small { font-size: 12px; color: var(--usjc-muted); }

.usjc-icon {
    width: 38px; height: 38px; flex-shrink: 0;
    border-radius: var(--usjc-radius-sm);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 16px;
}
.usjc-tint-primary { background: var(--usjc-tint-primary); color: var(--usjc-on-tint-primary); }
.usjc-tint-success { background: var(--usjc-tint-success); color: var(--usjc-on-tint-success); }
.usjc-tint-warning { background: var(--usjc-tint-warning); color: var(--usjc-on-tint-warning); }
.usjc-tint-danger  { background: var(--usjc-tint-danger);  color: var(--usjc-on-tint-danger); }
.usjc-tint-info    { background: var(--usjc-tint-info);    color: var(--usjc-on-tint-info); }
.usjc-tint-neutral { background: var(--usjc-tint-neutral); color: var(--usjc-on-tint-neutral); }

.usjc-chevron { color: #9aa8bd; font-size: 13px; transition: transform 0.2s ease; }

/* ================================================================
   5. CONTROLES
   ================================================================ */
.usjc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--usjc-gap-2);
    min-height: 46px;
    padding: 0 22px;
    border-radius: var(--usjc-pill);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    border: 0;
    cursor: pointer;
}
.usjc-btn-dark { background: var(--usjc-navy); color: #fff; }
.usjc-btn-dark:hover, .usjc-btn-dark:focus { background: var(--usjc-navy-hover); color: #fff; }
.usjc-btn-primary { background: var(--usjc-primary); color: var(--usjc-navy); }
.usjc-btn-outline { background: var(--usjc-surface); color: var(--usjc-link); border: 1.5px solid #c9d6ff; }
.usjc-btn-block { width: 100%; }

/* Chips: filtros y pestañas en fila desplazable */
.usjc-chips {
    display: flex;
    gap: var(--usjc-gap-2);
    overflow-x: auto;
    padding: 2px 2px 6px;
    scrollbar-width: none;
}
.usjc-chips::-webkit-scrollbar { display: none; }
.usjc-chip {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 0 16px;
    border-radius: var(--usjc-pill);
    border: 1px solid var(--usjc-line-strong);
    background: var(--usjc-surface);
    color: var(--usjc-ink);
    display: inline-flex;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}
.usjc-chip.is-active,
.usjc-chip[aria-current] { background: var(--usjc-navy); border-color: var(--usjc-navy); color: #fff; }

/* Insignias de estado */
.usjc-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 22px;
    padding: 2px 10px;
    border-radius: var(--usjc-pill);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
}
.usjc-badge-success { background: var(--usjc-tint-success); color: var(--usjc-on-tint-success); }
.usjc-badge-warning { background: var(--usjc-tint-warning); color: var(--usjc-on-tint-warning); }
.usjc-badge-danger  { background: var(--usjc-tint-danger);  color: var(--usjc-on-tint-danger); }
.usjc-badge-info    { background: var(--usjc-tint-info);    color: var(--usjc-on-tint-info); }
.usjc-badge-primary { background: var(--usjc-tint-primary); color: var(--usjc-on-tint-primary); }
.usjc-badge-neutral { background: var(--usjc-tint-neutral); color: var(--usjc-on-tint-neutral); }
.usjc-badge-count   { background: #a3391b; color: #fff; min-width: 20px; justify-content: center; padding: 1px 7px; font-size: 11px; }

/* Avatar con iniciales */
.usjc-avatar {
    width: var(--usjc-touch); height: var(--usjc-touch); flex-shrink: 0;
    border: 0; border-radius: 50%;
    background: #ffd9a8; color: #7a4a10;
    font-weight: 700; font-size: 15px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0; cursor: pointer;
}
.usjc-avatar-lg { width: 52px; height: 52px; font-size: 17px; }

/* Estado vacío */
.usjc-empty {
    background: var(--usjc-surface);
    border-radius: 20px;
    padding: 28px 20px;
    text-align: center;
    color: var(--usjc-muted);
    font-size: 14px;
}
.usjc-empty i { display: block; font-size: 26px; margin-bottom: 10px; color: #9aa8bd; }

/* Fila "dato: valor" (detalle de un registro) */
.usjc-facts { background: var(--usjc-surface); border-radius: 20px; padding: 6px 16px; margin: 0; }
.usjc-facts > div { display: flex; justify-content: space-between; gap: var(--usjc-gap-3); padding: 10px 0; }
.usjc-facts > div + div { border-top: 1px solid #eef2f7; }
.usjc-facts dt { font-size: 13px; font-weight: 600; color: var(--usjc-muted); }
.usjc-facts dd { margin: 0; font-size: 14px; font-weight: 600; color: var(--usjc-ink); text-align: right; }

/* Acordeón propio (avisos) */
.usjc-news-toggle {
    margin-top: 14px; width: 100%; min-height: 60px;
    border: 0; border-radius: var(--usjc-radius-item);
    background: var(--usjc-surface);
    display: flex; align-items: center; gap: var(--usjc-gap-3);
    padding: 10px 14px; font-family: inherit; color: var(--usjc-ink);
}
.usjc-news-toggle[aria-expanded="true"] .usjc-chevron { transform: rotate(180deg); }
.usjc-news-list { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; }

/* ================================================================
   6. HORARIO SEMANAL
   ================================================================ */
.usjc-schedule-term { margin: 4px 0 0; }
.usjc-days {
    margin-top: var(--usjc-gap-3);
    display: grid;
    grid-template-columns: repeat(var(--usjc-days, 6), minmax(0, 1fr));
    gap: var(--usjc-gap-2);
}
.usjc-day {
    position: relative; height: 64px;
    border: 1px solid var(--usjc-line-strong); border-radius: 22px;
    background: transparent; color: var(--usjc-muted);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; padding: 0; font-family: inherit;
}
.usjc-day.has-class::before {
    content: ""; position: absolute; top: 7px;
    width: 5px; height: 5px; border-radius: 50%; background: var(--usjc-primary);
}
.usjc-day-name { font-size: 12px; }
.usjc-day-num { font-size: 16px; font-weight: 700; color: var(--usjc-ink); }
.usjc-day.is-selected { background: var(--usjc-navy); border-color: var(--usjc-navy); color: #fff; }
.usjc-day.is-selected .usjc-day-num { color: #fff; }
.usjc-day.is-selected.has-class::before { background: #fff; }
.usjc-schedule-body { margin-top: 14px; display: flex; flex-direction: column; gap: var(--usjc-gap-3); }
.usjc-class { border-radius: 24px; padding: 18px; }
.usjc-class-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.usjc-class-tags .usjc-chip-tag { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: var(--usjc-pill); background: rgba(255, 255, 255, 0.6); }
.usjc-class-name { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.25; color: inherit; }
.usjc-class-time { margin: 6px 0 0; font-size: 14px; }
.usjc-class-prof { margin: 12px 0 0; font-size: 12px; display: flex; flex-direction: column; }
.usjc-class-prof strong { font-size: 14px; }
.usjc-other-title { margin: 8px 0 0; font-weight: 600; }

/* ================================================================
   7. ESTRUCTURA DE LA APP (barra superior, pestañas, hoja inferior)
   ================================================================ */
.usjc-appbar {
    position: sticky; top: 0; z-index: 900;
    display: flex; align-items: center; gap: var(--usjc-gap-3);
    padding: calc(10px + var(--usjc-safe-top)) 16px 10px;
    background: rgba(244, 247, 251, 0.92);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}
.usjc-appbar.is-scrolled { border-bottom-color: var(--usjc-line); }
.usjc-appbar-logo { display: flex; width: var(--usjc-touch); height: var(--usjc-touch); align-items: center; justify-content: center; }
.usjc-appbar-logo img { width: 26px; height: auto; }
.usjc-appbar-back {
    width: 40px; height: 40px; flex: 0 0 auto; margin: 2px;
    border-radius: 50%;
    background: var(--usjc-surface); color: var(--usjc-ink);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 15px; text-decoration: none;
    box-shadow: 0 1px 2px rgba(15, 30, 69, 0.06), 0 4px 12px rgba(15, 30, 69, 0.06);
}
.usjc-appbar-back:hover, .usjc-appbar-back:focus { color: var(--usjc-ink); }
.usjc-appbar-back:active { transform: scale(0.94); }
.usjc-appbar-title {
    flex: 1; min-width: 0; text-align: center;
    font-size: 17px; font-weight: 700; color: var(--usjc-ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: opacity 0.2s ease;
}
/* Cuando la página tiene título grande visible, la barra oculta el suyo (estilo iOS) */
.usjc-appbar.has-large-title:not(.is-scrolled) .usjc-appbar-title { opacity: 0; }

.usjc-tabbar {
    position: fixed;
    left: 16px; right: 16px;
    bottom: calc(14px + var(--usjc-safe-bottom));
    z-index: 1000;
    max-width: 520px; margin: 0 auto;
    height: 66px; padding: 0 8px;
    border-radius: var(--usjc-pill);
    background: var(--usjc-navy);
    box-shadow: 0 12px 30px rgba(15, 30, 69, 0.25);
    display: flex; align-items: center; justify-content: space-between; gap: 4px;
}
.usjc-tab {
    flex: 0 0 auto; min-width: 50px; height: 50px; padding: 0 12px;
    border: 0; border-radius: var(--usjc-pill);
    background: transparent; color: #fff;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-size: 14px; font-weight: 700; text-decoration: none; cursor: pointer;
}
.usjc-tab i { font-size: 19px; }
.usjc-tab:hover, .usjc-tab:focus { color: #fff; }
.usjc-tab.is-active { background: #fff; color: var(--usjc-navy); padding: 0 18px; }
.usjc-tab:not(.is-active) span {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.usjc-tab:focus-visible { outline: 3px solid var(--usjc-focus); outline-offset: 2px; }

.usjc-sheet.offcanvas-bottom {
    height: auto; max-height: 85vh;
    border-radius: var(--usjc-radius-lg) var(--usjc-radius-lg) 0 0;
    padding-bottom: calc(16px + var(--usjc-safe-bottom));
    background: var(--usjc-bg);
    z-index: 1050;
}
.usjc-sheet-handle { width: 40px; height: 5px; border-radius: var(--usjc-pill); background: #cfd8e6; margin: 10px auto 0; }
.usjc-sheet .offcanvas-title { font-size: 16px; font-weight: 700; color: var(--usjc-ink); }

@media (prefers-reduced-motion: reduce) {
    .usjc-chevron, .usjc-appbar, .usjc-appbar-title { transition: none; }
}
