/* ═══════════════════════════════════════════════════════════════
   S.A.M — Liquid Glass / Jarvis Theme
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-deep: #060a14;
  --bg: #0a0e1a;
  --bg-surface: #0f1424;
  --glass-bg: rgba(12, 16, 30, 0.5);
  --glass-border: rgba(60, 140, 220, 0.06);
  --glass-blur: 16px;
  --accent: #3baaff;
  --accent-bright: #5dc4ff;
  --accent-dim: #1a6baa;
  --accent-glow: rgba(59, 170, 255, 0.2);
  --accent-subtle: rgba(59, 170, 255, 0.06);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --text: #c8d4e8;
  --text-muted: #5a6d88;
  --text-dim: #2a3548;
  --text-bright: #e8f0ff;
  --border: rgba(60, 140, 220, 0.06);
  --border-active: rgba(59, 170, 255, 0.2);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-full: 9999px;
  --font: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ─── App Shell ────────────────────────────────────────────── */
#app { min-height: 100dvh; padding-bottom: 65px; }

.page { display: none; min-height: calc(100dvh - 65px); padding: 20px 16px; }
.page.active { display: block; }
.page-chat.active { display: flex; flex-direction: column; padding: 0; }

/* ─── Glass Primitives ─────────────────────────────────────── */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
}
.glass-card { composes: glass; padding: 16px; margin-bottom: 12px; }

.glass-btn {
  background: linear-gradient(135deg, var(--accent-dim), var(--accent));
  border: 1px solid rgba(59, 170, 255, 0.25);
  border-radius: var(--radius-sm);
  color: #fff;
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 20px;
  transition: all 200ms var(--ease);
}
.glass-btn:hover { box-shadow: 0 0 16px var(--accent-glow); transform: translateY(-1px); }
.glass-btn:active { transform: translateY(0); }

.glass-btn-ghost {
  background: transparent;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 16px;
  transition: all 200ms var(--ease);
}
.glass-btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.glass-btn-ghost.active { background: var(--accent-subtle); border-color: var(--border-active); color: var(--accent); }

/* ─── Bottom Navigation ────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 62px;
  background: rgba(6, 10, 20, 0.92);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-top: 1px solid rgba(60, 140, 220, 0.04);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 3px; cursor: pointer; padding: 6px 14px;
  color: var(--text-dim);
  transition: color 200ms;
}
.nav-item.active { color: var(--accent); }
.nav-item .nav-icon { font-size: 20px; }
.nav-item .nav-label { font-size: 9px; letter-spacing: 0.05em; }
.nav-fab {
  margin-top: -22px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.fab-circle {
  width: 50px; height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-dim), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: #fff;
  box-shadow: 0 0 20px var(--accent-glow);
  border: 2px solid rgba(100, 180, 255, 0.2);
  cursor: pointer;
  transition: transform 150ms, box-shadow 150ms;
}
.fab-circle:hover { transform: scale(1.05); box-shadow: 0 0 28px var(--accent-glow); }
.fab-circle:active { transform: scale(0.95); }

/* ─── Login Screen ─────────────────────────────────────────── */
.login-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
  position: relative;
  z-index: 2;
}
.login-logo {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.15em;
  margin-bottom: 4px;
}
.login-subtitle {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 40px;
}
.login-input {
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  padding: 12px 4px;
  outline: none;
  text-align: center;
  transition: border-color 300ms;
  margin-bottom: 24px;
}
.login-input:focus { border-bottom-color: var(--accent); }
.login-input::placeholder { color: var(--text-dim); }
.login-btn {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  margin-bottom: 12px;
}
.login-passkey-btn {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  background: transparent;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  transition: all 200ms;
}
.login-passkey-btn:hover { border-color: var(--accent); color: var(--accent); }
.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 16px;
  min-height: 20px;
}
.login-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0;
  font-size: 11px;
  color: var(--text-dim);
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── Dashboard ────────────────────────────────────────────── */
.page-header { margin-bottom: 20px; }
.page-title { font-size: 22px; font-weight: 600; color: var(--text-bright); }
.page-subtitle { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.stat-card { text-align: center; padding: 16px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--accent); line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.1em; }

.section-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 12px;
}

.event-row {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-left: 2px solid var(--accent);
  padding-left: 12px;
  margin-bottom: 6px;
}
.event-time { font-size: 12px; font-family: var(--font-mono); color: var(--accent); min-width: 80px; }
.event-title { font-size: 13px; color: var(--text); }
.event-meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.task-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  cursor: pointer;
}
.task-check {
  width: 16px; height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--text-dim);
  flex-shrink: 0;
  transition: all 200ms;
}
.task-row:hover .task-check { border-color: var(--accent); }
.task-label { font-size: 13px; color: var(--text); flex: 1; }
.task-tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  white-space: nowrap;
}
.task-tag.project { border-color: rgba(59, 170, 255, 0.15); color: var(--accent); }

/* ─── Chat ─────────────────────────────────────────────────── */
.page-chat {
  position: relative;
  height: calc(100dvh - 62px);
  overflow: hidden;
}
.chat-neural-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.chat-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.chat-core-area {
  height: 200px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  position: relative;
}
.core-label { font-size: 11px; font-weight: 600; color: rgba(59,170,255,0.5); letter-spacing: 0.25em; }
.core-status { font-size: 9px; color: rgba(52,211,153,0.5); letter-spacing: 0.15em; text-transform: uppercase; transition: color 400ms; margin-top: 4px; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(59,170,255,0.15) transparent;
  mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.3) 25px, black 70px);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.3) 25px, black 70px);
}
.chat-spacer { min-height: 30px; flex-shrink: 0; }

.bubble {
  max-width: 84%;
  padding: 10px 16px;
  font-size: 13px;
  line-height: 1.6;
  animation: fadeUp 300ms var(--ease);
}
.bubble-sam {
  align-self: flex-start;
  background: rgba(10, 14, 26, 0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 16px 16px 16px 4px;
  color: var(--text);
}
.bubble-user {
  align-self: flex-end;
  background: rgba(59, 170, 255, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(59, 170, 255, 0.1);
  border-radius: 16px 16px 4px 16px;
  color: var(--text-bright);
}
.bubble-actions {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--glass-border);
  font-size: 11px;
  color: var(--accent);
}
.thinking-dots {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 8px 16px;
}
.thinking-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: think 1.2s infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

.chat-input-area { padding: 6px 16px 10px; }
.chat-input-wrap { display: flex; gap: 8px; align-items: center; }
.chat-input {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 4px;
  outline: none;
  transition: border-color 300ms;
}
.chat-input:focus { border-bottom-color: rgba(59, 170, 255, 0.25); }
.chat-input::placeholder { color: var(--text-dim); }
.chat-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-dim), var(--accent));
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 15px; color: #fff; flex-shrink: 0;
  box-shadow: 0 0 10px var(--accent-glow);
  transition: transform 150ms, box-shadow 150ms;
  border: none;
}
.chat-send:hover { transform: scale(1.05); box-shadow: 0 0 18px var(--accent-glow); }
.chat-send:active { transform: scale(0.95); }

/* ─── Core Animation (CSS only) ────────────────────────────── */
.core-anim { position: relative; width: 250px; height: 160px; }
.core-anim * { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
.core-orb { border-radius: 50%; filter: blur(40px); opacity: 0.15; will-change: transform; }
.co1 { width: 160px; height: 160px; background: radial-gradient(circle,#3baaff,transparent 70%); animation: cd1 12s ease-in-out infinite; }
.co2 { width: 140px; height: 140px; background: radial-gradient(circle,#1a6baa,transparent 70%); animation: cd2 15s ease-in-out infinite; }
.co3 { width: 110px; height: 110px; background: radial-gradient(circle,#5dc4ff,transparent 70%); animation: cd3 10s ease-in-out infinite; }
.co4 { width: 100px; height: 100px; background: radial-gradient(circle,#34d399,transparent 70%); opacity: 0.07; animation: cd4 18s ease-in-out infinite; }

.core-ring { border-radius: 50%; border: 1px solid rgba(59,170,255,0.07); }
.cr1 { width: 80px; height: 80px; animation: spin 20s linear infinite, breathe 4s ease-in-out infinite; }
.cr2 { width: 130px; height: 130px; animation: spin 30s linear infinite reverse, breathe 5s ease-in-out infinite 1s; border-style: dashed; }
.cr3 { width: 180px; height: 180px; animation: spin 40s linear infinite, breathe 6s ease-in-out infinite 2s; border-style: dotted; }

.core-center { width: 35px; height: 35px; border-radius: 50%; background: radial-gradient(circle,rgba(59,170,255,0.2),rgba(59,170,255,0.05) 50%,transparent 70%); animation: cpulse 3s ease-in-out infinite; }
.core-glow { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle,rgba(100,200,255,0.35),transparent 70%); animation: cpulse 3s ease-in-out infinite 0.5s; }
.core-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-bright); box-shadow: 0 0 8px var(--accent), 0 0 16px var(--accent-glow); animation: dpulse 2s ease-in-out infinite; }

.core-arc { border-radius: 50%; border: 1px solid transparent; }
.ca1 { width: 60px; height: 60px; border-top-color: rgba(59,170,255,0.1); animation: spin 8s linear infinite; }
.ca2 { width: 100px; height: 100px; border-top-color: rgba(52,211,153,0.07); animation: spin 12s linear infinite reverse; }
.ca3 { width: 40px; height: 40px; border-top-color: rgba(59,170,255,0.12); border-bottom-color: rgba(59,170,255,0.06); animation: spin 6s linear infinite; }
.ca4 { width: 140px; height: 140px; border-top-color: rgba(59,170,255,0.05); animation: spin 15s linear infinite reverse; }

.core-pw { border-radius: 50%; border: 1px solid rgba(59,170,255,0.12); opacity: 0; width: 8px; height: 8px; }
.cpw1 { animation: pout 4s ease-out infinite; }
.cpw2 { animation: pout 4s ease-out infinite 1.3s; }
.cpw3 { animation: pout 4s ease-out infinite 2.6s; }

.core-particles { width: 75px; height: 75px; border-radius: 50%; animation: spin 10s linear infinite; background: radial-gradient(circle at 0% 50%,rgba(59,170,255,0.5) 0%,transparent 3px),radial-gradient(circle at 50% 0%,rgba(100,200,255,0.3) 0%,transparent 2px),radial-gradient(circle at 100% 50%,rgba(59,170,255,0.4) 0%,transparent 2.5px),radial-gradient(circle at 50% 100%,rgba(100,200,255,0.3) 0%,transparent 2px); }

/* Thinking state — speed up everything */
.thinking .core-orb { opacity: 0.28; }
.thinking .core-dot { box-shadow: 0 0 12px var(--accent-bright), 0 0 25px var(--accent), 0 0 50px var(--accent-glow); animation-duration: 0.8s; }
.thinking .core-ring { border-color: rgba(59,170,255,0.16); }
.thinking .cr1 { animation-duration: 6s; }
.thinking .cr2 { animation-duration: 8s; }
.thinking .ca1 { animation-duration: 3s; border-top-color: rgba(59,170,255,0.2); }
.thinking .ca3 { animation-duration: 2s; }
.thinking .cpw1, .thinking .cpw2, .thinking .cpw3 { animation-duration: 2s; }
.thinking .core-particles { animation-duration: 3s; }

/* ─── Keyframes ────────────────────────────────────────────── */
@keyframes cd1 { 0%,100%{transform:translate(calc(-50% - 50px),calc(-50% - 20px)) scale(1)} 25%{transform:translate(calc(-50% + 30px),calc(-50% - 40px)) scale(1.1)} 50%{transform:translate(calc(-50% + 50px),calc(-50% + 30px)) scale(0.9)} 75%{transform:translate(calc(-50% - 30px),calc(-50% + 40px)) scale(1.05)} }
@keyframes cd2 { 0%,100%{transform:translate(calc(-50% + 40px),calc(-50% + 20px))} 33%{transform:translate(calc(-50% - 50px),calc(-50% - 30px)) scale(1.15)} 66%{transform:translate(calc(-50% + 20px),calc(-50% - 50px)) scale(0.85)} }
@keyframes cd3 { 0%,100%{transform:translate(calc(-50% - 20px),calc(-50% + 40px))} 50%{transform:translate(calc(-50% + 40px),calc(-50% - 20px)) scale(1.2)} }
@keyframes cd4 { 0%,100%{transform:translate(calc(-50% + 50px),calc(-50% - 15px))} 40%{transform:translate(calc(-50% - 40px),calc(-50% + 40px))} 80%{transform:translate(calc(-50% - 15px),calc(-50% - 40px))} }
@keyframes spin { from{transform:translate(-50%,-50%) rotate(0)} to{transform:translate(-50%,-50%) rotate(360deg)} }
@keyframes breathe { 0%,100%{opacity:1} 50%{opacity:0.6} }
@keyframes cpulse { 0%,100%{transform:translate(-50%,-50%) scale(1);opacity:1} 50%{transform:translate(-50%,-50%) scale(1.3);opacity:0.6} }
@keyframes dpulse { 0%,100%{transform:translate(-50%,-50%) scale(1)} 50%{transform:translate(-50%,-50%) scale(1.4)} }
@keyframes pout { 0%{transform:translate(-50%,-50%) scale(1);opacity:0.4} 100%{transform:translate(-50%,-50%) scale(22);opacity:0} }
@keyframes fadeUp { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
@keyframes think { 0%{opacity:0.3} 50%{opacity:1} 100%{opacity:0.3} }

/* ─── Utility ──────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-dim { color: var(--text-dim); }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }

/* ─── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(59,170,255,0.2); border-radius: 2px; }
