/* ==========================================================================
   ANIMACIONES GLOBALES - Portal Paciente
   Hospital Área Programa Cinco Saltos
   Desarrollado por: Lic. Villarruel Ezequiel © 2025
   ========================================================================== */

/* ─── VARIABLES ─────────────────────────────────────────────────────────── */
:root {
    --anim-fast:    0.18s;
    --anim-normal:  0.32s;
    --anim-slow:    0.55s;
    --anim-ease:    cubic-bezier(0.4, 0, 0.2, 1);
    --anim-spring:  cubic-bezier(0.34, 1.56, 0.64, 1);
    --anim-smooth:  cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --blue:         #0055A4;
    --blue-dark:    #003d7a;
    --green-wa:     #25d366;
}

/* ─── KEYFRAMES ─────────────────────────────────────────────────────────── */

/* Entrada desde abajo con fade */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Entrada desde arriba */
@keyframes fadeDown {
    from { opacity: 0; transform: translateY(-24px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Fade simple */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Entrada desde izquierda */
@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Entrada desde derecha */
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Escala desde el centro (modal pop) */
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.88); }
    to   { opacity: 1; transform: scale(1); }
}

/* Escala con spring */
@keyframes popIn {
    from { opacity: 0; transform: scale(0.7); }
    60%  { transform: scale(1.05); }
    to   { opacity: 1; transform: scale(1); }
}

/* Pulso suave para badges/contadores */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.06); }
}

/* Shimmer para skeleton loaders */
@keyframes shimmer {
    0%   { background-position: -600px 0; }
    100% { background-position:  600px 0; }
}

/* Rotación para spinners */
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Onda de ripple en botones */
@keyframes ripple {
    to { transform: scale(4); opacity: 0; }
}

/* Latido para ícono de WhatsApp / alertas */
@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    14%       { transform: scale(1.15); }
    28%       { transform: scale(1); }
    42%       { transform: scale(1.12); }
    70%       { transform: scale(1); }
}

/* Barra de carga (progress top) */
@keyframes loadBar {
    from { width: 0%; }
    to   { width: 100%; }
}

/* Parpadeo suave para indicadores activos */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* Entrada de la navbar desde arriba */
@keyframes navbarSlide {
    from { opacity: 0; transform: translateY(-100%); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Counter animado */
@keyframes countUp {
    from { opacity: 0; transform: translateY(10px) scale(0.8); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* Flotar */
@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50%       { transform: translateY(-8px); }
}

/* Deslizar entrada de filas de tabla */
@keyframes rowIn {
    from { opacity: 0; transform: translateX(-12px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Flash de éxito (alertas) */
@keyframes flashSuccess {
    0%   { background: #d4edda; }
    50%  { background: #a8e6c0; }
    100% { background: #d4edda; }
}

/* ─── CLASES DE UTILIDAD ─────────────────────────────────────────────────── */

/* Página completa */
.anim-page {
    animation: fadeIn var(--anim-normal) var(--anim-ease);
}

/* Navbar */
.anim-navbar {
    animation: navbarSlide var(--anim-normal) var(--anim-ease);
}

/* Cards staggered */
.anim-card {
    opacity: 0;
    animation: fadeUp var(--anim-slow) var(--anim-spring) forwards;
}
.anim-card:nth-child(1) { animation-delay: 0.05s; }
.anim-card:nth-child(2) { animation-delay: 0.12s; }
.anim-card:nth-child(3) { animation-delay: 0.19s; }
.anim-card:nth-child(4) { animation-delay: 0.26s; }
.anim-card:nth-child(5) { animation-delay: 0.33s; }
.anim-card:nth-child(6) { animation-delay: 0.40s; }
.anim-card:nth-child(7) { animation-delay: 0.47s; }
.anim-card:nth-child(8) { animation-delay: 0.54s; }

/* Stats individuales */
.anim-stat {
    opacity: 0;
    animation: popIn var(--anim-slow) var(--anim-spring) forwards;
}
.anim-stat:nth-child(1) { animation-delay: 0.08s; }
.anim-stat:nth-child(2) { animation-delay: 0.16s; }
.anim-stat:nth-child(3) { animation-delay: 0.24s; }
.anim-stat:nth-child(4) { animation-delay: 0.32s; }

/* Secciones */
.anim-section {
    opacity: 0;
    animation: fadeUp var(--anim-slow) var(--anim-smooth) forwards;
}
.anim-section:nth-child(1) { animation-delay: 0.10s; }
.anim-section:nth-child(2) { animation-delay: 0.20s; }
.anim-section:nth-child(3) { animation-delay: 0.30s; }
.anim-section:nth-child(4) { animation-delay: 0.40s; }
.anim-section:nth-child(5) { animation-delay: 0.50s; }
.anim-section:nth-child(6) { animation-delay: 0.60s; }
.anim-section:nth-child(7) { animation-delay: 0.70s; }

/* Filas de tabla */
.anim-row {
    opacity: 0;
    animation: rowIn var(--anim-normal) var(--anim-ease) forwards;
}
/* JS agrega delay inline */

/* Modal */
.anim-modal {
    animation: scaleIn var(--anim-normal) var(--anim-spring);
}

/* ─── EFECTOS HOVER GLOBALES ─────────────────────────────────────────────── */

/* Botones con ripple */
.btn-ripple {
    position: relative;
    overflow: hidden;
}
.btn-ripple .ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.35);
    width: 10px; height: 10px;
    animation: ripple 0.6s linear;
    pointer-events: none;
    transform: scale(0);
}

/* Lift en hover */
.hover-lift {
    transition: transform var(--anim-fast) var(--anim-spring),
                box-shadow var(--anim-fast) var(--anim-ease);
    cursor: pointer;
}
.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0,85,164,0.18) !important;
}

/* Glow en hover */
.hover-glow {
    transition: box-shadow var(--anim-normal) var(--anim-ease);
}
.hover-glow:hover {
    box-shadow: 0 0 0 3px rgba(0,85,164,0.25), 0 8px 20px rgba(0,85,164,0.12);
}

/* ─── BARRA DE PROGRESO TOP ──────────────────────────────────────────────── */
.page-loader {
    position: fixed;
    top: 0; left: 0;
    width: 0%; height: 3px;
    background: linear-gradient(90deg, var(--blue), #00c6ff, var(--blue));
    background-size: 200% 100%;
    z-index: 9999;
    animation: loadBar 0.8s var(--anim-smooth) forwards,
               shimmer 1.2s linear infinite;
    border-radius: 0 2px 2px 0;
    box-shadow: 0 0 10px rgba(0,85,164,0.5);
}

/* ─── SKELETON LOADER ────────────────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 600px 100%;
    animation: shimmer 1.4s infinite;
    border-radius: 6px;
}

/* ─── TOAST / NOTIFICACIONES ─────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 80px; right: 20px;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast {
    background: white;
    border-radius: 12px;
    padding: 14px 18px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 600;
    min-width: 260px;
    max-width: 380px;
    pointer-events: all;
    animation: slideInRight var(--anim-normal) var(--anim-spring);
    border-left: 4px solid var(--blue);
    position: relative;
    overflow: hidden;
}
.toast::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0;
    height: 3px;
    background: var(--blue);
    animation: loadBar 4s linear forwards;
    width: 0;
}
.toast.success { border-left-color: #28a745; }
.toast.success::after { background: #28a745; }
.toast.error   { border-left-color: #dc3545; }
.toast.error::after   { background: #dc3545; }
.toast.warning { border-left-color: #fd7e14; }
.toast.warning::after { background: #fd7e14; }
.toast i { font-size: 20px; flex-shrink: 0; }
.toast.success i { color: #28a745; }
.toast.error   i { color: #dc3545; }
.toast.warning i { color: #fd7e14; }
.toast-exit {
    animation: slideInRight var(--anim-normal) var(--anim-ease) reverse forwards;
}

/* ─── ANIMACIÓN NÚMEROS ──────────────────────────────────────────────────── */
.anim-number {
    animation: countUp var(--anim-slow) var(--anim-spring);
}

/* ─── WHATSAPP PULSE ─────────────────────────────────────────────────────── */
.wa-pulse {
    animation: heartbeat 2s ease-in-out infinite;
}

/* ─── FLOATING ACTION ────────────────────────────────────────────────────── */
.anim-float {
    animation: float 3s ease-in-out infinite;
}

/* ─── FOCUS RING ─────────────────────────────────────────────────────────── */
input:focus, select:focus, textarea:focus {
    transition: border-color var(--anim-fast) var(--anim-ease),
                box-shadow var(--anim-fast) var(--anim-ease) !important;
    outline: none;
}

/* ─── TRANSITIONS GLOBALES ───────────────────────────────────────────────── */
a, button {
    transition: all var(--anim-fast) var(--anim-ease);
}
