/* ============================================================
   NARVYN LIFE OS — Global App Styles v1.0
   Premium mobile-first CSS: glassmorphism, animations,
   bottom nav, floating button, micro-interactions
   ============================================================ */

/* ── Fonts ──────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --gold:        #D4A853;
  --gold-light:  #F5D47A;
  --gold-dark:   #B8882E;
  --bottom-nav-h: 64px;
  --header-h:    56px;
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   20px;
  --radius-xl:   28px;
  /* Theme tokens — DARK (default) */
  --bg:          #050508;
  --bg-1:        #0d0d1a;
  --bg-2:        #16213e;
  --bg-card:     rgba(255,255,255,0.04);
  --bg-card-hover: rgba(255,255,255,0.07);
  --border:      rgba(212,168,83,0.12);
  --text:        #e2e8f0;
  --text-muted:  #64748b;
  --text-dim:    #374151;
  --glass-bg:    rgba(255,255,255,0.04);
  --glass-dark:  rgba(0,0,0,0.35);
  --sidebar-bg:  #080811;
  --header-bg:   rgba(0,0,0,0.35);
  --input-bg:    rgba(255,255,255,0.05);
  --bubble-out-bg: linear-gradient(135deg, #D4A853, #B8882E);
  --bubble-out-text: #050508;
  --bubble-in-bg:  rgba(255,255,255,0.07);
  --bubble-in-text: #e2e8f0;
  --msg-bg:      rgba(13,13,26,0.98);
}

/* ── LIGHT THEME ───────────────────────────────────────────── */
[data-theme="light"] {
  --bg:          #f4f1eb;
  --bg-1:        #faf8f3;
  --bg-2:        #fff8e7;
  --bg-card:     rgba(255,255,255,0.8);
  --bg-card-hover: rgba(255,255,255,0.95);
  --border:      rgba(212,168,83,0.25);
  --text:        #1a1a2e;
  --text-muted:  #64748b;
  --text-dim:    #9ca3af;
  --glass-bg:    rgba(255,255,255,0.7);
  --glass-dark:  rgba(255,255,255,0.85);
  --sidebar-bg:  #faf8f3;
  --header-bg:   rgba(250,248,243,0.9);
  --input-bg:    rgba(0,0,0,0.05);
  --bubble-out-bg: linear-gradient(135deg, #D4A853, #B8882E);
  --bubble-out-text: #fff;
  --bubble-in-bg:  rgba(255,255,255,0.9);
  --bubble-in-text: #1a1a2e;
  --msg-bg:      rgba(250,248,243,0.98);
}

/* Apply theme vars to base elements */
body { background: var(--bg); color: var(--text); transition: background 0.3s ease, color 0.3s ease; }
[data-theme="light"] body { background: var(--bg); }
[data-theme="light"] #app-shell { background: var(--bg); }
[data-theme="light"] aside#sidebar { background: var(--sidebar-bg) !important; border-color: var(--border) !important; }
[data-theme="light"] header { background: var(--header-bg) !important; border-color: var(--border) !important; }
[data-theme="light"] #bottom-nav { background: rgba(250,248,243,0.95) !important; border-color: var(--border) !important; }
[data-theme="light"] .glass { background: var(--glass-bg) !important; border-color: var(--border) !important; }
[data-theme="light"] .glass-dark { background: var(--glass-dark) !important; border-color: var(--border) !important; }
[data-theme="light"] .text-gray-400 { color: #6b7280 !important; }
[data-theme="light"] .text-gray-500 { color: #9ca3af !important; }
[data-theme="light"] .text-gray-600 { color: #d1d5db !important; }
[data-theme="light"] .text-white { color: var(--text) !important; }
[data-theme="light"] .bg-dark-400, [data-theme="light"] .bg-dark-500 { background: var(--sidebar-bg) !important; }
[data-theme="light"] input, [data-theme="light"] textarea { background: var(--input-bg) !important; color: var(--text) !important; }

/* Smooth theme transition */
*, *::before, *::after { transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease; }

/* ── Reset / Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-tap-highlight-color: transparent; scroll-behavior: smooth; }
body {
  background: var(--dark);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(212,168,83,0.3); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ── Glassmorphism ──────────────────────────────────────────── */
.glass {
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(212,168,83,0.12);
}
.glass-dark {
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(212,168,83,0.08);
}
.glass-gold {
  background: rgba(212,168,83,0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(212,168,83,0.25);
}

/* ── Gold Effects ───────────────────────────────────────────── */
.gold-text {
  background: linear-gradient(135deg, #D4A853, #F5D47A, #D4A853);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  background-size: 200% auto;
  animation: shimmer 3s linear infinite;
}
.gold-glow {
  box-shadow: 0 0 20px rgba(212,168,83,0.2), 0 0 40px rgba(212,168,83,0.08);
}
.gold-glow-strong {
  box-shadow: 0 0 30px rgba(212,168,83,0.4), 0 0 60px rgba(212,168,83,0.15);
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn-gold {
  background: linear-gradient(135deg, #D4A853, #B8882E);
  color: #050508;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}
.btn-gold::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  transition: left 0.4s ease;
}
.btn-gold:hover::after { left: 100%; }
.btn-gold:hover {
  background: linear-gradient(135deg, #F5D47A, #D4A853);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(212,168,83,0.45);
}
.btn-gold:active { transform: translateY(0) scale(0.97); }

/* ── Cards ──────────────────────────────────────────────────── */
.card-hover {
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.card-hover:hover {
  transform: translateY(-4px);
  border-color: rgba(212,168,83,0.35) !important;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5), 0 0 25px rgba(212,168,83,0.1);
}
.card-hover:active { transform: translateY(-2px); }

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar-link {
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
  position: relative;
}
.sidebar-link::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%) scaleX(0);
  width: 3px; height: 60%;
  background: var(--gold);
  border-radius: 0 2px 2px 0;
  transition: transform 0.2s ease;
}
.sidebar-link:hover, .sidebar-link.active {
  background: rgba(212,168,83,0.08);
  border-left-color: var(--gold);
  color: var(--gold);
}
.sidebar-link:hover::before, .sidebar-link.active::before {
  transform: translateY(-50%) scaleX(1);
}

/* ── Bottom Navigation ──────────────────────────────────────── */
#bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: rgba(5,5,8,0.92);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-top: 1px solid rgba(212,168,83,0.12);
  display: flex;
  align-items: stretch;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
  /* Only shown on mobile */
}
#bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: #4a5568;
  position: relative;
  transition: color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
#bottom-nav a:active {
  background: rgba(212,168,83,0.06);
}
#bottom-nav a.bnav-active {
  color: var(--gold);
}
#bottom-nav a.bnav-active::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 32px; height: 2px;
  background: linear-gradient(90deg, #D4A853, #F5D47A);
  border-radius: 0 0 2px 2px;
}
.bnav-icon {
  width: 22px; height: 22px;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.2s ease;
}
.bnav-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
  transition: color 0.2s ease;
}

/* ── Floating Chat Button ───────────────────────────────────── */
#float-chat-btn {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 16px);
  right: 16px;
  z-index: 99;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #D4A853, #B8882E);
  box-shadow: 0 4px 20px rgba(212,168,83,0.5), 0 0 0 0 rgba(212,168,83,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  animation: pulse-float 3s ease-in-out infinite;
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
#float-chat-btn:active {
  transform: scale(0.92);
  box-shadow: 0 2px 10px rgba(212,168,83,0.3);
  animation: none;
}
#float-chat-btn svg {
  width: 24px; height: 24px;
  color: #050508;
}
#float-chat-btn .chat-badge {
  position: absolute;
  top: -2px; right: -2px;
  width: 16px; height: 16px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid var(--dark);
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Splash Screen ──────────────────────────────────────────── */
#narvyn-splash {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #050508;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}
#narvyn-splash .splash-logo {
  width: 80px; height: 80px;
  border-radius: 20px;
  background: linear-gradient(135deg, #D4A853, #B8882E);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 60px rgba(212,168,83,0.5);
  animation: splash-pulse 1.5s ease-in-out infinite;
}
#narvyn-splash .splash-logo img {
  width: 52px; height: 52px;
  object-fit: contain;
}
#narvyn-splash .splash-title {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, #D4A853, #F5D47A);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}
#narvyn-splash .splash-subtitle {
  font-size: 13px;
  color: #4a5568;
  letter-spacing: 3px;
  text-transform: uppercase;
}
#narvyn-splash .splash-loader {
  width: 40px; height: 2px;
  background: rgba(212,168,83,0.15);
  border-radius: 1px;
  overflow: hidden;
  margin-top: 8px;
}
#narvyn-splash .splash-loader-bar {
  height: 100%;
  background: linear-gradient(90deg, #D4A853, #F5D47A);
  border-radius: 1px;
  animation: loader-sweep 0.8s ease-in-out forwards;
}

/* ── Animations ─────────────────────────────────────────────── */
@keyframes shimmer {
  0% { background-position: 0% center; }
  100% { background-position: 200% center; }
}
@keyframes pulse-float {
  0%, 100% { transform: translateY(0) scale(1); box-shadow: 0 4px 20px rgba(212,168,83,0.5); }
  50%       { transform: translateY(-4px) scale(1.02); box-shadow: 0 8px 30px rgba(212,168,83,0.6); }
}
@keyframes splash-pulse {
  0%, 100% { box-shadow: 0 0 40px rgba(212,168,83,0.4); }
  50%       { box-shadow: 0 0 80px rgba(212,168,83,0.7), 0 0 120px rgba(212,168,83,0.3); }
}
@keyframes loader-sweep {
  0%   { width: 0; }
  100% { width: 100%; }
}
@keyframes slideUp {
  0%   { transform: translateY(30px); opacity: 0; }
  100% { transform: translateY(0);    opacity: 1; }
}
@keyframes slideDown {
  0%   { transform: translateY(-30px); opacity: 0; }
  100% { transform: translateY(0);     opacity: 1; }
}
@keyframes fadeIn {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}
@keyframes ripple {
  0%   { transform: scale(0); opacity: 0.6; }
  100% { transform: scale(4); opacity: 0; }
}

/* ── Ripple Effect ──────────────────────────────────────────── */
.ripple-container { position: relative; overflow: hidden; }
.ripple-effect {
  position: absolute;
  border-radius: 50%;
  background: rgba(212,168,83,0.3);
  transform: scale(0);
  animation: ripple 0.6s linear;
  pointer-events: none;
}

/* ── Skeleton Loaders ───────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,255,255,0.08) 50%,
    rgba(255,255,255,0.04) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-wave 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-wave {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Chat Bubbles ───────────────────────────────────────────── */
.msg-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
  animation: msgPop 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes msgPop {
  0%   { transform: scale(0.85) translateY(4px); opacity: 0; }
  100% { transform: scale(1) translateY(0);      opacity: 1; }
}
.msg-out {
  background: var(--bubble-out-bg);
  color: var(--bubble-out-text);
  border-bottom-right-radius: 4px;
  margin-left: auto;
}
.msg-out::after {
  content:''; position:absolute; bottom:0; right:-6px;
  width:0; height:0;
  border-left:8px solid var(--gold-dark);
  border-top:6px solid transparent;
  border-bottom:0 solid transparent;
}
.msg-in {
  background: var(--bubble-in-bg);
  color: var(--bubble-in-text);
  border-bottom-left-radius: 4px;
  backdrop-filter: blur(10px);
}
[data-theme="light"] .msg-in { border: 1px solid rgba(0,0,0,0.06); box-shadow: 0 1px 4px rgba(0,0,0,0.06); }

.msg-in::after {
  content:''; position:absolute; bottom:0; left:-6px;
  width:0; height:0;
  border-right:8px solid var(--bubble-in-bg);
  border-top:6px solid transparent;
  border-bottom:0 solid transparent;
}
.msg-system {
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  margin: 4px auto;
}
.msg-time {
  font-size: 10px;
  opacity: 0.6;
  margin-top: 3px;
  white-space: nowrap;
}
.msg-out .msg-time { text-align: right; }
.msg-in .msg-time { text-align: left; }
.read-tick { font-size: 11px; }
.read-tick.read { color: #60a5fa; }

/* Reply quote */
.reply-quote {
  border-left: 3px solid var(--gold);
  padding: 4px 8px;
  margin-bottom: 6px;
  border-radius: 4px;
  background: rgba(212,168,83,0.1);
  font-size: 11px;
}
.msg-out .reply-quote { background: rgba(0,0,0,0.15); }

/* Reactions */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 4px;
}
.reaction-chip {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 1px 6px;
  font-size: 12px;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.reaction-chip:active { transform: scale(1.2); }

/* Long-press context menu */
#msg-context-menu {
  position: fixed;
  z-index: 500;
  background: rgba(13,13,26,0.98);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(212,168,83,0.2);
  border-radius: 14px;
  padding: 6px;
  min-width: 160px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  animation: fadeIn .15s ease;
}
[data-theme="light"] #msg-context-menu {
  background: rgba(255,255,255,0.98);
  border-color: rgba(212,168,83,0.3);
}
.ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s ease;
}
.ctx-item:hover { background: rgba(212,168,83,0.1); color: var(--gold); }
.ctx-item.danger:hover { background: rgba(239,68,68,0.1); color: #f87171; }

/* Date separator */
.date-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
  margin: 12px 0;
}
.date-sep::before, .date-sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.date-sep span {
  background: var(--bg-1);
  padding: 2px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

/* Typing dots */
.typing-dot {
  width: 7px; height: 7px;
  background: var(--gold);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.4; }
  30%          { transform: translateY(-6px); opacity: 1; }
}

/* Swipe to reply hint */
.swipe-reply-hint {
  position: absolute;
  right: -36px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.2s ease, right 0.2s ease;
  pointer-events: none;
}

/* Notification dropdown */
#notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  max-height: 480px;
  overflow-y: auto;
  background: var(--msg-bg);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  z-index: 200;
  animation: slideUp .2s cubic-bezier(0.34,1.56,0.64,1);
}
[data-theme="light"] #notif-dropdown {
  background: rgba(250,248,243,0.99);
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s ease;
  border-bottom: 1px solid var(--border);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: rgba(212,168,83,0.05); }
.notif-item.unread { background: rgba(212,168,83,0.04); }
.notif-item.unread::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--gold);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 6px;
}

/* Theme toggle button */
#theme-toggle {
  width: 36px; height: 20px;
  background: rgba(255,255,255,0.1);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: background 0.3s ease;
  flex-shrink: 0;
}
#theme-toggle.light { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
#theme-toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
#theme-toggle.light::after { transform: translateX(16px); }

/* ── Mobile layout padding for bottom nav ───────────────────── */
@media (max-width: 767px) {
  #bottom-nav { display: flex; }
  #float-chat-btn { display: flex; }

  /* Push content above bottom nav */
  #page-content {
    padding-bottom: calc(var(--bottom-nav-h) + 80px) !important;
  }

  /* Compact header on mobile */
  #app-shell header {
    padding: 10px 14px !important;
  }

  /* Larger tap targets */
  button, a[role="button"] { min-height: 40px; }
}

@media (min-width: 768px) {
  #bottom-nav { display: none !important; }
  #float-chat-btn { display: none !important; }
}

/* ── Toast enhancements ─────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 9996;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
  width: calc(100vw - 32px);
  pointer-events: none;
}
#toast-container > * { pointer-events: all; }

.toast-item {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid;
  animation: slideUp .3s cubic-bezier(0.34,1.56,0.64,1);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}

/* ── Page transition ────────────────────────────────────────── */
.page-enter {
  animation: fadeIn 0.3s ease;
}

/* ── Micro-interactions ─────────────────────────────────────── */
.tap-scale:active { transform: scale(0.96); }
.tap-bounce:active { transform: scale(0.94) translateY(1px); }

/* ── Focus states (accessibility) ──────────────────────────── */
:focus-visible {
  outline: 2px solid rgba(212,168,83,0.5);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── PWA standalone mode ────────────────────────────────────── */
@media (display-mode: standalone) {
  body { padding-top: env(safe-area-inset-top); }
  #app-shell { padding-top: 0; }
  #bottom-nav {
    padding-bottom: max(env(safe-area-inset-bottom), 8px);
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
  }
}

/* ── Notification permission bar animation ──────────────────── */
@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

/* ── Desktop sidebar improvements ──────────────────────────── */
@media (min-width: 768px) {
  #sidebar {
    transition: width 0.3s ease;
  }
  .sidebar-link {
    border-radius: 10px;
    margin: 1px 4px;
  }
  .sidebar-link:hover {
    background: rgba(212,168,83,0.07) !important;
    transform: translateX(3px);
  }
  .card-hover:hover {
    transform: translateY(-6px);
  }
}

/* ── Subtle page scroll indicator ──────────────────────────── */
#scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  background: linear-gradient(90deg, #D4A853, #F5D47A);
  z-index: 9999;
  transition: width 0.1s linear;
  pointer-events: none;
}

/* ════════════════════════════════════════════════════════════
   FIX PACK v1.1 — UI Polish & Responsiveness
   ════════════════════════════════════════════════════════════ */

/* ── FIX: Bottom nav active class (JS adds .active, mirror bnav-active) ── */
#bottom-nav a.active { color: var(--gold); }
#bottom-nav a.active::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 32px; height: 2px;
  background: linear-gradient(90deg, #D4A853, #F5D47A);
  border-radius: 0 0 2px 2px;
}
#bottom-nav a.active .bnav-icon { color: var(--gold); transform: scale(1.15); }
#bottom-nav a.active .bnav-label { color: var(--gold); }

/* ── FIX: Prevent horizontal overflow on all pages ── */
html, body { max-width: 100vw; overflow-x: hidden; }
#app-shell { max-width: 100vw; overflow-x: hidden; }

/* ── FIX: Hide float chat btn on the chat page itself ── */
body[data-page="chat"] #float-chat-btn { display: none !important; }

/* ── FIX: Notification dropdown — mobile overflow ── */
@media (max-width: 480px) {
  #notif-dropdown {
    position: fixed;
    top: 56px;
    left: 8px;
    right: 8px;
    width: auto !important;
    max-height: 70vh;
    border-radius: 16px;
  }
}

/* ── FIX: Light mode — Tailwind dark bg classes ── */
[data-theme="light"] .bg-dark-300,
[data-theme="light"] .bg-dark-400,
[data-theme="light"] .bg-dark-500 {
  background: var(--bg-1) !important;
}

/* ── FIX: Light mode — select elements ── */
[data-theme="light"] select {
  background: var(--input-bg) !important;
  color: var(--text) !important;
  border-color: rgba(0,0,0,0.12) !important;
}
[data-theme="light"] option {
  background: var(--bg-1) !important;
  color: var(--text) !important;
}

/* ── FIX: Light mode — sidebar nav text ── */
[data-theme="light"] .sidebar-link { color: #374151 !important; }
[data-theme="light"] .sidebar-link:hover,
[data-theme="light"] .sidebar-link.active { color: var(--gold) !important; }
[data-theme="light"] #bottom-nav a { color: #6b7280 !important; }
[data-theme="light"] #bottom-nav a.active,
[data-theme="light"] #bottom-nav a.bnav-active { color: var(--gold) !important; }

/* ── FIX: Light mode — card glass surfaces ── */
[data-theme="light"] .glass-gold {
  background: rgba(212,168,83,0.12) !important;
}
[data-theme="light"] #narvyn-splash { background: #faf8f3 !important; }

/* ── FIX: Line-clamp cross-browser ── */
.line-clamp-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ── FIX: Chat back button — show on mobile via CSS ── */
@media (max-width: 767px) {
  #back-btn { display: flex !important; }
}

/* ── FIX: Mobile content padding — safe-area aware ── */
@media (max-width: 767px) {
  #page-content {
    padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 72px) !important;
  }
  /* Chat page overrides this */
  body[data-page="chat"] #page-content {
    padding-bottom: 0 !important;
  }
}

/* ── FIX: Modal z-index stacking ── */
.modal-backdrop { z-index: 500; }
#vault-modal, #detail-modal { z-index: 500; }
#toast-container { z-index: 9996; }
#narvyn-splash { z-index: 10000; }

/* ── FIX: Input & textarea — consistent focus ring ── */
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: rgba(212,168,83,0.5) !important;
  box-shadow: 0 0 0 3px rgba(212,168,83,0.08);
}

/* ── FIX: Images — prevent overflow in cards ── */
img { max-width: 100%; height: auto; }

/* ── FIX: Tables — horizontal scroll on mobile ── */
table { width: 100%; border-collapse: collapse; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── FIX: Button — min tap target on mobile ── */
@media (max-width: 767px) {
  .btn-gold { min-height: 44px; }
}

/* ── FIX: Sidebar — light mode scroll track ── */
[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(212,168,83,0.4); }
[data-theme="light"] ::-webkit-scrollbar-track { background: rgba(0,0,0,0.03); }

/* ── FIX: Message input on mobile keyboard open (iOS) ── */
@supports (-webkit-touch-callout: none) {
  #input-bar { position: sticky; bottom: 0; }
}

/* ── FIX: Gold text in light mode — readable contrast ── */
[data-theme="light"] .gold-text {
  background: linear-gradient(135deg, #B8882E, #D4A853);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── ENHANCE: Card shadows in light mode ── */
[data-theme="light"] .card-hover:hover {
  box-shadow: 0 20px 50px rgba(0,0,0,0.12), 0 0 20px rgba(212,168,83,0.15) !important;
}

/* ── ENHANCE: Sidebar active link indicator ── */
.sidebar-link.active {
  background: rgba(212,168,83,0.09) !important;
  color: var(--gold) !important;
  font-weight: 600;
}

/* ── ENHANCE: Empty state centering ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  gap: 12px;
}
.empty-state .empty-icon { font-size: 48px; opacity: 0.6; }
.empty-state h4 { font-size: 16px; font-weight: 600; color: var(--text); margin: 0; }
.empty-state p  { font-size: 13px; color: var(--text-muted); margin: 0; max-width: 260px; }

/* ── ENHANCE: Form labels ── */
.form-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; display: block; font-weight: 500; }

/* ── ENHANCE: Glass input (applies --input-bg var) ── */
.glass-input {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  width: 100%;
  font-family: inherit;
  transition: border-color .2s ease;
}
.glass-input:focus { border-color: rgba(212,168,83,.5); box-shadow: 0 0 0 3px rgba(212,168,83,.07); }
.glass-input::placeholder { color: var(--text-muted); }

/* ── ENHANCE: Stats number pulse on load ── */
@keyframes countUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.stat-num { animation: countUp .4s ease both; }

/* ── ENHANCE: Desktop sidebar collapsed hint ── */
@media (min-width: 768px) {
  aside#sidebar { will-change: transform; }
}

/* ── ENHANCE: Mobile tap feedback for list items ── */
@media (max-width: 767px) {
  .room-item:active { background: rgba(212,168,83,.15) !important; transform: scale(.99); }
  .card-hover:active { transform: translateY(-1px) !important; }
  .notif-item:active { background: rgba(212,168,83,.08) !important; }
}

/* ── ENHANCE: Danger zone styling ── */
.danger-zone {
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: var(--radius-lg);
  padding: 20px;
}
[data-theme="light"] .danger-zone { background: rgba(239,68,68,0.03); }

/* ── ENHANCE: Full width on mobile for modals ── */
@media (max-width: 480px) {
  .modal-box { border-radius: 20px 20px 0 0 !important; max-width: 100% !important; }
  .modal-backdrop { align-items: flex-end !important; padding: 0 !important; }
}

/* ── ENHANCE: Smooth sidebar transition ── */
#sidebar, #sidebar-overlay { will-change: transform, opacity; }

/* ── FIX: Ensure h-screen + flex work on iOS Safari ── */
#app-shell {
  height: 100svh; /* svh = small viewport height, handles iOS toolbar */
}
@supports not (height: 100svh) {
  #app-shell { height: 100vh; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   FIX PACK v1.2 — Cross-page polish pass (April 2026)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Finance / Health / Intelligence tab bars: hide scrollbar, keep scroll ── */
.overflow-x-auto {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.overflow-x-auto::-webkit-scrollbar { display: none; }

/* ── Finance tab bar — light mode bg ── */
[data-theme="light"] .bg-dark-400\/60 { background: rgba(0,0,0,0.05) !important; }

/* ── Tab buttons — reduce padding on very small screens ── */
@media (max-width: 380px) {
  .tab-btn { padding: 0.35rem 0.75rem !important; font-size: 0.72rem !important; }
}

/* ── Finance filters: stack on narrow mobile ── */
@media (max-width: 480px) {
  #month-filter, #cat-filter { min-width: 0; }
}

/* ── Light mode: glass cards background ── */
[data-theme="light"] .glass {
  background: rgba(255,255,255,0.75) !important;
  border-color: rgba(0,0,0,0.07) !important;
}
[data-theme="light"] .glass-input {
  background: rgba(255,255,255,0.8) !important;
  border-color: rgba(0,0,0,0.12) !important;
  color: var(--text) !important;
}
[data-theme="light"] .glass-input::placeholder { color: rgba(0,0,0,0.35) !important; }

/* ── Light mode: page title + subtitle ── */
[data-theme="light"] #page-title    { color: var(--text) !important; }
[data-theme="light"] #page-subtitle { color: var(--text-muted) !important; }

/* ── Light mode: stat numbers ── */
[data-theme="light"] .text-white     { color: var(--text) !important; }
[data-theme="light"] .text-gray-400  { color: rgba(0,0,0,0.55) !important; }
[data-theme="light"] .text-gray-500  { color: rgba(0,0,0,0.45) !important; }
[data-theme="light"] .text-gray-600  { color: rgba(0,0,0,0.35) !important; }

/* ── Light mode: gold text stays gold ── */
[data-theme="light"] .text-gold-400,
[data-theme="light"] .gold-text,
[data-theme="light"] .text-gold-500 { color: #B8860B !important; }

/* ── Light mode: dark rings in health/intelligence SVGs ── */
[data-theme="light"] circle[stroke="#1f2937"] { stroke: #e5e7eb !important; }

/* ── Scrollable areas: thin scrollbar on desktop ── */
@media (min-width: 768px) {
  ::-webkit-scrollbar { width: 4px; height: 4px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: rgba(212,168,83,0.3); border-radius: 2px; }
  ::-webkit-scrollbar-thumb:hover { background: rgba(212,168,83,0.6); }
}

/* ── Intelligence identity scores: keep 3 cols but allow ring to shrink ── */
@media (max-width: 359px) {
  .grid-cols-3 > div .w-20 { width: 4rem !important; height: 4rem !important; }
  .grid-cols-3 > div svg.w-20 { width: 4rem !important; height: 4rem !important; }
}

/* ── Card hover: slightly deeper on desktop for premium feel ── */
@media (min-width: 768px) {
  .card-hover:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.35), 0 0 0 1px rgba(212,168,83,0.12);
  }
}

/* ── Goals board: 3-col on desktop, 1-col on mobile ── */
@media (max-width: 767px) {
  #goals-board { grid-template-columns: 1fr !important; }
}

/* ── Planning left panel: full width on mobile ── */
@media (max-width: 767px) {
  #plan-left-panel { width: 100% !important; }
}

/* ── Button focus ring ── */
button:focus-visible {
  outline: 2px solid rgba(212,168,83,0.6);
  outline-offset: 2px;
}

/* ── Smooth page load fade-in ── */
#page-content { animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
