/**
 * ═══════════════════════════════════════════════════════════════════════════════
 * KAIRO WELCOME DASHBOARD STYLES
 * Beautiful landing page with loading animations and quick stats
 * ═══════════════════════════════════════════════════════════════════════════════
 */

/* ═══════════════════════════════════════════════════════════════════════════════
   LOADING OVERLAY
   ═══════════════════════════════════════════════════════════════════════════════ */

.kairo-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0a0a12 0%, #12121f 50%, #0a0a12 100%);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.kairo-loading-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
}

.kairo-loading-logo {
  width: 120px;
  height: 120px;
  margin-bottom: 30px;
  animation: logo-pulse-glow 2s ease-in-out infinite;
}

.kairo-loading-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 30px rgba(99, 102, 241, 0.5));
}

@keyframes logo-pulse-glow {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 0 30px rgba(99, 102, 241, 0.5));
  }
  50% {
    transform: scale(1.05);
    filter: drop-shadow(0 0 50px rgba(99, 102, 241, 0.8));
  }
}

.kairo-loading-title {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 8px;
  background: linear-gradient(135deg, var(--indigo-500), var(--violet-500), var(--purple-500));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.kairo-loading-subtitle {
  font-size: 14px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 40px;
}

.kairo-loading-progress {
  width: 280px;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 20px;
}

.kairo-loading-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--indigo-500), var(--violet-500), var(--purple-500));
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
}

.kairo-loading-status {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.4);
  min-height: 20px;
}

.kairo-loading-dots {
  display: inline-flex;
  gap: 4px;
  margin-left: 8px;
}

.kairo-loading-dots span {
  width: 4px;
  height: 4px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  animation: dot-bounce 1.4s ease-in-out infinite both;
}

.kairo-loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.kairo-loading-dots span:nth-child(2) { animation-delay: -0.16s; }
.kairo-loading-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes dot-bounce {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   WELCOME PAGE
   ═══════════════════════════════════════════════════════════════════════════════ */

.welcome-page {
  padding: 40px;
  min-height: calc(100vh - 80px);
  background:
    radial-gradient(ellipse at top, var(--gradient-mesh-1, rgba(99, 102, 241, 0.08)) 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, var(--gradient-mesh-2, rgba(139, 92, 246, 0.05)) 0%, transparent 50%);
  background-size: 100% 100%;
  animation: page-gradient-shift 20s ease-in-out infinite;
}

@keyframes page-gradient-shift {
  0%, 100% { background-position: 0% 0%, 100% 100%; }
  50% { background-position: 100% 100%, 0% 0%; }
}

/* Hero Section */
.welcome-hero {
  display: flex;
  align-items: center;
  gap: 40px;
  margin-bottom: 50px;
  padding: 40px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.05) 100%);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 24px;
  position: relative;
  overflow: hidden;
}

.welcome-hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

/* Animated mesh gradient overlay */
.welcome-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 50%, var(--gradient-mesh-1, rgba(99, 102, 241, 0.15)) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, var(--gradient-mesh-2, rgba(139, 92, 246, 0.12)) 0%, transparent 50%),
    radial-gradient(circle at 60% 80%, var(--gradient-mesh-3, rgba(6, 182, 212, 0.10)) 0%, transparent 50%);
  background-size: 200% 200%;
  animation: mesh-drift 12s ease-in-out infinite;
  pointer-events: none;
  border-radius: 24px;
  z-index: 0;
}

@keyframes mesh-drift {
  0%, 100% { background-position: 0% 0%, 100% 0%, 50% 100%; }
  33% { background-position: 100% 50%, 0% 100%, 80% 20%; }
  66% { background-position: 50% 100%, 50% 0%, 0% 50%; }
}

/* Hero content above gradient */
.welcome-hero-content,
.welcome-hero-logo,
.welcome-hero-date {
  position: relative;
  z-index: 1;
}

.welcome-hero-logo {
  width: 140px;
  height: 140px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 40px rgba(99, 102, 241, 0.4));
  animation: float 6s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

.welcome-hero-content {
  flex: 1;
  position: relative;
  z-index: 1;
}

.welcome-hero-greeting {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 8px;
}

.welcome-hero-title {
  font-size: 42px;
  font-weight: 800;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #ffffff 0%, rgba(255, 255, 255, 0.8) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-hero-brand {
  font-size: 20px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--indigo-500), var(--violet-500));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}

.welcome-hero-description {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.6;
  max-width: 500px;
}

.welcome-hero-date {
  position: absolute;
  top: 30px;
  right: 40px;
  text-align: right;
  color: rgba(255, 255, 255, 0.4);
  font-size: 13px;
}

.welcome-hero-date-day {
  font-size: 48px;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, var(--indigo-500), var(--violet-500));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Stats Bento Grid */
.welcome-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: auto;
  gap: 20px;
  margin-bottom: 40px;
}

/* First stat card spans 2 columns for visual hierarchy */
.welcome-stat-card.patients {
  grid-column: span 2;
}

.welcome-stat-card.patients .welcome-stat-value {
  font-size: 48px;
  font-variation-settings: 'wght' 800, 'opsz' 32;
}

.welcome-stat-card.patients .welcome-stat-icon {
  width: 56px;
  height: 56px;
  font-size: 28px;
  border-radius: 16px;
}

.welcome-stat-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 24px;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.welcome-stat-card:hover {
  transform: translateY(-4px);
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

/* Animated gradient top stripe */
.welcome-stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--stat-color, linear-gradient(90deg, var(--gradient-border-from, var(--indigo-500)), var(--gradient-border-to, var(--violet-500))));
  background-size: 200% 100%;
  opacity: 0;
  transition: opacity 0.3s;
  animation: gradient-slide 3s linear infinite paused;
}

.welcome-stat-card:hover::before {
  opacity: 1;
  animation-play-state: running;
}

@keyframes gradient-slide {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

/* Animated gradient glow on hover */
.welcome-stat-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    var(--gradient-mesh-1, rgba(99, 102, 241, 0.06)) 0%,
    transparent 40%,
    transparent 60%,
    var(--gradient-mesh-3, rgba(6, 182, 212, 0.04)) 100%
  );
  background-size: 200% 200%;
  opacity: 0;
  transition: opacity 0.4s ease;
  animation: card-glow-drift 6s ease-in-out infinite;
  pointer-events: none;
}

.welcome-stat-card:hover::after {
  opacity: 1;
}

@keyframes card-glow-drift {
  0%, 100% { background-position: 0% 0%; }
  50% { background-position: 100% 100%; }
}

.welcome-stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 16px;
  background: var(--stat-bg, rgba(99, 102, 241, 0.15));
}

.welcome-stat-card.patients .welcome-stat-icon {
  --stat-bg: rgba(99, 102, 241, 0.15);
}
.welcome-stat-card.patients { --stat-color: linear-gradient(90deg, var(--indigo-500), #818cf8); }

.welcome-stat-card.scans .welcome-stat-icon {
  --stat-bg: rgba(139, 92, 246, 0.15);
}
.welcome-stat-card.scans { --stat-color: linear-gradient(90deg, var(--violet-500), var(--violet-400)); }

.welcome-stat-card.today .welcome-stat-icon {
  --stat-bg: rgba(34, 197, 94, 0.15);
}
.welcome-stat-card.today { --stat-color: linear-gradient(90deg, var(--green-500), var(--green-400)); }

.welcome-stat-card.analyses .welcome-stat-icon {
  --stat-bg: rgba(249, 115, 22, 0.15);
}
.welcome-stat-card.analyses { --stat-color: linear-gradient(90deg, var(--orange-500), var(--orange-400)); }

.welcome-stat-value {
  font-size: 36px;
  font-weight: 800;
  font-variation-settings: 'wght' 800, 'opsz' 32;
  color: white;
  line-height: 1;
  margin-bottom: 4px;
  transition: font-variation-settings 0.3s ease;
}

/* Tactile weight shift on hover */
.welcome-stat-card:hover .welcome-stat-value {
  font-variation-settings: 'wght' 900, 'opsz' 32;
}

.welcome-stat-label {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.welcome-stat-change {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 20px;
  background: rgba(34, 197, 94, 0.15);
  color: var(--green-400);
}

.welcome-stat-change.negative {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red-400);
}

/* Main Content Bento Grid */
.welcome-grid {
  display: grid;
  grid-template-columns: 5fr 3fr;
  gap: 24px;
}

/* Recent patients section - contained scroll */
.welcome-grid .welcome-section:last-child .welcome-activity-list {
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: thin;
}

/* Quick Actions */
.welcome-section {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 20px;
  padding: 28px;
}

.welcome-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.welcome-section-title {
  font-size: 16px;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
}

.welcome-section-title span {
  font-size: 18px;
}

.welcome-section-link {
  font-size: 13px;
  color: var(--indigo-500);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.welcome-section-link:hover {
  color: #818cf8;
}

/* Quick Actions Bento Grid */
.welcome-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: auto auto;
  gap: 16px;
}

/* Primary CTA spans 2 columns */
.welcome-action-card:first-child {
  grid-column: span 2;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(139, 92, 246, 0.05) 100%);
  border-color: rgba(99, 102, 241, 0.15);
  padding: 28px;
}

.welcome-action-card:first-child .welcome-action-icon {
  width: 56px;
  height: 56px;
  font-size: 24px;
  border-radius: 16px;
}

.welcome-action-card:first-child .welcome-action-title {
  font-size: 17px;
}

.welcome-action-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.welcome-action-card:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.2);
  transform: translateY(-2px);
}

.welcome-action-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.welcome-action-icon.scan { background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2)); }
.welcome-action-icon.patient { background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(74, 222, 128, 0.2)); }
.welcome-action-icon.analysis { background: linear-gradient(135deg, rgba(249, 115, 22, 0.2), rgba(251, 146, 60, 0.2)); }
.welcome-action-icon.healing { background: linear-gradient(135deg, rgba(236, 72, 153, 0.2), rgba(244, 114, 182, 0.2)); }

.welcome-action-content {
  flex: 1;
  min-width: 0;
}

.welcome-action-title {
  font-size: 15px;
  font-weight: 600;
  color: white;
  margin-bottom: 4px;
}

.welcome-action-desc {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  line-height: 1.4;
}

/* Recent Activity */
.welcome-activity-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.welcome-activity-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.welcome-activity-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.welcome-activity-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--indigo-500), var(--violet-500));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.welcome-activity-content {
  flex: 1;
  min-width: 0;
}

.welcome-activity-name {
  font-size: 14px;
  font-weight: 500;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.welcome-activity-action {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}

.welcome-activity-time {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  white-space: nowrap;
}

/* Empty State */
.welcome-empty {
  text-align: center;
  padding: 40px 20px;
  color: rgba(255, 255, 255, 0.4);
}

.welcome-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.welcome-empty-text {
  font-size: 14px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SCROLL-DRIVEN ANIMATIONS
   CSS scroll-driven animations API (Chrome 115+, Safari 18.4+)
   Falls back gracefully to no animation in unsupported browsers
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Entrance animation keyframe */
@keyframes scroll-fade-in {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Cards fade in as they scroll into view */
@supports (animation-timeline: view()) {
  .welcome-stat-card,
  .welcome-action-card,
  .welcome-section,
  .welcome-activity-item {
    animation: scroll-fade-in linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 30%;
  }

  /* Staggered entrance for stat cards */
  .welcome-stat-card:nth-child(1) { animation-range: entry 0% entry 25%; }
  .welcome-stat-card:nth-child(2) { animation-range: entry 5% entry 30%; }
  .welcome-stat-card:nth-child(3) { animation-range: entry 10% entry 35%; }
  .welcome-stat-card:nth-child(4) { animation-range: entry 15% entry 40%; }

  /* Staggered entrance for action cards */
  .welcome-action-card:nth-child(1) { animation-range: entry 0% entry 25%; }
  .welcome-action-card:nth-child(2) { animation-range: entry 3% entry 28%; }
  .welcome-action-card:nth-child(3) { animation-range: entry 6% entry 31%; }
  .welcome-action-card:nth-child(4) { animation-range: entry 9% entry 34%; }
  .welcome-action-card:nth-child(5) { animation-range: entry 12% entry 37%; }
  .welcome-action-card:nth-child(6) { animation-range: entry 15% entry 40%; }

  /* Hero parallax-like effect on scroll */
  .welcome-hero {
    animation: hero-parallax linear;
    animation-timeline: scroll(root);
    animation-range: 0px 400px;
  }
}

@keyframes hero-parallax {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(-20px);
    opacity: 0.85;
  }
}

/* Scroll progress keyframe (must be outside @supports) */
@keyframes scroll-progress {
  to { transform: scaleX(1); }
}

/* Scroll progress indicator in header */
@supports (animation-timeline: scroll()) {
  .kairo-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 100%;
    background: var(--kairo-gradient);
    transform-origin: left;
    transform: scaleX(0);
    animation: scroll-progress linear;
    animation-timeline: scroll(root);
  }
}

/* Reduced motion: disable all scroll animations */
@media (prefers-reduced-motion: reduce) {
  .welcome-stat-card,
  .welcome-action-card,
  .welcome-section,
  .welcome-activity-item,
  .welcome-hero,
  .welcome-page {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1200px) {
  .welcome-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .welcome-stat-card.patients {
    grid-column: span 2;
  }

  .welcome-grid {
    grid-template-columns: 1fr;
  }

  .welcome-actions {
    grid-template-columns: repeat(2, 1fr);
  }

  .welcome-action-card:first-child {
    grid-column: span 2;
  }
}

@media (max-width: 768px) {
  .welcome-page {
    padding: 20px;
  }

  .welcome-hero {
    flex-direction: column;
    text-align: center;
    padding: 30px 20px;
  }

  .welcome-hero-logo {
    width: 100px;
    height: 100px;
  }

  .welcome-hero-title {
    font-size: 28px;
  }

  .welcome-hero-date {
    position: static;
    text-align: center;
    margin-top: 20px;
  }

  .welcome-stats {
    grid-template-columns: 1fr;
  }

  .welcome-stat-card.patients {
    grid-column: span 1;
  }

  .welcome-stat-card.patients .welcome-stat-value {
    font-size: 36px;
  }

  .welcome-actions {
    grid-template-columns: 1fr;
  }

  .welcome-action-card:first-child {
    grid-column: span 1;
    padding: 20px;
  }
}
