﻿/* Phase 4.3 — wrapped in @layer components to prevent cascade leakage */
@layer components {
/* ============================================
   FOOTER PROFESIONAL - TecsaS3
   Paleta: var(--tecsa-secondary), var(--tecsa-primary), var(--tecsa-primary), #134D6D, var(--tecsa-text)
   ============================================ */

:root {
    --footer-primary: #134D6D;
    --footer-secondary: var(--tecsa-primary);
    --footer-accent: var(--tecsa-primary);
    --footer-light: var(--tecsa-secondary);
    --footer-dark: var(--tecsa-text);
    --footer-height-collapsed: 40px;
    --footer-height-expanded: 100px;
    --footer-transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    /* R5 — altura reservada al ticker para que el glyph nunca quede recortado */
    --footer-ticker-height: 2.5rem;
}

/* ============================================
   FOOTER CONTAINER
   ============================================ */
.footer-professional {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1050;
    transition: var(--footer-transition);
}

.footer-professional.collapsed .footer-content {
    max-height: 0 !important;
    padding: 0 !important;
    opacity: 0 !important;
    overflow: hidden !important;
}

.footer-professional.collapsed .footer-toggle-icon {
    transform: rotate(180deg);
}

/* ============================================
   TOGGLE TAB (SOLAPA)
   ============================================ */
.footer-toggle {
    position: absolute;
    top: -32px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 32px;
    background: linear-gradient(135deg, var(--footer-primary) 0%, var(--footer-secondary) 100%);
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 -4px 12px rgba(19, 77, 109, 0.3);
    transition: var(--footer-transition);
    border: none;
    outline: none;
    z-index: 1051;
}

.footer-toggle:hover {
    background: linear-gradient(135deg, var(--footer-secondary) 0%, var(--footer-primary) 100%);
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 -6px 16px rgba(19, 77, 109, 0.4);
}

.footer-toggle:focus {
    outline: 2px solid var(--footer-light);
    outline-offset: 2px;
}

.footer-toggle-icon {
    color: #ffffff;
    font-size: 1rem;
    transition: transform 0.3s ease;
}

.footer-toggle-text {
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   FOOTER CONTENT
   ============================================ */
.footer-professional .footer-content {
    background: linear-gradient(135deg, var(--footer-dark) 0%, var(--footer-primary) 100%);
    /* max-height es border-box: la reserva del ticker debe SUMARSE aqui.
       Si solo se declara el padding-bottom, este encoge la caja util y el
       carril del ticker acaba recortado contra el borde de la pantalla. */
    max-height: calc(var(--footer-height-expanded) + var(--footer-ticker-height));
    padding: 8px 0;
    padding-bottom: var(--footer-ticker-height, 2.5rem);
    transition: var(--footer-transition);
    opacity: 1;
    overflow: hidden;
    box-shadow: 0 -4px 20px rgba(4, 42, 58, 0.4);
    display: block !important;
}

.footer-professional .footer-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex !important;
    flex-direction: column;
    gap: 6px;
}

/* ============================================
   STATS ROW
   ============================================ */
.footer-stats-row {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
}

.footer-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    backdrop-filter: blur(4px);
    transition: var(--footer-transition);
}

.footer-stat:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* Clickable footer stat link */
.footer-stat.footer-stat-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.footer-stat.footer-stat-link:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.footer-stat.footer-stat-link .footer-stat-icon {
    transition: transform 0.3s ease;
}

.footer-stat.footer-stat-link:hover .footer-stat-icon {
    transform: scale(1.1);
}

.footer-stat-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #ffffff;
}

.footer-stat-icon.patients {
    background: linear-gradient(135deg, #6CCB7A 0%, #51B968 100%);
}

.footer-stat-icon.families {
    background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
}

.footer-stat-icon.risk-high {
    background: linear-gradient(135deg, #FF6B6B 0%, #EE5A52 100%);
}

.footer-stat-icon.risk-medium {
    background: linear-gradient(135deg, #FFD93D 0%, #FFC312 100%);
}

.footer-stat-icon.risk-low {
    background: linear-gradient(135deg, #6CCB7A 0%, #51B968 100%);
}

.footer-stat-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.footer-stat-value {
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
}

.footer-stat-label {
    color: var(--footer-light);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   TICKER (NEWS FEED)
   ============================================ */
.footer-professional .footer-ticker-wrapper {
    width: 100%;
    overflow: hidden;
    position: relative;
    height: 50px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 15px;
    display: flex !important;
    align-items: center;
}

.footer-professional .footer-ticker-label {
    flex-shrink: 0;
    padding: 0 12px;
    background: linear-gradient(135deg, var(--footer-secondary) 0%, var(--footer-accent) 100%);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    height: 100%;
    display: flex;
    align-items: center;
    border-radius: 15px 0 0 15px;
    z-index: 2;
}

.footer-professional .footer-ticker-label i {
    margin-right: 6px;
}

.footer-professional .footer-ticker-content {
    flex: 1;
    overflow: hidden;
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
    min-height: 1.75rem; /* asegure una línea visible aunque no haya items */
    padding-bottom: 0.25rem; /* breathing para el glyph descender */
}

.footer-professional .footer-ticker {
    display: flex !important;
    width: max-content;
    white-space: nowrap;
    /* La duración la fija scripts.js según el ancho del contenido para lograr
       una velocidad CONSTANTE (px/seg) estilo ticker bursátil, sin importar
       cuántas noticias haya. El 40s es solo fallback antes de que corra el JS. */
    animation: footerTicker var(--footer-ticker-duration, 40s) linear infinite;
    will-change: transform;
    /* El padre es flex: sin esto el ticker se encogeria al ancho del carril y
       el marquee (width: max-content + translateX(-50%)) dejaria de cuadrar. */
    flex-shrink: 0;
}

/* Cada grupo es una copia idéntica del contenido; el segundo (aria-hidden)
   permite un loop continuo sin salto al desplazar -50%. */
.footer-professional .footer-ticker-group {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.footer-professional .footer-ticker:hover,
.footer-professional .footer-ticker.is-paused {
    animation-play-state: paused;
}

/* Fallback estático (reduced motion / sin JS): contenido desplazable a mano */
.footer-professional .footer-ticker.is-static {
    animation: none;
}

.footer-professional .footer-ticker-content:has(.footer-ticker.is-static) {
    overflow-x: auto;
    scrollbar-width: thin;
}

.footer-professional .footer-ticker-item {
    display: inline-flex !important;
    align-items: center;
    padding: 0 20px;
    color: #ffffff;
    font-size: 0.85rem;
    line-height: 1.7;
    /* Sube el texto un poco dentro del carril (el grupo centra la caja de
       margen) y deja aire para descendentes y el subrayado punteado. */
    margin-bottom: 0.25rem;
    gap: 8px;
    vertical-align: middle;
}

.footer-professional .footer-ticker-item span {
    color: #ffffff;
}

.footer-professional .footer-ticker-item a {
    color: #ffffff;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
    text-decoration-color: rgba(255, 255, 255, 0.45);
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.footer-professional .footer-ticker-item a:hover,
.footer-professional .footer-ticker-item a:focus-visible {
    color: var(--footer-light);
    text-decoration-style: solid;
    text-decoration-color: currentColor;
}

/* Icono de enlace externo: indica que la noticia es clickeable y abre en nueva pestaña. */
.footer-professional .footer-ticker-item .footer-ticker-external {
    font-size: 0.6rem;
    margin-left: 4px;
    opacity: 0.7;
}

.footer-professional .footer-ticker-separator {
    color: var(--footer-accent);
    font-weight: bold;
    margin: 0 4px;
}

.footer-professional .footer-ticker-badge {
    /* Reset defensivo: footer.css vive en @layer components y una clase de
       componente Bootstrap sin capa (p. ej. .alert) ganaria pese a la
       especificidad, inflando el badge y arrastrando todo el ticker. */
    margin: 0;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.footer-professional .footer-ticker-badge.news {
    background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
    color: #ffffff;
}

.footer-professional .footer-ticker-badge.stat {
    background: linear-gradient(135deg, #6CCB7A 0%, #51B968 100%);
    color: #ffffff;
}

.footer-professional .footer-ticker-badge.is-alert {
    background: linear-gradient(135deg, #FF6B6B 0%, #EE5A52 100%);
    color: #ffffff;
}

/* translate3d: fuerza compositing en GPU (sin repaints por frame) */
@keyframes footerTicker {
    from {
        transform: translate3d(0, 0, 0);
    }
    to {
        transform: translate3d(-50%, 0, 0);
    }
}

/* ============================================
   COPYRIGHT
   ============================================ */
.footer-copyright {
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.7rem;
    padding-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-copyright a {
    color: var(--footer-light);
    text-decoration: none;
    font-weight: 600;
}

.footer-copyright a:hover {
    color: #ffffff;
    text-decoration: underline;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 992px) {
    .footer-stats-row {
        gap: 12px;
    }

    .footer-stat {
        padding: 4px 10px;
    }

    .footer-stat-icon {
        width: 24px;
        height: 24px;
        font-size: 0.7rem;
    }

    .footer-stat-value {
        font-size: 0.9rem;
    }
}

@media (max-width: 768px) {
    /* Prefijado con .footer-professional: sin el prefijo estos overrides
       (0,1,0) perdian contra las reglas base (0,2,0) y eran codigo muerto. */
    .footer-professional .footer-content {
        max-height: calc(120px + var(--footer-ticker-height));
    }

    .footer-stats-row {
        gap: 8px;
        justify-content: center;
    }

    .footer-stat {
        padding: 3px 8px;
    }

    .footer-stat-label {
        display: none;
    }

    .footer-ticker-label span {
        display: none;
    }

    .footer-professional .footer-ticker-item {
        font-size: 0.75rem;
        padding: 0 16px;
    }

    .footer-toggle {
        width: 60px;
        height: 28px;
        top: -28px;
    }

    .footer-toggle-text {
        display: none;
    }
}

@media (max-width: 576px) {
    .footer-stats-row {
        display: none;
    }

    /* Sin .footer-stats-row, el contenido es carril + copyright: la reserva
       del ticker sigue sumandose para no recortar el carril. */
    .footer-professional .footer-content {
        max-height: calc(60px + var(--footer-ticker-height));
        padding: 6px 0;
        padding-bottom: var(--footer-ticker-height, 2.5rem);
    }

    .footer-professional .footer-ticker-wrapper {
        height: 26px;
        border-radius: 13px;
    }

    /* El carril baja a 26px: el respiro del texto se escala con el, o el
       item sobresaldria por arriba (medido: -1px) y quedaria recortado. */
    .footer-professional .footer-ticker-content {
        padding-bottom: 0.125rem;
    }

    .footer-professional .footer-ticker-item {
        font-size: 0.75rem;
        line-height: 1.5;
        padding: 0 12px;
        margin-bottom: 0.125rem;
    }

    .footer-professional .footer-ticker-badge {
        padding: 2px 6px;
        font-size: 0.6rem;
    }

    .footer-copyright {
        font-size: 0.6rem;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .footer-ticker {
        animation: none;
    }

    .footer-ticker-content {
        overflow-x: auto;
        scrollbar-width: thin;
    }

    .footer-toggle,
    .footer-stat,
    .footer-content {
        transition: none;
    }

    .footer-ticker-wrapper::after,
    .footer-ticker-badge.is-alert {
        animation: none !important;
    }
}

/* Preferencia de app (atributo que fija base.html según media query) */
html[data-reduced-motion] .footer-ticker {
    animation: none;
}

html[data-reduced-motion] .footer-ticker-content {
    overflow-x: auto;
    scrollbar-width: thin;
}

html[data-reduced-motion] .footer-ticker-wrapper::after,
html[data-reduced-motion] .footer-ticker-badge.is-alert {
    animation: none !important;
}

/* ============================================
   BODY PADDING ADJUSTMENT
   ============================================ */
body {
    padding-bottom: calc(var(--footer-height-expanded) + var(--footer-ticker-height) + 10px);
}

body.footer-collapsed {
    padding-bottom: 50px;
}

#content-wrapper {
    padding-bottom: 20px;
}

/* ============================================
   OVERRIDE TRICORDER (scoped) — glass + glow + efectos video_dashboard
   Solo bajo html[data-app-theme="tricorder"]; el look legacy se conserva.
   ============================================ */
html[data-app-theme="tricorder"] .footer-professional .footer-content {
    background: var(--tricorder-card-bg, linear-gradient(145deg, rgba(10, 22, 40, 0.96) 0%, rgba(20, 40, 60, 0.92) 100%));
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    border-top: 1px solid var(--tricorder-border-soft, rgba(0, 229, 255, 0.15));
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
    position: relative;
}

/* Hairline glow superior (igual que video_dashboard / dashboard-header) */
html[data-app-theme="tricorder"] .footer-professional .footer-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--tricorder-primary, #00E5FF) 50%, transparent);
    opacity: 0.55;
    pointer-events: none;
}

html[data-app-theme="tricorder"] .footer-toggle {
    background: linear-gradient(135deg, var(--tricorder-secondary, #00B8D4) 0%, var(--tricorder-primary, #00E5FF) 100%);
    box-shadow: 0 -4px 14px rgba(0, 229, 255, 0.3);
    color: var(--tricorder-dark, #0A1628);
}

html[data-app-theme="tricorder"] .footer-toggle:hover {
    box-shadow: 0 -6px 18px rgba(0, 229, 255, 0.5);
}

html[data-app-theme="tricorder"] .footer-toggle-icon,
html[data-app-theme="tricorder"] .footer-toggle-text {
    color: var(--tricorder-dark, #0A1628);
}

/* Stat chips: glass cyan + hover lift/glow */
html[data-app-theme="tricorder"] .footer-stat {
    background: rgba(0, 229, 255, 0.06);
    border: 1px solid var(--tricorder-border-soft, rgba(0, 229, 255, 0.15));
}

html[data-app-theme="tricorder"] .footer-stat.footer-stat-link:hover {
    background: rgba(0, 229, 255, 0.14);
    border-color: var(--tricorder-border, rgba(0, 229, 255, 0.3));
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4), 0 0 14px rgba(0, 229, 255, 0.2);
}

html[data-app-theme="tricorder"] .footer-stat-value {
    color: var(--tricorder-text, #E0F7FA);
    font-variant-numeric: tabular-nums;
}

html[data-app-theme="tricorder"] .footer-stat-label {
    color: var(--tricorder-muted, #82B4C7);
}

/* Ticker tricorder */
html[data-app-theme="tricorder"] .footer-professional .footer-ticker-wrapper {
    background: rgba(5, 14, 26, 0.55);
    border: 1px solid var(--tricorder-border-soft, rgba(0, 229, 255, 0.15));
}

html[data-app-theme="tricorder"] .footer-professional .footer-ticker-label {
    background: linear-gradient(135deg, var(--tricorder-secondary, #00B8D4) 0%, var(--tricorder-primary, #00E5FF) 100%);
    color: var(--tricorder-dark, #0A1628);
}

html[data-app-theme="tricorder"] .footer-professional .footer-ticker-item span,
html[data-app-theme="tricorder"] .footer-professional .footer-ticker-item a {
    color: var(--tricorder-text, #E0F7FA);
}

html[data-app-theme="tricorder"] .footer-professional .footer-ticker-item a:hover {
    color: var(--tricorder-primary, #00E5FF);
}

html[data-app-theme="tricorder"] .footer-professional .footer-ticker-separator {
    color: var(--tricorder-primary, #00E5FF);
    opacity: 0.6;
}

html[data-app-theme="tricorder"] .footer-professional .footer-ticker-badge.news {
    background: rgba(64, 196, 255, 0.18);
    color: var(--tricorder-info, #40C4FF);
    border: 1px solid rgba(64, 196, 255, 0.3);
}

html[data-app-theme="tricorder"] .footer-professional .footer-ticker-badge.stat {
    background: rgba(0, 191, 165, 0.18);
    color: var(--tricorder-success, #00BFA5);
    border: 1px solid rgba(0, 191, 165, 0.3);
}

html[data-app-theme="tricorder"] .footer-professional .footer-ticker-badge.is-alert {
    background: rgba(255, 82, 82, 0.18);
    color: var(--tricorder-danger, #FF5252);
    border: 1px solid rgba(255, 82, 82, 0.3);
}

html[data-app-theme="tricorder"] .footer-copyright {
    color: var(--tricorder-muted, #82B4C7);
    border-top: 1px solid var(--tricorder-border-soft, rgba(0, 229, 255, 0.15));
}

html[data-app-theme="tricorder"] .footer-copyright a {
    color: var(--tricorder-primary, #00E5FF);
}

/* ============================================
   TICKER FUTURISTA (efectos especiales tricorder)
   ============================================ */

/* Edge fade: las noticias emergen/desvanecen en los bordes del carril */
html[data-app-theme="tricorder"] .footer-professional .footer-ticker-content {
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}

/* Barrido scanline: barra cian fina cruzando el carril cada ~8s */
html[data-app-theme="tricorder"] .footer-professional .footer-ticker-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -15%;
    width: 12%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(0, 229, 255, 0.12) 40%,
        rgba(0, 229, 255, 0.22) 50%,
        rgba(0, 229, 255, 0.12) 60%,
        transparent
    );
    pointer-events: none;
    animation: tickerScan 8s var(--ease-out-quart, ease-out) infinite;
    z-index: 1;
}

@keyframes tickerScan {
    0% { transform: translate3d(0, 0, 0); }
    55%, 100% { transform: translate3d(1000%, 0, 0); }
}

/* Badge de alerta con pulso rojo (latido de urgencia) */
html[data-app-theme="tricorder"] .footer-professional .footer-ticker-badge.is-alert {
    animation: tickerAlertPulse 2.4s ease-in-out infinite;
}

@keyframes tickerAlertPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 82, 82, 0); }
    50% { box-shadow: 0 0 10px 1px rgba(255, 82, 82, 0.45); }
}

/* Glow del texto al pasar el mouse o enfocar con teclado */
html[data-app-theme="tricorder"] .footer-professional .footer-ticker-item a:hover,
html[data-app-theme="tricorder"] .footer-professional .footer-ticker-item a:focus-visible {
    text-shadow: 0 0 12px rgba(0, 229, 255, 0.6);
}

/* LED "en vivo" en la etiqueta Noticias */
html[data-app-theme="tricorder"] .footer-professional .footer-ticker-label i {
    animation: tickerLedPulse 2s ease-in-out infinite;
}

@keyframes tickerLedPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

} /* end @layer components */
