/* ====================================================================
   Apple Style Frost Glass Design System (Pure White Background Edition)
   5-Family Health Track - Mobile-First PWA
   ==================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Kantumruy+Pro:ital,wght@0,300..700;1,300..700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* Apple Typography */
  --font-khmer: 'Kantumruy Pro', -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", sans-serif;
  --font-latin: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;

  /* Apple Health & System Colors */
  --apple-blue: #007aff;
  --apple-green: #34c759;
  --apple-red: #ff3b30;
  --apple-orange: #ff9500;
  --apple-purple: #af52de;
  --apple-teal: #5ac8fa;

  /* Pure White Canvas */
  --bg-deep: #f8fafc;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --glass-white: rgba(255, 255, 255, 0.88);
  --glass-border: rgba(226, 232, 240, 0.85);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: var(--font-khmer);
  background-color: #f8fafc !important;
  color: var(--text-main) !important;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.font-latin {
  font-family: var(--font-latin);
}

/* --------------------------------------------------------------------
   Ambient Pastel Floating Orbs (Behind White Background)
   -------------------------------------------------------------------- */
.orb-glow {
  position: absolute;
  border-radius: 9999px;
  filter: blur(100px);
  pointer-events: none;
  opacity: 0.55;
  will-change: transform;
}

.orb-1 {
  top: -60px;
  left: -40px;
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.25) 0%, rgba(56, 189, 248, 0) 70%);
  animation: float-orb-1 16s ease-in-out infinite alternate;
}

.orb-2 {
  top: 25%;
  right: -80px;
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, rgba(192, 132, 252, 0.22) 0%, rgba(192, 132, 252, 0) 70%);
  animation: float-orb-2 20s ease-in-out infinite alternate;
}

.orb-3 {
  bottom: 8%;
  left: 6%;
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, rgba(74, 222, 128, 0.2) 0%, rgba(74, 222, 128, 0) 70%);
  animation: float-orb-3 18s ease-in-out infinite alternate;
}

.orb-4 {
  bottom: -80px;
  right: 10%;
  width: 440px;
  height: 440px;
  background: radial-gradient(circle, rgba(251, 113, 133, 0.2) 0%, rgba(251, 113, 133, 0) 70%);
  animation: float-orb-4 15s ease-in-out infinite alternate;
}

@keyframes float-orb-1 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(50px, 70px) scale(1.1); }
}

@keyframes float-orb-2 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-60px, 80px) scale(0.95); }
}

@keyframes float-orb-3 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(70px, -50px) scale(1.06); }
}

@keyframes float-orb-4 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-40px, -60px) scale(1.12); }
}

/* --------------------------------------------------------------------
   Apple Frost Glass Cards (Light / White Appearance)
   -------------------------------------------------------------------- */
.apple-glass,
.glass-panel {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 
    inset 0 1px 1.5px 0 rgba(255, 255, 255, 1),
    0 10px 25px -5px rgba(15, 23, 42, 0.05),
    0 8px 10px -6px rgba(15, 23, 42, 0.02);
}

.apple-glass-card {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(30px) saturate(200%);
  -webkit-backdrop-filter: blur(30px) saturate(200%);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 28px;
  box-shadow: 
    inset 0 1px 1.5px rgba(255, 255, 255, 1),
    0 12px 28px -6px rgba(15, 23, 42, 0.06),
    0 4px 8px -2px rgba(15, 23, 42, 0.03);
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.apple-glass-card:hover {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(203, 213, 225, 0.9);
  transform: translateY(-2px);
  box-shadow: 
    inset 0 1px 2px rgba(255, 255, 255, 1),
    0 18px 36px -8px rgba(15, 23, 42, 0.1);
}

.apple-glass-pill {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 
    inset 0 1px 1px rgba(255, 255, 255, 1),
    0 3px 10px rgba(15, 23, 42, 0.04);
  border-radius: 9999px;
  color: #0f172a;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.apple-glass-pill:hover {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 
    inset 0 1px 1px rgba(255, 255, 255, 1),
    0 6px 16px rgba(15, 23, 42, 0.08);
}

.apple-glass-pill:active {
  transform: scale(0.97);
}

/* Frosted Input Fields (Light Mode) */
.apple-glass-input {
  background: rgba(248, 250, 252, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1.5px solid rgba(203, 213, 225, 0.9);
  border-radius: 18px;
  color: #0f172a;
  transition: all 0.2s ease;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
}

.apple-glass-input:focus {
  outline: none;
  border-color: var(--apple-blue);
  background: #ffffff;
  box-shadow: 
    0 0 0 4px rgba(0, 122, 255, 0.15),
    inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

/* iOS Segmented Controls Bar (Light Mode) */
.apple-segmented-bar {
  background: rgba(241, 245, 249, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 9999px;
  padding: 4px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

.apple-segmented-item-active {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 0.5px solid rgba(0, 0, 0, 0.06);
  box-shadow: 
    0 3px 10px rgba(0, 0, 0, 0.1),
    0 1px 2px rgba(0, 0, 0, 0.06);
}

/* --------------------------------------------------------------------
   Elderly Accessible Mode (Ultra-Crisp for Senior Eyes on White)
   -------------------------------------------------------------------- */
body.elderly-mode {
  font-size: 1.25rem;
  line-height: 1.6;
}

body.elderly-mode h1 {
  font-size: 2.35rem;
}

body.elderly-mode h2 {
  font-size: 1.85rem;
}

body.elderly-mode h3 {
  font-size: 1.55rem;
}

body.elderly-mode button,
body.elderly-mode .elderly-touch-target {
  min-height: 68px;
  font-size: 1.3rem;
  font-weight: 800;
  border-radius: 26px;
}

body.elderly-mode input,
body.elderly-mode select {
  font-size: 1.4rem;
  min-height: 64px;
}

/* Apple Elderly Glass Card (Light Mode) */
.glass-panel-elderly {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(34px) saturate(210%);
  -webkit-backdrop-filter: blur(34px) saturate(210%);
  border: 1.5px solid rgba(226, 232, 240, 0.95);
  border-radius: 30px;
  box-shadow: 
    inset 0 1.5px 2px rgba(255, 255, 255, 1),
    0 14px 34px -8px rgba(15, 23, 42, 0.07);
}

/* Status Badges */
.status-badge-critical {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
  animation: pulse-danger 2s infinite;
}

.status-badge-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
}

.status-badge-normal {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

@keyframes pulse-danger {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.03); opacity: 0.92; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes pulse-ring {
  0% { transform: scale(0.97); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
  70% { transform: scale(1); box-shadow: 0 0 0 22px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.97); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.sos-pulse {
  animation: pulse-ring 2.2s infinite;
}

/* --------------------------------------------------------------------
   Apple Sheet Modal with Deep Frost Blur (Light Mode)
   -------------------------------------------------------------------- */
.apple-modal-content {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(40px) saturate(220%);
  -webkit-backdrop-filter: blur(40px) saturate(220%);
  border: 1.5px solid rgba(255, 255, 255, 1);
  border-radius: 36px;
  box-shadow: 
    inset 0 1.5px 2px rgba(255, 255, 255, 1),
    0 25px 60px -15px rgba(15, 23, 42, 0.2);
  color: #0f172a;
}

.apple-drag-handle {
  width: 44px;
  height: 5px;
  background-color: rgba(15, 23, 42, 0.2);
  border-radius: 9999px;
  margin: 0 auto 16px auto;
}

/* --------------------------------------------------------------------
   Apple Toast Notification (Light Mode Dynamic Island)
   -------------------------------------------------------------------- */
#toast-container {
  position: fixed;
  top: 24px;
  right: 20px;
  left: 20px;
  max-width: 440px;
  margin: 0 auto;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 
    inset 0 1px 1.5px rgba(255, 255, 255, 1),
    0 20px 45px -10px rgba(15, 23, 42, 0.14);
  border-radius: 24px;
  color: #0f172a;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  transform: translateY(-24px) scale(0.95);
  opacity: 0;
}

.toast.show {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Custom Scrollbars (Light Mode) */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.6);
}

/* Sound Wave Animation for OCR */
.wave-bar {
  display: inline-block;
  width: 4px;
  height: 24px;
  margin: 0 2px;
  background-color: var(--apple-blue);
  border-radius: 9999px;
  animation: wave 1.2s infinite ease-in-out;
}
.wave-bar:nth-child(2) { animation-delay: 0.15s; }
.wave-bar:nth-child(3) { animation-delay: 0.3s; }
.wave-bar:nth-child(4) { animation-delay: 0.45s; }
.wave-bar:nth-child(5) { animation-delay: 0.6s; }

@keyframes wave {
  0%, 100% { height: 8px; }
  50% { height: 30px; }
}

/* Safe Area Support */
.pb-safe {
  padding-bottom: env(safe-area-inset-bottom, 20px);
}
