/* =====================================================================
   styles.css — avinash.ai — monochrome "obsidian" UI.

   Design language (matches the brand reference):
     - Pure black backgrounds, near-black elevated surfaces
     - Strictly monochrome: white text, gray muted text, hairline borders
     - Primary actions: solid white buttons with black text
     - Secondary actions: outlined dark buttons with white text
     - Logo mark: black rounded square with a white outline + white "A"
     - Subtle white glows only — no color accents
   ===================================================================== */

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

:root {
  --bg:           #050505;
  --bg-elev:      #0d0d0e;
  --bg-elev-2:    #161618;
  --border:       #232326;
  --border-hover: #3d3d42;
  --text:         #f5f5f5;
  --text-muted:   #a2a2a8;
  --text-dim:     #6f6f76;
  --accent:       #ffffff;      /* monochrome accent = white */
  --accent-2:     #d6d6da;
  --accent-hover: #e6e6e9;
  --on-accent:    #0a0a0a;      /* text on white buttons */
  --danger:       #ef4444;
  --success:      #22c55e;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
               "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* Force any emoji glyphs used as icons to render monochrome/white. */
.mono-emoji {
  filter: grayscale(1) brightness(1.9);
}

/* =====================================================================
   App layout (sidebar + main) — used by chat.html
   ===================================================================== */
body.app-body {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text);
}

.logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
  object-fit: cover;
  flex-shrink: 0;
}

.welcome-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  border: 1px solid var(--border);
  margin-bottom: 18px;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: var(--bg-elev-2);
  border-color: var(--border-hover);
  color: var(--text);
}

.sidebar-nav {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.15s;
}

.nav-item:hover {
  background: var(--bg-elev-2);
  color: var(--text);
}

.nav-icon {
  width: 16px;
  text-align: center;
  font-size: 14px;
}

.history-section {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}

.history-title {
  margin: 6px 12px 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 600;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.history-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  background: none;
  border: none;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.history-item:hover {
  background: var(--bg-elev-2);
  color: var(--text);
}

.history-date {
  margin: 14px 12px 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 600;
}

.history-empty {
  padding: 12px;
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 10px;
}

.logout-link {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  text-align: center;
  transition: all 0.15s;
}

.logout-link:hover {
  background: var(--bg-elev-2);
  color: var(--text);
}

/* ---------- Main area ---------- */
.main-area {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.model-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.model-badge {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
}

.model-detail {
  font-size: 12px;
  color: var(--text-dim);
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px;
}

.messages {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 0;
}

/* ---------- Welcome screen ---------- */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: 40px 20px;
}

.welcome h1 {
  font-size: 38px;
  font-weight: 700;
  margin: 0 0 14px;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #ffffff 30%, #84848b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome p {
  font-size: 15px;
  color: var(--text-muted);
  margin: 0 0 28px;
  max-width: 460px;
  line-height: 1.5;
}

.suggestions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  max-width: 540px;
  width: 100%;
}

.suggestion {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: all 0.15s;
}

.suggestion:hover {
  border-color: var(--border-hover);
  color: var(--text);
  transform: translateY(-1px);
}

/* ---------- Chat bubbles ---------- */
.bubble {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-width: 85%;
  animation: fadeIn 0.2s ease;
}

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

.bubble.user {
  align-self: flex-end;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
}

.bubble.assistant {
  align-self: flex-start;
  background: transparent;
  padding: 12px 0;
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.bubble.pending {
  color: var(--text-dim);
  font-style: italic;
}

/* ---------- Copy buttons ---------- */
.copy-btn {
  align-self: flex-start;
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.copy-btn:hover {
  background: var(--bg-elev-2);
  border-color: var(--border-hover);
  color: var(--text);
}

.copy-btn.copied {
  color: var(--success);
  border-color: var(--success);
}

/* ---------- Composer ---------- */
.composer-wrap {
  padding: 10px 20px 16px;
  background: var(--bg);
}

.composer {
  max-width: 760px;
  margin: 0 auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 6px 6px 6px 18px;
  display: flex;
  align-items: end;
  gap: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer:focus-within {
  border-color: var(--border-hover);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.composer textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  padding: 10px 4px;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  max-height: 200px;
  min-height: 24px;
  line-height: 1.4;
}

.composer textarea::placeholder {
  color: var(--text-dim);
}

.send-btn {
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: all 0.15s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.send-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.send-btn:disabled {
  background: var(--border);
  color: var(--text-dim);
  cursor: not-allowed;
  transform: none;
}

.disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  margin: 10px 0 0;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

/* =====================================================================
   Auth pages (signup, login, profile)
   ===================================================================== */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(ellipse 60% 40% at 50% -10%, rgba(255, 255, 255, 0.05), transparent 70%),
    var(--bg);
}

.auth-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px;
  width: 100%;
  max-width: 460px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.auth-brand .brand-text {
  font-weight: 600;
  font-size: 17px;
}

.auth-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-card .subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 22px;
  line-height: 1.5;
}

.section-title {
  margin: 22px 0 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 600;
}

label {
  display: block;
  margin: 12px 0 4px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

input, textarea, select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder, textarea::placeholder {
  color: var(--text-dim);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--border-hover);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

textarea {
  resize: vertical;
  min-height: 44px;
}

button.primary {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  margin-top: 18px;
  transition: all 0.15s;
}

button.primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

button.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.error   { color: var(--danger);  font-size: 13px; margin-top: 12px; min-height: 1.2em; }
.status  { color: var(--success); font-size: 13px; margin-top: 12px; min-height: 1.2em; }

.footer-link {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.footer-link a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.footer-link a:hover { text-decoration: underline; }

/* =====================================================================
   Profile page top bar (different layout, no sidebar)
   ===================================================================== */
.profile-body {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
}

.topbar nav a {
  color: var(--text-muted);
  text-decoration: none;
  margin-left: 16px;
  font-size: 14px;
  transition: color 0.15s;
}

.topbar nav a:hover { color: var(--text); }

.profile-wrap {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 24px;
}

.profile-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px;
  width: 100%;
  max-width: 620px;
}

.profile-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.profile-card .subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 20px;
}

/* =====================================================================
   Responsive — collapse sidebar on small screens
   ===================================================================== */
@media (max-width: 720px) {
  body.app-body {
    grid-template-columns: 1fr;
  }
  .sidebar { display: none; }
  .suggestions { grid-template-columns: 1fr; }
  .welcome h1 { font-size: 28px; }
}

/* ---------- Markdown in assistant bubbles ---------- */
.bubble.md { white-space: normal; }
.bubble.md h3 { font-size: 16px; font-weight: 700; margin: 14px 0 8px; }
.bubble.md h4 { font-size: 15px; font-weight: 600; margin: 12px 0 6px; }
.bubble.md h3:first-child, .bubble.md h4:first-child { margin-top: 0; }
.bubble.md ul, .bubble.md ol { margin: 8px 0; padding-left: 22px; }
.bubble.md li { margin: 4px 0; }
.bubble.md a { color: var(--text); text-decoration: underline; }
.bubble.md code {
  background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 1px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}
.bubble.md .code-block-wrap {
  position: relative; margin: 10px 0; max-width: 100%;
}
.bubble.md pre.code-block {
  background: #0b0b0c; border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin: 0; overflow-x: auto; white-space: pre;
}
.bubble.md pre.code-block code {
  background: none; border: none; padding: 0; font-size: 13px; line-height: 1.6;
}
.code-copy {
  position: absolute; top: 8px; right: 8px; z-index: 1;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font: inherit; font-size: 11px; font-weight: 500; line-height: 1;
  padding: 5px 10px; border-radius: 7px;
  cursor: pointer; opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s, border-color 0.15s;
}
.code-block-wrap:hover .code-copy, .code-copy:focus-visible { opacity: 1; }
.code-copy:hover {
  background: var(--bg-elev-2); border-color: var(--border-hover);
  color: var(--text);
}
.code-copy.copied { opacity: 1; color: var(--success); border-color: var(--success); }
