/* ============================================================
   AROVI — Redesigned UI (ChatGPT-style, larger fonts)
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  /* Backgrounds — three distinct levels */
  --bg: #0f1210;         /* near-black, main canvas */
  --bg2: #1a1f18;        /* sidebar, header, modals */
  --bg3: #22291f;        /* hover states, input wrapper */

  /* Borders */
  --border: #2e3829;     /* subtle dividers */
  --border2: #3d4a38;    /* stronger borders on hover */

  /* Accent — moss green, used sparingly */
  --gold: #7ab87a;       /* slightly brighter green */

  /* Text hierarchy — real contrast */
  --text: #ede8df;       /* primary text, near-white warm */
  --text2: #b0aa9e;      /* secondary text */
  --muted: #6e7a6a;      /* labels, placeholders */
  --dim: #3a4235;        /* very quiet text */

  --sidebar-width: 260px;
  --font-base: 15px;
}

html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  font-size: var(--font-base);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* PAGE SYSTEM */
.page { display: none; flex-direction: column; height: 100%; }
.page.active { display: flex; }

/* HEADER */
header {
  padding: 0 16px;
  height: 52px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  background: var(--bg2);
}
.logo {
  font-size: 1.2em;
  color: var(--text);
  letter-spacing: 0.06em;
  font-weight: 700;
  flex-shrink: 0;
  cursor: pointer;
}
.avatar-tabs {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.avatar-tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 7px 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88em;
  border-radius: 6px;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.tab:hover { background: var(--bg3); color: var(--text); }
.tab.active {
  background: #1d2b1d;
  border-color: var(--gold);
  color: var(--gold);
  font-weight: 500;
}
.auth-area { display: flex; align-items: center; gap: 8px; flex-shrink: 0; margin-left: auto; }
.user-email { color: var(--border2); font-size: 0.8em; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: none; }
@media (min-width: 480px) { .user-email { display: block; } }
.btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88em;
  border-radius: 6px;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--border2); color: var(--text); background: var(--bg3); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--bg); font-weight: 500; }
.btn.primary:hover { background: #8fca8f; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--bg3); border-color: transparent; }

/* MODAL */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  border-radius: 12px;
  position: relative;
}
.modal h2 { color: var(--text); font-size: 1.15em; margin-bottom: 20px; font-weight: 600; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; color: var(--muted); font-size: 0.82em; margin-bottom: 6px; font-weight: 500; }
.form-group input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 14px;
  font-family: inherit;
  font-size: 0.95em;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus { border-color: var(--gold); }
.modal-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; }
.modal-error { color: #c06060; font-size: 0.82em; margin-top: 8px; min-height: 18px; }
.modal-switch { color: var(--muted); font-size: 0.85em; cursor: pointer; }
.modal-switch:hover { color: var(--gold); }
.modal-close { position: absolute; top: 12px; right: 16px; cursor: pointer; color: var(--muted); font-size: 1.4em; line-height: 1; }
.modal-close:hover { color: var(--text); }

/* ONBOARDING PAGE */
#page-onboarding { background: var(--bg); overflow-y: auto; }
.onboarding-body { max-width: 600px; margin: 0 auto; padding: 56px 24px; }
.onboarding-body h1 { color: var(--text); font-size: 1.8em; font-weight: 600; margin-bottom: 10px; }
.onboarding-body .subtitle { color: var(--muted); font-size: 1em; margin-bottom: 40px; line-height: 1.6; }
.mentor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 32px; }
@media (max-width: 480px) { .mentor-grid { grid-template-columns: 1fr; } }
.mentor-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 16px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  background: var(--bg2);
}
.mentor-card:hover { border-color: var(--border2); background: var(--bg3); }
.mentor-card.selected { border-color: var(--gold); background: #1d2b1d; }
.mentor-card.default-card { opacity: 0.7; cursor: default; }
.mentor-card.default-card:hover { border-color: var(--border); background: var(--bg2); }
.mentor-card .mentor-name { color: var(--text); font-size: 1em; margin-bottom: 4px; font-weight: 500; }
.mentor-card .mentor-subtitle { color: var(--muted); font-size: 0.82em; }
.mentor-card .mentor-badge { position: absolute; top: 10px; right: 10px; font-size: 0.7em; padding: 2px 8px; border-radius: 10px; font-weight: 500; }
.badge-default { background: var(--bg3); color: var(--muted); border: 1px solid var(--border); }
.badge-follow { background: #1d2b1d; color: var(--gold); border: 1px solid var(--gold); }
.badge-following { background: #1d2d1e; color: #7ab87c; border: 1px solid #5a8a5c; }
.onboarding-actions { display: flex; justify-content: flex-end; }

/* APP BODY */
.app-body { display: flex; flex: 1; overflow: hidden; min-height: 0; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-width);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--bg2);
}
@media (max-width: 768px) { .sidebar { display: none; } }
.sidebar-header {
  padding: 14px 16px;
  color: var(--muted);
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.new-chat-btn {
  color: var(--gold);
  cursor: pointer;
  font-size: 1.2em;
  line-height: 1;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.15s;
}
.new-chat-btn:hover { background: var(--bg3); }
.sidebar-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.sidebar-item {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 0.88em;
  color: var(--muted);
  border-radius: 0;
  transition: all 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 3px solid transparent;
}
.sidebar-item:hover { color: var(--text); background: var(--bg3); }
.sidebar-item.active { color: var(--text); border-left-color: var(--gold); background: var(--bg3); }
.sidebar-empty { padding: 20px 16px; color: var(--dim); font-size: 0.85em; }
.sidebar-login-prompt { padding: 16px; color: var(--dim); font-size: 0.82em; text-align: center; line-height: 1.7; }
.sidebar-login-prompt span { color: var(--gold); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* CHAT AREA */
#chat-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; background: var(--bg); }
.subtitle-bar {
  padding: 10px 20px;
  color: var(--muted);
  font-size: 0.82em;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg2);
}
#chat {
  flex: 1;
  overflow-y: auto;
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
  -webkit-overflow-scrolling: touch;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  align-self: center;
  box-sizing: border-box;
}
@media (min-width: 768px) { #chat { padding: 40px 32px; } }

/* MESSAGES — ChatGPT style */
.message {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  animation: fadeIn 0.2s ease;
}
.message:last-child { border-bottom: none; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }
.message.user { align-items: flex-end; }
.message.assistant { align-items: flex-start; }

.speaker {
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.assistant .speaker { color: var(--gold); font-weight: 700; }

.bubble {
  font-size: 1em;
  line-height: 1.75;
  border-radius: 12px;
}
.user .bubble {
  background: #2a3826;
  border: 1px solid #3d5038;
  color: var(--text);
  padding: 12px 18px;
  max-width: 75%;
}
.assistant .bubble {
  background: transparent;
  color: var(--text);
  padding: 0;
  max-width: 100%;
}

.thinking { color: var(--dim); font-style: italic; font-size: 0.9em; padding: 4px 0; }
.thinking::after { content: ''; animation: dots 1.5s infinite; }
@keyframes dots { 0%, 20% { content: '.'; } 40% { content: '..'; } 60%, 100% { content: '...'; } }

/* EMPTY STATE */
.empty-state {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding: 40px 20px;
}
.empty-state .name {
  font-size: 1.6em;
  font-weight: 600;
  color: var(--text);
}
.empty-state .tagline {
  font-size: 0.95em;
  color: var(--muted);
  line-height: 1.5;
}
.empty-state .hint {
  font-size: 0.88em;
  color: var(--dim);
  margin-top: 8px;
  max-width: 360px;
}

/* FOOTER / INPUT */
footer {
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}
@media (min-width: 768px) { footer { padding: 16px 32px 24px; } }
.input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 796px;
  margin: 0 auto;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  transition: border-color 0.15s;
}
.input-row:focus-within { border-color: var(--border2); }
textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 1em;
  resize: none;
  outline: none;
  min-height: 26px;
  max-height: 160px;
  line-height: 1.6;
  -webkit-appearance: none;
  padding: 0;
}
textarea::placeholder { color: var(--dim); }
button#send {
  background: var(--gold);
  border: none;
  color: var(--bg);
  padding: 8px 16px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9em;
  font-weight: 600;
  border-radius: 8px;
  transition: background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 36px;
  align-self: flex-end;
}
button#send:hover { background: #8fca8f; }
button#send:disabled { background: var(--border); color: var(--dim); cursor: not-allowed; }

/* SETTINGS PAGE */
#page-settings { overflow-y: auto; background: var(--bg); }
.settings-body { max-width: 600px; margin: 0 auto; padding: 48px 24px; }
.settings-body h2 { color: var(--text); font-size: 1.3em; font-weight: 600; margin-bottom: 32px; }
.settings-section { margin-bottom: 48px; }
.settings-section h3 {
  color: var(--muted);
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.mentor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.mentor-row:last-child { border-bottom: none; }
.mentor-row-info .mentor-name { font-size: 0.95em; color: var(--text); margin-bottom: 3px; font-weight: 500; }
.mentor-row-info .mentor-subtitle { font-size: 0.82em; color: var(--muted); }
.follow-btn {
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 0.85em;
  cursor: pointer;
  font-family: inherit;
  border: 1px solid;
  font-weight: 500;
  transition: all 0.15s;
}
.follow-btn.follow { border-color: var(--gold); color: var(--gold); background: transparent; }
.follow-btn.follow:hover { background: #1d2b1d; }
.follow-btn.following { border-color: #5a8a5c; color: #7ab87c; background: #1d2d1e; }
.follow-btn.following:hover { border-color: #c06060; color: #c07070; background: #2a1a1a; }
.default-label { font-size: 0.82em; color: var(--dim); }
