/* NOVA PWA — Premium Mobile Dark UI
   Color system matches existing NOVA dashboard */

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

/* =============================================
   DESIGN TOKENS
   ============================================= */
:root {
  --nova-bg:        #0a0a0f;
  --nova-surface:   #12121a;
  --nova-surface-2: #1a1a26;
  --nova-surface-3: #22223a;
  --nova-border:    rgba(124, 58, 237, 0.15);
  --nova-accent:    #7c3aed;
  --nova-accent-2:  #9d5cf7;
  --nova-accent-3:  #6025c7;
  --nova-glow:      rgba(124, 58, 237, 0.25);
  --nova-text:      #e8e8f0;
  --nova-text-dim:  #888899;
  --nova-text-faint:#444456;
  --nova-high:      #ef4444;
  --nova-mid:       #f59e0b;
  --nova-low:       #06b6d4;
  --nova-success:   #10b981;
  --nova-user-bg:   #7c3aed;
  --nova-ai-bg:     #1a1a26;
  --font:           'Inter', system-ui, -apple-system, sans-serif;
  --radius:         16px;
  --radius-sm:      10px;
  --radius-pill:    999px;
  --shadow-glow:    0 0 20px var(--nova-glow);
  --shadow-card:    0 4px 24px rgba(0,0,0,0.4);
  --transition:     0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =============================================
   RESET & BASE
   ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--nova-bg);
  color: var(--nova-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea { font-family: inherit; }
a { color: var(--nova-accent-2); text-decoration: none; }

/* =============================================
   APP SHELL
   ============================================= */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;            /* dynamic viewport height — handles iOS safari bar */
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: var(--nova-bg);
}

/* =============================================
   AUTH SCREEN
   ============================================= */
#auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  padding: 32px 24px;
  background: var(--nova-bg);
  background-image:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(124, 58, 237, 0.15) 0%, transparent 70%);
}

.auth-logo {
  width: 96px;
  height: 96px;
  border-radius: 24px;
  background: var(--nova-surface-2);
  border: 1px solid var(--nova-border);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
  margin-bottom: 24px;
  overflow: hidden;
}

.auth-logo img { width: 100%; height: 100%; object-fit: cover; border-radius: 24px; }

.auth-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #fff 0%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-subtitle {
  font-size: 15px;
  color: var(--nova-text-dim);
  text-align: center;
  line-height: 1.5;
  margin-bottom: 40px;
  max-width: 280px;
}

.btn-google {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  color: #1f1f1f;
  font-size: 16px;
  font-weight: 600;
  padding: 14px 28px;
  border-radius: var(--radius-pill);
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  transition: transform var(--transition), box-shadow var(--transition);
  width: 100%;
  max-width: 280px;
  justify-content: center;
}

.btn-google:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(0,0,0,0.4); }
.btn-google:active { transform: translateY(0); }

.btn-google svg { width: 22px; height: 22px; flex-shrink: 0; }

.auth-footer {
  position: absolute;
  bottom: calc(24px + env(safe-area-inset-bottom));
  font-size: 12px;
  color: var(--nova-text-faint);
  text-align: center;
}

/* =============================================
   TOP BAR
   ============================================= */
#top-bar {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--nova-surface);
  border-bottom: 1px solid var(--nova-border);
  gap: 12px;
  flex-shrink: 0;
}

.top-bar-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
}

.top-bar-logo img { width: 100%; height: 100%; object-fit: cover; }

.top-bar-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.2px;
  background: linear-gradient(135deg, #fff 0%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  flex: 1;
}

.top-bar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--nova-text-dim);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--nova-success);
  box-shadow: 0 0 6px var(--nova-success);
  animation: pulse-dot 2s infinite;
}

.status-dot.offline { background: var(--nova-high); box-shadow: 0 0 6px var(--nova-high); animation: none; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

#btn-mute {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--nova-surface-2);
  color: var(--nova-text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

#btn-mute.muted { color: var(--nova-high); background: rgba(239,68,68,0.1); }

/* =============================================
   TAB CONTENT AREA
   ============================================= */
#content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab-panel {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}

.tab-panel.active { display: flex; }

/* =============================================
   BOTTOM NAV
   ============================================= */
#bottom-nav {
  display: flex;
  background: var(--nova-surface);
  border-top: 1px solid var(--nova-border);
  padding-bottom: env(safe-area-inset-bottom);
  flex-shrink: 0;
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 4px 8px;
  gap: 4px;
  color: var(--nova-text-faint);
  font-size: 11px;
  font-weight: 500;
  transition: color var(--transition);
  position: relative;
}

.nav-tab.active { color: var(--nova-accent-2); }

.nav-tab svg { width: 22px; height: 22px; }

.nav-tab .tab-label { font-size: 10px; font-weight: 600; letter-spacing: 0.3px; }

.nav-tab::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 32px;
  height: 2px;
  background: var(--nova-accent);
  border-radius: var(--radius-pill);
  transition: transform var(--transition);
}

.nav-tab.active::before { transform: translateX(-50%) scaleX(1); }

/* =============================================
   CHAT TAB
   ============================================= */
#tab-chat {
  background: var(--nova-bg);
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Scrollbar */
#messages::-webkit-scrollbar { width: 4px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: var(--nova-surface-3); border-radius: 2px; }

.msg {
  display: flex;
  gap: 10px;
  animation: msg-in 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 88%;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg.user { flex-direction: row-reverse; align-self: flex-end; }
.msg.nova  { align-self: flex-start; }

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  overflow: hidden;
}

.msg.nova .msg-avatar {
  background: var(--nova-surface-3);
  border: 1px solid var(--nova-border);
}

.msg.nova .msg-avatar img { width: 100%; height: 100%; object-fit: cover; }

.msg.user .msg-avatar {
  background: var(--nova-accent-3);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.55;
  max-width: 100%;
}

.msg.user .msg-bubble {
  background: var(--nova-user-bg);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.msg.nova .msg-bubble {
  background: var(--nova-ai-bg);
  color: var(--nova-text);
  border: 1px solid var(--nova-border);
  border-bottom-left-radius: 6px;
}

/* Markdown in NOVA messages */
.msg.nova .msg-bubble h1,
.msg.nova .msg-bubble h2,
.msg.nova .msg-bubble h3 { color: var(--nova-accent-2); margin: 8px 0 4px; font-size: 14px; }

.msg.nova .msg-bubble p { margin: 4px 0; }
.msg.nova .msg-bubble ul,
.msg.nova .msg-bubble ol { padding-left: 18px; margin: 4px 0; }
.msg.nova .msg-bubble li { margin: 2px 0; }

.msg.nova .msg-bubble code {
  background: var(--nova-surface-3);
  border: 1px solid var(--nova-border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
  font-family: 'Menlo', 'Monaco', monospace;
}

.msg.nova .msg-bubble pre {
  background: var(--nova-surface-3);
  border: 1px solid var(--nova-border);
  border-radius: 8px;
  padding: 10px;
  overflow-x: auto;
  margin: 6px 0;
}

.msg.nova .msg-bubble pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
}

/* Typing indicator */
.msg-typing .msg-bubble {
  background: var(--nova-ai-bg);
  border: 1px solid var(--nova-border);
  padding: 14px 18px;
}

.typing-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--nova-accent);
  animation: typing-bounce 1.2s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* Scroll-to-bottom button */
#scroll-to-bottom {
  position: absolute;
  bottom: 80px;
  right: 16px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--nova-surface-2);
  border: 1px solid var(--nova-border);
  color: var(--nova-text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-card);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  z-index: 10;
}

#scroll-to-bottom.visible { opacity: 1; pointer-events: auto; }

/* Input area */
#chat-input-area {
  padding: 10px 12px;
  background: var(--nova-surface);
  border-top: 1px solid var(--nova-border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

#chat-input {
  flex: 1;
  background: var(--nova-surface-2);
  border: 1px solid var(--nova-border);
  border-radius: 22px;
  padding: 10px 16px;
  color: var(--nova-text);
  font-size: 15px;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  line-height: 1.4;
  outline: none;
  transition: border-color var(--transition);
  overflow-y: auto;
}

#chat-input:focus { border-color: var(--nova-accent); }
#chat-input::placeholder { color: var(--nova-text-faint); }

#chat-input::-webkit-scrollbar { width: 3px; }
#chat-input::-webkit-scrollbar-thumb { background: var(--nova-surface-3); }

#btn-mic {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--nova-surface-2);
  border: 1px solid var(--nova-border);
  color: var(--nova-text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition);
}

#btn-mic:hover { background: var(--nova-surface-3); color: var(--nova-accent-2); }

#btn-mic.recording {
  background: rgba(239,68,68,0.15);
  border-color: var(--nova-high);
  color: var(--nova-high);
  animation: mic-pulse 1.5s infinite;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50% { box-shadow: 0 0 0 10px rgba(239,68,68,0); }
}

#btn-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--nova-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), transform var(--transition), opacity var(--transition);
  box-shadow: 0 2px 12px var(--nova-glow);
}

#btn-send:hover { background: var(--nova-accent-2); transform: scale(1.05); }
#btn-send:active { transform: scale(0.95); }
#btn-send:disabled { opacity: 0.4; transform: none; cursor: not-allowed; }

/* =============================================
   MY DAY TAB
   ============================================= */
#tab-myday {
  background: var(--nova-bg);
  overflow-y: auto;
}

.myday-header {
  padding: 20px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.myday-date {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.myday-date span { color: var(--nova-accent-2); }

#btn-refresh-plan {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--nova-surface-2);
  border: 1px solid var(--nova-border);
  color: var(--nova-text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), background var(--transition), transform var(--transition);
}

#btn-refresh-plan:hover { color: var(--nova-accent-2); background: var(--nova-surface-3); }
#btn-refresh-plan.spinning { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#plan-cards {
  padding: 0 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.plan-card {
  background: var(--nova-surface);
  border: 1px solid var(--nova-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}

.plan-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(124,58,237,0.03) 100%);
  pointer-events: none;
}

.plan-card:hover { background: var(--nova-surface-2); border-color: rgba(124,58,237,0.3); transform: translateY(-1px); }
.plan-card:active { transform: translateY(0); }

.plan-card.done {
  opacity: 0.45;
  pointer-events: none;
}

.plan-card.done .plan-title { text-decoration: line-through; }

.priority-bar {
  width: 3px;
  border-radius: 2px;
  flex-shrink: 0;
  align-self: stretch;
  min-height: 36px;
}

.priority-bar.high   { background: var(--nova-high); box-shadow: 0 0 8px rgba(239,68,68,0.4); }
.priority-bar.medium { background: var(--nova-mid);  box-shadow: 0 0 8px rgba(245,158,11,0.3); }
.priority-bar.low    { background: var(--nova-low);  box-shadow: 0 0 8px rgba(6,182,212,0.3); }

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

.plan-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--nova-text);
  margin-bottom: 4px;
  line-height: 1.3;
}

.plan-detail {
  font-size: 12.5px;
  color: var(--nova-text-dim);
  line-height: 1.4;
}

.plan-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--nova-border);
  flex-shrink: 0;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), border-color var(--transition);
  color: transparent;
}

.plan-card:hover .plan-check { border-color: var(--nova-accent); }
.plan-card.done .plan-check { background: var(--nova-success); border-color: var(--nova-success); color: #fff; }

/* Skeleton loader */
.skeleton-card {
  background: var(--nova-surface);
  border: 1px solid var(--nova-border);
  border-radius: var(--radius);
  height: 72px;
  overflow: hidden;
  position: relative;
}

.skeleton-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.04) 50%, transparent 100%);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* =============================================
   VOICE TAB
   ============================================= */
#tab-voice {
  background: var(--nova-bg);
  background-image: radial-gradient(ellipse 70% 50% at 50% 0%, rgba(124,58,237,0.1) 0%, transparent 60%);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 40px 24px;
}

.voice-orb-container {
  position: relative;
  width: 180px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-orb {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--nova-accent-3) 0%, #3b0a8a 60%, var(--nova-surface-2) 100%);
  border: 2px solid var(--nova-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 0 40px rgba(124,58,237,0.3), inset 0 0 40px rgba(0,0,0,0.5);
  z-index: 2;
  position: relative;
}

.voice-orb:hover { transform: scale(1.04); box-shadow: 0 0 60px rgba(124,58,237,0.5), inset 0 0 40px rgba(0,0,0,0.5); }
.voice-orb:active { transform: scale(0.97); }

.voice-orb.listening {
  animation: orb-breathe 1.5s ease-in-out infinite;
  box-shadow: 0 0 60px rgba(239,68,68,0.5), inset 0 0 40px rgba(0,0,0,0.5);
  border-color: var(--nova-high);
}

.voice-orb.speaking {
  animation: orb-speak 0.8s ease-in-out infinite;
  box-shadow: 0 0 60px rgba(124,58,237,0.6), inset 0 0 40px rgba(0,0,0,0.5);
}

@keyframes orb-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

@keyframes orb-speak {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.orb-ring {
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 1px solid rgba(124,58,237,0.2);
  animation: ring-expand 2s ease-out infinite;
}

.orb-ring:nth-child(2) { inset: -24px; animation-delay: 0.5s; border-color: rgba(124,58,237,0.12); }
.orb-ring:nth-child(3) { inset: -38px; animation-delay: 1s; border-color: rgba(124,58,237,0.06); }

@keyframes ring-expand {
  0% { opacity: 0.8; transform: scale(0.95); }
  100% { opacity: 0; transform: scale(1.1); }
}

.voice-orb svg { width: 52px; height: 52px; color: #fff; }

.voice-status {
  font-size: 17px;
  font-weight: 500;
  color: var(--nova-text);
  text-align: center;
}

.voice-status .status-hint {
  display: block;
  font-size: 13px;
  color: var(--nova-text-dim);
  margin-top: 6px;
  font-weight: 400;
}

#voice-transcript {
  background: var(--nova-surface);
  border: 1px solid var(--nova-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  width: 100%;
  min-height: 60px;
  font-size: 14px;
  color: var(--nova-text-dim);
  text-align: center;
  line-height: 1.5;
  font-style: italic;
}

#voice-transcript.has-text { color: var(--nova-text); font-style: normal; }

/* =============================================
   OFFLINE BANNER
   ============================================= */
#offline-banner {
  display: none;
  background: rgba(239,68,68,0.15);
  border-bottom: 1px solid rgba(239,68,68,0.3);
  padding: 8px 16px;
  font-size: 12.5px;
  color: #fca5a5;
  text-align: center;
  flex-shrink: 0;
}

#offline-banner.visible { display: block; }

/* =============================================
   TOAST NOTIFICATIONS
   ============================================= */
#toast-container {
  position: fixed;
  bottom: calc(70px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 420px;
}

.toast {
  background: var(--nova-surface-2);
  border: 1px solid var(--nova-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13.5px;
  color: var(--nova-text);
  box-shadow: var(--shadow-card);
  animation: toast-in 0.3s ease;
  pointer-events: auto;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =============================================
   UTILITY
   ============================================= */
.hidden { display: none !important; }

/* Desktop comfort */
@media (min-width: 481px) {
  #app {
    border-left: 1px solid var(--nova-border);
    border-right: 1px solid var(--nova-border);
    box-shadow: 0 0 80px rgba(124,58,237,0.08);
  }

  body {
    background: #06060a;
    background-image: radial-gradient(ellipse 60% 40% at 50% 0%, rgba(124,58,237,0.08) 0%, transparent 60%);
  }
}
