/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Earth palette ───────────────────────────── */
  /* Matte-black backgrounds */
  --bg:          #080d0b;
  --bg-surface:  #0d1410;
  --bg-elevated: #121a15;
  --bg-hover:    #172019;
  --border:      rgba(0,210,180,0.1);
  --border-soft: rgba(0,210,180,0.05);

  --text-primary:   #e4f5f0;
  --text-secondary: #7aada0;
  --text-muted:     #3d6059;

  /* Cyan — oceans */
  --accent:       #00c9b8;
  --accent-light: #2de8d5;
  --accent-glow:  rgba(0,201,184,0.28);

  /* Purple — atmosphere edge */
  --accent-2:     #7c4dff;
  --accent-2-glow: rgba(124,77,255,0.2);

  /* Green — landmasses */
  --accent-3:      #1db87a;
  --accent-3-glow: rgba(29,184,122,0.18);

  --user-bubble:   linear-gradient(135deg, #00c9b8 0%, #1db87a 100%);
  --ai-bubble:     #0e1a14;

  --radius-sm:  8px;
  --radius-md:  14px;
  --radius-lg:  20px;
  --radius-xl:  28px;

  --sidebar-w: 270px;
  --transition: 0.22s cubic-bezier(0.4,0,0.2,1);
  --font: 'Inter', system-ui, sans-serif;
}

/* Light theme */
body.light {
  --bg:          #e8f5f2;
  --bg-surface:  #ffffff;
  --bg-elevated: #d8f0eb;
  --bg-hover:    #cceae3;
  --border:      rgba(0,150,130,0.15);
  --border-soft: rgba(0,150,130,0.07);

  --text-primary:   #061210;
  --text-secondary: #2a6a5e;
  --text-muted:     #7aaaa0;

  --ai-bubble: #ddf0eb;
}


/* ─── Nepal map watermark ───────────────────────────────────────────────────── */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: url('nepal.svg');
  background-repeat: no-repeat;
  background-size: 72%;
  background-position: center 60%;
  opacity: 0.1;
  filter: drop-shadow(0 0 8px #00c9b8);
  mix-blend-mode: screen;
}
body.light::after {
  opacity: 0.12;
  mix-blend-mode: screen;
}

html { height: 100%; }


body {
  font-family: var(--font);
  background-color: #060d0a;
  background-image: url('bg.jpg');
  background-size: cover;
  background-position: center center;
  background-attachment: fixed;
  color: var(--text-primary);
  height: 100%;
  overflow: hidden;
  transition: color var(--transition);
  position: relative;
}

/* Dark overlay so text stays readable over the image */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background: rgba(6, 13, 10, 0.78);
  pointer-events: none;
}
body.light::before {
  background: rgba(6, 13, 10, 0.55);
}

/* Background orbs hidden — image bg is used instead */
.bg-orb { display: none; }
@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  33%       { transform: translate(20px, -20px); }
  66%       { transform: translate(-15px, 15px); }
}

/* ─── App Layout ───────────────────────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  height: 100vh;
  height: 100dvh;
  position: relative;
  z-index: 1;
}

/* ─── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  flex-shrink: 0;
  transition: transform var(--transition), background var(--transition);
  backdrop-filter: blur(20px);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 0 4px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #00c9b8, #1db87a);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.logo-icon svg { width: 18px; height: 18px; color: #fff; }
.logo-text { font-weight: 700; font-size: 1.15rem; letter-spacing: -0.3px; }

.sidebar-close { display: none; }

/* New Chat button */
.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 24px;
}
.new-chat-btn svg { width: 16px; height: 16px; }
.new-chat-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

/* History */
.history-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 10px;
  margin-bottom: 8px;
}

.history-list { list-style: none; flex: 1; overflow-y: auto; }
.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.history-item span { overflow: hidden; text-overflow: ellipsis; }
.history-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.history-item.active { background: var(--bg-hover); color: var(--accent-light); }

/* Sidebar footer */
.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border-soft); }
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition);
}
.user-card:hover { background: var(--bg-hover); }
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.85rem; font-weight: 600; }
.user-plan { font-size: 0.72rem; color: var(--text-muted); }
.settings-icon { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }

/* ─── Chat Area ────────────────────────────────────────────────────────────── */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ─── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(13,15,20,0.6);
  backdrop-filter: blur(20px);
  flex-shrink: 0;
}
body.light .topbar { background: rgba(245,247,255,0.7); }

.menu-btn { display: none; }

.model-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: all var(--transition);
  margin-right: auto;
}
.model-selector:hover { border-color: var(--accent); }
.model-name { font-size: 0.875rem; font-weight: 600; }
.model-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  letter-spacing: 0.04em;
}
.model-selector svg { width: 14px; height: 14px; color: var(--text-muted); }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ─── Icon Button ──────────────────────────────────────────────────────────── */
.icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all var(--transition);
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.hidden { display: none !important; }

/* ─── Messages Container ───────────────────────────────────────────────────── */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  scroll-behavior: smooth;
}
.messages-container::-webkit-scrollbar { width: 5px; }
.messages-container::-webkit-scrollbar-track { background: transparent; }
.messages-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.messages-list { padding: 24px 0 16px; }

/* ─── Welcome Screen ───────────────────────────────────────────────────────── */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  padding: 40px 24px;
  text-align: center;
  animation: fadeUp 0.5s ease;
}
.welcome-icon {
  position: relative;
  width: 72px; height: 72px;
  margin-bottom: 28px;
}
.welcome-icon svg {
  width: 72px; height: 72px;
  color: var(--accent);
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 0 16px var(--accent-glow));
}
.pulse-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0.4;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50%       { transform: scale(1.15); opacity: 0; }
}

.welcome-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #e4f5f0 0%, #00c9b8 45%, #1db87a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
}
.welcome-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 36px;
}

/* Suggestion cards */
.suggestions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-width: 580px;
  width: 100%;
}
.suggestion-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: left;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.suggestion-card:hover {
  border-color: var(--accent);
  background: var(--bg-elevated);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,201,184,0.15);
}
.suggestion-icon { font-size: 1.3rem; }
.suggestion-text { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.45; }

/* ─── Message Bubbles ──────────────────────────────────────────────────────── */
.message {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 10px 24px;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
  animation: fadeUp 0.3s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message.user { flex-direction: row-reverse; }

.message-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}
.message.user .message-avatar {
  background: linear-gradient(135deg, #00c9b8, #1db87a);
  color: #fff;
}
.message.ai .message-avatar {
  background: var(--bg-elevated);
  border: 1px solid rgba(0,201,184,0.25);
  color: var(--accent);
}
.message.ai .message-avatar svg { width: 16px; height: 16px; }

.message-body { max-width: 78%; display: flex; flex-direction: column; gap: 4px; }
.message.user .message-body { align-items: flex-end; }

.message-content {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  line-height: 1.65;
  word-break: break-word;
}
.message.user .message-content {
  background: var(--user-bubble);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.message.ai .message-content {
  background: var(--ai-bubble);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}

.message-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0 4px;
}

/* Message actions */
.message-actions {
  display: none;
  gap: 6px;
  margin-top: 4px;
}
.message:hover .message-actions { display: flex; }
.action-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all var(--transition);
}
.action-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.action-btn svg { width: 13px; height: 13px; }

/* ─── Typing Indicator ─────────────────────────────────────────────────────── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  background: var(--ai-bubble);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.typing-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%            { transform: translateY(-6px); opacity: 1; }
}

/* ─── Input Area ───────────────────────────────────────────────────────────── */
.input-area {
  padding: 12px 24px 20px;
  flex-shrink: 0;
  background: transparent;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 10px 10px 10px 18px;
  transition: border-color var(--transition), box-shadow var(--transition);
  max-width: 820px;
  margin: 0 auto;
}
.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,201,184,0.18);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.9rem;
  line-height: 1.6;
  resize: none;
  max-height: 200px;
  overflow-y: auto;
  padding: 2px 0;
}
.chat-input::placeholder { color: var(--text-muted); }

.input-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.attach-btn { opacity: 0.6; }
.attach-btn:hover { opacity: 1; }

.send-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.send-btn svg { width: 16px; height: 16px; }
.send-btn:disabled { background: var(--bg-elevated); color: var(--text-muted); cursor: not-allowed; }
.send-btn:not(:disabled):hover {
  background: var(--accent-light);
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(0,201,184,0.4), 0 0 0 1px rgba(0,201,184,0.2);
}

.input-hint {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 10px;
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}

/* ─── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    transform: translateX(-100%);
    box-shadow: 4px 0 40px rgba(0,0,0,0.4);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: grid; }
  .menu-btn { display: grid; }
  .suggestions-grid { grid-template-columns: 1fr; }
  .message { padding: 10px 16px; }
  .input-area { padding: 10px 16px 16px; }
  .topbar { padding: 12px 16px; }
  .welcome-title { font-size: 1.5rem; }
}

@media (max-width: 480px) {
  .message-body { max-width: 90%; }
}

/* ─── Streaming cursor ─────────────────────────────────────────────────────── */
.cursor-blink {
  display: inline-block;
  color: var(--accent);
  font-weight: 300;
  animation: blink 0.9s step-end infinite;
  margin-left: 1px;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.streaming-content { min-height: 1.6em; }

/* ─── Message content prose ────────────────────────────────────────────────── */
.message-content p       { margin: 0 0 0.5em; }
.message-content p:last-child { margin-bottom: 0; }
.message-content h1,
.message-content h2,
.message-content h3      { margin: 0.8em 0 0.3em; font-weight: 600; }
.message-content ul,
.message-content ol      { padding-left: 1.4em; margin: 0.4em 0; }
.message-content li      { margin-bottom: 0.25em; }
.message-content code    {
  background: rgba(0,201,184,0.12);
  color: var(--accent-light);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: 'Fira Code', 'Cascadia Code', monospace;
}

/* Error message */
.error-msg {
  color: #f06292;
  font-size: 0.875rem;
}
