/* ============================================================
   MEDIPLUS — ANIMATIONS & TRANSITIONS
   ============================================================ */

/* ── FADE IN ────────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInLeft {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes fadeInRight {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

@keyframes slideInUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ── COUNTER ANIMATION ──────────────────────────────────────── */
@keyframes countUp {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ── PULSE ──────────────────────────────────────────────────── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.4); }
}

/* ── BOUNCE ─────────────────────────────────────────────────── */
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

/* ── SPIN ───────────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── PAGE ENTER ─────────────────────────────────────────────── */
.page-enter {
  animation: fadeInUp 0.35s ease forwards;
}

/* ── STAGGER CHILDREN ───────────────────────────────────────── */
.stagger-children > * {
  animation: fadeInUp 0.3s ease forwards;
  opacity: 0;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.10s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.20s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.30s; }
.stagger-children > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-children > *:nth-child(8) { animation-delay: 0.40s; }

/* ── KPI CARD ENTRANCE ──────────────────────────────────────── */
.kpi-card {
  animation: fadeInUp 0.4s ease forwards;
  opacity: 0;
}

.kpi-card:nth-child(1) { animation-delay: 0.05s; }
.kpi-card:nth-child(2) { animation-delay: 0.10s; }
.kpi-card:nth-child(3) { animation-delay: 0.15s; }
.kpi-card:nth-child(4) { animation-delay: 0.20s; }
.kpi-card:nth-child(5) { animation-delay: 0.25s; }

/* ── HOVER LIFT ─────────────────────────────────────────────── */
.hover-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.hover-lift:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

/* ── LIVE INDICATOR ─────────────────────────────────────────── */
.live-dot {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-green);
}

.live-dot::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-green);
  animation: pulseDot 1.5s ease infinite;
}

/* ── NUMBER COUNTER ─────────────────────────────────────────── */
.counter-value {
  display: inline-block;
  animation: countUp 0.5s ease forwards;
}

/* ── RIPPLE EFFECT ──────────────────────────────────────────── */
.btn {
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background 0.3s ease;
}

.btn:active::after {
  background: rgba(255,255,255,0.15);
}

/* ── CARD SHINE ─────────────────────────────────────────────── */
@keyframes shine {
  from { background-position: -200% center; }
  to   { background-position: 200% center; }
}

.card-shine {
  background: linear-gradient(
    105deg,
    transparent 40%,
    rgba(255,255,255,0.3) 50%,
    transparent 60%
  );
  background-size: 200% auto;
  animation: shine 3s linear infinite;
}

/* ── STATUS PULSE (for live data) ────────────────────────────── */
.status-live {
  position: relative;
}

.status-live::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 8px;
  background: var(--color-green);
  border-radius: 50%;
  border: 2px solid white;
  animation: pulseDot 2s infinite;
}

/* ── LOADING OVERLAY ────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  backdrop-filter: blur(4px);
}

.loading-logo {
  font-size: 32px;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -1px;
  margin-bottom: var(--space-4);
  animation: pulse 1.5s ease infinite;
}

.loading-bar {
  width: 200px;
  height: 3px;
  background: var(--color-gray-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-teal));
  border-radius: var(--radius-full);
  animation: loadingBar 1.5s ease infinite;
}

@keyframes loadingBar {
  0%   { width: 0%; margin-left: 0; }
  50%  { width: 60%; margin-left: 20%; }
  100% { width: 0%; margin-left: 100%; }
}

/* ── REDUCE MOTION ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}