/* ============================================================
   Daivy AI — style.css
   Dark navy + teal accent, inspired by reference UI
   ============================================================ */
 
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
 
/* ── Variables ── */
:root {
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'DM Sans', sans-serif;
 
  /* Dark theme */
  --bg-primary:    #080c16;
  --bg-secondary:  #0e1422;
  --bg-card:       #131929;
  --bg-glass:      rgba(19, 25, 41, 0.75);
  --border:        rgba(255,255,255,0.07);
  --border-accent: rgba(0, 212, 170, 0.3);
 
  --text-primary:   #f0f4ff;
  --text-secondary: #8892aa;
  --text-muted:     #4a5568;
 
  --accent:      #00d4aa;
  --accent-dim:  rgba(0, 212, 170, 0.12);
  --accent-glow: rgba(0, 212, 170, 0.22);
 
  --user-bubble:        #1a3a8f;
  --user-bubble-border: rgba(59, 130, 246, 0.3);
  --ai-bubble:          #131929;
  --ai-bubble-border:   rgba(255,255,255,0.07);
 
  --shadow-lg:     0 20px 60px rgba(0,0,0,0.5);
  --shadow-accent: 0 0 40px rgba(0, 212, 170, 0.12);
  --nav-bg:        rgba(8, 12, 22, 0.88);
  --sidebar-bg:    #0a0f1e;
 
  --scrollbar:       #1e2a40;
  --scrollbar-thumb: #2e4070;
 
  --sidebar-width: 258px;
  --topbar-height: 60px;
  --transition: 0.22s ease;
}
 
[data-theme="light"] {
  --bg-primary:    #f5f7ff;
  --bg-secondary:  #eef1fc;
  --bg-card:       #ffffff;
  --bg-glass:      rgba(255, 255, 255, 0.82);
  --border:        rgba(0,0,0,0.08);
  --border-accent: rgba(0, 180, 140, 0.3);
 
  --text-primary:   #0d1526;
  --text-secondary: #4a5578;
  --text-muted:     #9aa3b8;
 
  --accent:      #007a64;
  --accent-dim:  rgba(0, 122, 100, 0.08);
  --accent-glow: rgba(0, 122, 100, 0.18);
 
  --user-bubble:        #1a5fd4;
  --user-bubble-border: rgba(26, 95, 212, 0.2);
  --ai-bubble:          #ffffff;
  --ai-bubble-border:   rgba(0,0,0,0.08);
 
  --shadow-lg:     0 20px 60px rgba(0,0,0,0.1);
  --shadow-accent: 0 0 40px rgba(0,122,100,0.08);
  --nav-bg:        rgba(245, 247, 255, 0.92);
  --sidebar-bg:    #edf0fc;
 
  --scrollbar:       #dde3f0;
  --scrollbar-thumb: #b0bcd8;
}
 
/* ── Base ── */
body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.65;
  overflow: hidden;
  height: 100vh;
  height: 100dvh; /* dvh = dynamic viewport height — shrinks with mobile browser chrome */
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}
 
::selection { background: var(--accent); color: #000; }
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--scrollbar); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
 
/* ── Layout ── */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}
 
/* ── Background effects (main panel) ── */
.bg-grid {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 20%, black 0%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 20%, black 0%, transparent 100%);
  pointer-events: none;
}
 
.bg-glow {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 55% 45% at 50% 20%, rgba(0,212,170,0.07) 0%, transparent 70%),
    radial-gradient(ellipse 35% 35% at 80% 60%, rgba(0,120,255,0.05) 0%, transparent 70%);
  pointer-events: none;
}
 
[data-theme="light"] .bg-glow {
  background:
    radial-gradient(ellipse 55% 45% at 50% 20%, rgba(0,122,100,0.06) 0%, transparent 70%),
    radial-gradient(ellipse 35% 35% at 80% 60%, rgba(0,120,255,0.04) 0%, transparent 70%);
}
 
/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 200;
  position: relative;
  transition: transform var(--transition), background var(--transition);
}
 
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
}
 
/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
 
.logo-mark {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent) 0%, #0099ff 100%);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: #000;
  box-shadow: 0 0 18px var(--accent-glow);
  flex-shrink: 0;
  transition: box-shadow var(--transition);
}
 
.logo-mark.small {
  width: 28px;
  height: 28px;
  font-size: 13px;
  border-radius: 8px;
}
 
.logo-text {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
 
.logo-text span { color: var(--accent); }
 
/* New chat button */
.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 12px 6px;
  padding: 9px 14px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 400;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
 
.new-chat-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}
 
.sidebar-section-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 14px 16px 6px;
}
 
.history-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 0 8px 12px;
}
 
.history-list li {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background var(--transition), color var(--transition);
}
 
.history-list li:hover {
  background: rgba(0, 212, 170, 0.06);
  color: var(--text-primary);
}
 
[data-theme="light"] .history-list li:hover {
  background: var(--accent-dim);
}
 
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}
 
.sidebar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
 
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 7px var(--accent);
  animation: pulse 2.5s infinite;
  flex-shrink: 0;
}
 
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }
 
/* ── Main panel ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  overflow: hidden;
}
 
/* ── Topbar ── */
.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  transition: background var(--transition);
}
 
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
}
 
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--transition), color var(--transition), transform 0.15s;
  flex-shrink: 0;
}
 
.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.05);
}
 
/* theme icons */
[data-theme="dark"] .sun-icon  { display: none; }
[data-theme="dark"] .moon-icon { display: block; }
.moon-icon { display: none; }
.sun-icon  { display: block; }
 
/* ── Chat area ── */
.chat-area {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
}
 
/* ── Welcome ── */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px 40px;
  flex: 1;
  text-align: center;
  animation: fadeUp 0.5s ease both;
}
 
.welcome-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--accent-dim);
  border: 1px solid var(--border-accent);
  border-radius: 100px;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 28px;
  font-weight: 500;
  animation: fadeUp 0.5s 0.05s ease both;
}
 
.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s infinite;
  flex-shrink: 0;
}
 
.welcome-logo-wrap {
  margin-bottom: 24px;
  animation: fadeUp 0.5s 0.1s ease both;
}
 
.welcome-logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--accent) 0%, #0099ff 100%);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  color: #000;
  box-shadow: 0 0 40px var(--accent-glow), 0 8px 32px rgba(0,0,0,0.3);
}
 
.welcome-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 300;
  line-height: 1.12;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 16px;
  animation: fadeUp 0.5s 0.15s ease both;
}
 
.welcome-title em {
  font-style: italic;
  color: var(--accent);
}
 
.welcome-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 300;
  max-width: 420px;
  margin: 0 auto 36px;
  animation: fadeUp 0.5s 0.2s ease both;
}
 
/* Suggestion cards */
.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 560px;
  animation: fadeUp 0.5s 0.25s ease both;
}
 
.suggestion-card {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: border-color var(--transition), background var(--transition), transform 0.15s;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 400;
  line-height: 1.4;
  backdrop-filter: blur(10px);
}
 
.suggestion-card:hover {
  border-color: var(--border-accent);
  background: var(--accent-dim);
  color: var(--text-primary);
  transform: translateY(-2px);
}
 
.suggestion-icon {
  font-size: 18px;
}
 
/* ── Messages ── */
.messages {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 20px 0 28px;
  width: 100%;
}
 
.message-row {
  display: flex;
  padding: 6px 20px;
  animation: fadeUp 0.25s ease both;
}
 
.message-row.user { justify-content: flex-end; }
.message-row.ai   { justify-content: flex-start; align-items: flex-start; }
 
/* Bubbles */
.message-bubble {
  max-width: min(74%, 680px);
  padding: 11px 16px;
  font-size: 14.5px;
  line-height: 1.65;
  word-break: break-word;
}
 
.message-row.user .message-bubble {
  background: var(--user-bubble);
  border: 1px solid var(--user-bubble-border);
  border-radius: 16px;
  border-top-right-radius: 4px;
  color: #f0f4ff;
}
 
.message-row.ai .message-bubble {
  background: transparent;
  color: var(--text-primary);
  padding-left: 0;
  border-radius: 0;
}
 
/* AI avatar */
.ai-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent) 0%, #0099ff 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: #000;
  flex-shrink: 0;
  margin-right: 10px;
  margin-top: 2px;
  box-shadow: 0 0 12px var(--accent-glow);
}
 
.ai-message-content {
  flex: 1;
  max-width: min(74%, 680px);
}
 
/* Message formatting */
.message-bubble p             { margin-bottom: 8px; }
.message-bubble p:last-child  { margin-bottom: 0; }
.message-bubble code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  background: rgba(0,212,170,0.1);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 13px;
}
[data-theme="light"] .message-bubble code {
  background: rgba(0,122,100,0.08);
}
.message-bubble pre {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 13px;
  margin: 8px 0;
}
.message-bubble pre code { background: none; padding: 0; color: var(--text-primary); }
.message-bubble ul, .message-bubble ol { padding-left: 20px; margin: 6px 0; }
.message-bubble li { margin-bottom: 4px; }
.message-bubble strong { font-weight: 600; color: var(--text-primary); }
 
/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 0;
}
 
.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: bounce 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 bounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.5; }
  30%          { transform: translateY(-7px); opacity: 1; }
}
 
/* Error */
.error-msg {
  font-size: 13.5px;
  color: #f87171;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.2);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
 
[data-theme="light"] .error-msg {
  color: #c0392b;
  background: #fdf0ee;
  border-color: #f5c6c0;
}
 
/* ── Input area ── */
.input-area {
  padding: 14px 18px 16px;
  /* Safe area inset for phones with home bar (iPhone X+, Android gesture nav) */
  padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  transition: background var(--transition);
}
 
.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 10px 10px 18px;
  max-width: 760px;
  margin: 0 auto;
  transition: border-color 0.18s, box-shadow 0.18s;
}
 
.input-wrapper:focus-within {
  border-color: var(--border-accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
 
#userInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text-primary);
  max-height: 180px;
  overflow-y: auto;
  padding: 2px 0;
}
 
#userInput::placeholder { color: var(--text-muted); }
#userInput::-webkit-scrollbar { display: none; }
 
.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #000;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 18px var(--accent-glow);
  transition: opacity var(--transition), transform 0.12s, box-shadow var(--transition);
}
 
.send-btn:disabled {
  background: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.5;
}
 
.send-btn:not(:disabled):hover {
  opacity: 0.88;
  transform: scale(1.06);
  box-shadow: 0 0 28px var(--accent-glow);
}
 
.send-btn:not(:disabled):active { transform: scale(0.96); }
 
.input-disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 9px;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}
 
/* ── Typewriter cursor ── */
.type-cursor {
  display: inline-block;
  color: var(--accent);
  font-size: 13px;
  line-height: 1;
  margin-left: 1px;
  animation: cursorBlink 0.7s step-end infinite;
  vertical-align: text-bottom;
}
 
@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}
 
/* ── Overlay (mobile) ── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
  backdrop-filter: blur(2px);
}
 
/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
 
/* ── Mobile ── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100%;
    height: 100dvh;
    transform: translateX(-100%);
    box-shadow: 0 0 60px rgba(0,0,0,0.6);
  }
  .sidebar.open    { transform: translateX(0); }
  .overlay.show    { display: block; }
 
  .welcome-title   { font-size: clamp(1.6rem, 7vw, 2.4rem); }
  .suggestion-grid { grid-template-columns: 1fr 1fr; }
 
  .message-bubble       { max-width: 88%; font-size: 14px; }
  .ai-message-content   { max-width: calc(88% - 42px); }
  .message-row          { padding: 5px 14px; }
 
  /* Tighter input area on small screens, still safe-area aware */
  .input-area {
    padding: 10px 12px max(14px, env(safe-area-inset-bottom, 14px));
  }
 
  .input-disclaimer { font-size: 10.5px; margin-top: 6px; }
}
 
@media (max-width: 420px) {
  .suggestion-grid { grid-template-columns: 1fr; }
}