/* ═══════════════════════════════════════════════════════════════
   PREMIUM UI — Visual Enhancement Layer
   Additive only — overrides nothing, enhances everything
   ═══════════════════════════════════════════════════════════════ */

/* ── 1. GLASSMORPHISM ─────────────────────────────────── */

/* Frosted header */
.header {
  background: rgba(8,12,20,0.97) !important;
  /* backdrop-filter removed — creates stacking context that traps notif dropdown */
  -webkit-/* backdrop-filter removed — creates stacking context that traps notif dropdown */
  border-bottom: 1px solid rgba(255,255,255,0.04) !important;
  box-shadow: 0 1px 24px rgba(0,0,0,0.3);
}
[data-theme="light"] .header {
  background: rgba(255,255,255,0.97) !important;
  box-shadow: 0 1px 20px rgba(0,0,0,0.06);
}

/* Stats bar — frosted glass */
.stats-bar {
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.stats-bar .stat-box {
  background: rgba(13,19,32,0.6) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.06) !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.03);
  transition: all 0.35s cubic-bezier(0.4,0,0.2,1) !important;
}
.stats-bar .stat-box:hover {
  border-color: rgba(96,165,250,0.2) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.05), 0 0 0 1px rgba(96,165,250,0.1);
  transform: translateY(-2px);
}
[data-theme="light"] .stats-bar .stat-box {
  background: rgba(255,255,255,0.7) !important;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04), inset 0 1px 0 rgba(255,255,255,0.8);
}

/* Tabs — frosted with smooth active indicator */
.tabs {
  background: rgba(13,19,32,0.65) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255,255,255,0.04) !important;
}
[data-theme="light"] .tabs {
  background: rgba(255,255,255,0.7) !important;
}
.tab {
  border-radius: 8px 8px 0 0;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1) !important;
  position: relative;
}
.tab:hover {
  background: rgba(255,255,255,0.03);
}
.tab.active {
  background: rgba(59,130,246,0.06);
}
.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  animation: tabSlide 0.3s cubic-bezier(0.4,0,0.2,1);
}
@keyframes tabSlide {
  from { left: 40%; right: 40%; opacity: 0; }
  to { left: 20%; right: 20%; opacity: 1; }
}

/* All cards & panels — glass depth */
.pred-card,
.today-card,
.med-card,
.med-sched-card,
.visit-card,
.report-card,
.report-item,
.hc-card,
.gc-stat-card,
.gc-compare-card,
.imaging-card,
.lifestyle-card,
.drug-result-item,
.ss-card,
.pdash,
.bm-wrap,
.v2-streak-card {
  background: rgba(13,19,32,0.55) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.05) !important;
  box-shadow:
    0 4px 24px rgba(0,0,0,0.15),
    0 1px 3px rgba(0,0,0,0.1),
    inset 0 1px 0 rgba(255,255,255,0.025);
  transition: all 0.35s cubic-bezier(0.4,0,0.2,1) !important;
}
[data-theme="light"] .pred-card,
[data-theme="light"] .today-card,
[data-theme="light"] .med-card,
[data-theme="light"] .ss-card,
[data-theme="light"] .pdash {
  background: rgba(255,255,255,0.65) !important;
  box-shadow: 0 2px 16px rgba(0,0,0,0.04), inset 0 1px 0 rgba(255,255,255,0.8);
}

/* ── 2. MICRO-INTERACTIONS ────────────────────────────── */

/* Card hover lift */
.pred-card:hover,
.today-card:hover,
.gc-stat-card:hover,
.gc-compare-card:hover,
.drug-result-item:hover {
  border-color: rgba(96,165,250,0.12) !important;
  box-shadow:
    0 12px 40px rgba(0,0,0,0.2),
    0 2px 6px rgba(0,0,0,0.15),
    inset 0 1px 0 rgba(255,255,255,0.04),
    0 0 0 1px rgba(96,165,250,0.06);
  transform: translateY(-2px);
}

/* Buttons — premium feel */
.btn, button[class*="btn"],
.header-actions button,
.meds-add button,
.pdash-markall,
.bm-take-btn,
.bm-toggle-btn {
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1) !important;
}
.btn:hover, button[class*="btn"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.btn:active, button[class*="btn"]:active {
  transform: translateY(0) scale(0.98);
  transition-duration: 0.1s !important;
}

/* Panel fade-in on tab switch */
.panel.active {
  animation: panelFadeIn 0.35s cubic-bezier(0.4,0,0.2,1);
}
@keyframes panelFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Smooth scrollbar everywhere */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(148,163,184,0.15) transparent;
}
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.15); border-radius: 3px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(148,163,184,0.25); }

/* Input focus glow */
input:focus, select:focus, textarea:focus {
  outline: none !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12), 0 2px 8px rgba(0,0,0,0.1) !important;
  transition: all 0.2s !important;
}

/* Badge pulse for notifications */
.header .notif-badge,
.header [class*="badge"] {
  animation: badgePulse 2s ease-in-out infinite;
}
@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

/* Medication pill cards hover */
.pdash-pill:hover:not(.taken):not(.missed) {
  box-shadow: 0 4px 16px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.03) !important;
}

/* Body map organ hover glow */
.bm-organ:hover {
  filter: brightness(1.15);
}

/* Table row hover */
tr:hover td {
  background: rgba(255,255,255,0.02);
  transition: background 0.2s;
}
[data-theme="light"] tr:hover td {
  background: rgba(0,0,0,0.02);
}

/* ── 3. DYNAMIC TIME THEME ────────────────────────────── */
/* Applied via JS — see premium-ui.js */
/* These CSS vars are set dynamically */
body[data-time-period="morning"] {
  --time-accent: #f59e0b;
  --time-glow: rgba(245,158,11,0.06);
}
body[data-time-period="noon"] {
  --time-accent: #3b82f6;
  --time-glow: rgba(59,130,246,0.04);
}
body[data-time-period="evening"] {
  --time-accent: #8b5cf6;
  --time-glow: rgba(139,92,246,0.06);
}
body[data-time-period="night"] {
  --time-accent: #1e40af;
  --time-glow: rgba(30,64,175,0.04);
}

/* Time-aware ambient glow on body */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 300px;
  background: radial-gradient(ellipse at 50% 0%, var(--time-glow, rgba(59,130,246,0.04)), transparent 70%);
  pointer-events: none;
  z-index: 0;
  transition: background 2s ease;
}
[data-theme="light"] body::before {
  height: 200px;
  background: radial-gradient(ellipse at 50% 0%, var(--time-glow, rgba(59,130,246,0.03)), transparent 70%);
}

/* Stats bar accent line changes with time */
.stats-bar .stat-box .stat-val {
  transition: color 1s ease;
}

/* ── 4. MOBILE BOTTOM NAV ─────────────────────────────── */
@media (max-width: 768px) {
  /* Bottom nav bar */
  .pui-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 60px;
    background: rgba(8,12,20,0.88);
    backdrop-filter: blur(24px) saturate(1.5);
    -webkit-backdrop-filter: blur(24px) saturate(1.5);
    border-top: 1px solid rgba(255,255,255,0.06);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.3);
    padding: 0 8px;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  [data-theme="light"] .pui-bottom-nav {
    background: rgba(255,255,255,0.88);
    border-top-color: rgba(0,0,0,0.06);
    box-shadow: 0 -2px 16px rgba(0,0,0,0.06);
  }

  .pui-bnav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 0;
    border: none;
    background: none;
    color: rgba(148,163,184,0.5);
    font-size: 10px;
    font-weight: 600;
    font-family: var(--sans);
    cursor: pointer;
    transition: all 0.25s;
    flex: 1;
    min-width: 0;
    -webkit-tap-highlight-color: transparent;
    position: relative;
  }
  .pui-bnav-item .pui-bnav-icon {
    font-size: 20px;
    line-height: 1;
    transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  }
  .pui-bnav-item.active {
    color: var(--accent2);
  }
  .pui-bnav-item.active .pui-bnav-icon {
    transform: scale(1.1);
  }
  .pui-bnav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 25%;
    right: 25%;
    height: 2px;
    background: var(--accent);
    border-radius: 0 0 2px 2px;
  }
  .pui-bnav-item:active .pui-bnav-icon {
    transform: scale(0.9);
  }

  /* Add padding at bottom to prevent content hiding behind nav */
  body {
    padding-bottom: 68px !important;
  }

  /* Hide scrollbar on mobile tabs for cleaner look */
  .tabs {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
}

/* Hide bottom nav on desktop */
@media (min-width: 769px) {
  .pui-bottom-nav { display: none !important; }
}

/* ── 5. GENERAL POLISH ────────────────────────────────── */

/* Smoother font rendering */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Better focus rings for accessibility */
:focus-visible {
  outline: 2px solid var(--accent) !important;
  outline-offset: 2px !important;
  border-radius: 4px;
}

/* Subtle page background texture */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.008'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}
[data-theme="light"] body::after {
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000000' fill-opacity='0.012'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* Ensure content is above pseudo-elements */
.header, .tabs, .stats-bar, .panel, .upload-screen, #login-section, #patient-list {
  position: relative;
  z-index: 1;
}

/* Loading skeleton shimmer for empty states */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
  border-radius: 8px;
}

/* Selection color */
::selection {
  background: rgba(59,130,246,0.25);
  color: inherit;
}
