/* ============================================================
   style.css — Minimal academic/medical UI. Light + dark theme.
   ============================================================ */

:root {
  --bg: #f7f9fb;
  --surface: #ffffff;
  --surface-alt: #eef2f6;
  --border: #dde3ea;
  --text: #1c2733;
  --text-muted: #5b6b7c;
  --primary: #0e7c86;
  --primary-dark: #0a5f67;
  --primary-contrast: #ffffff;
  --accent: #2f6fed;
  --danger: #c0392b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 30, 40, 0.08), 0 1px 2px rgba(20, 30, 40, 0.06);
  --font: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html[data-theme="dark"] {
  --bg: #121820;
  --surface: #1a222c;
  --surface-alt: #212b36;
  --border: #2d3947;
  --text: #e7edf3;
  --text-muted: #9aacbd;
  --primary: #2bb6c2;
  --primary-dark: #1f8e98;
  --primary-contrast: #0c1116;
  --accent: #6b9bff;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Pages with a fixed app shell (currently: chatbot) lock the viewport
   and let only the chat log scroll internally, like Claude/ChatGPT. */
body.app-page {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.app-page .app-layout {
  flex: 1;
  min-height: 0; /* required so the flex child can shrink and scroll */
}

.hidden {
  display: none !important;
}

a {
  color: var(--accent);
}

button {
  font-family: inherit;
}

/* ---------- Top nav ---------- */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--primary-dark);
}

.brand .cross {
  color: var(--primary);
  font-size: 1.1rem;
}

.nav-links {
  display: flex;
  gap: 0.25rem;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-muted);
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-size: 0.92rem;
}

.nav-links a.active,
.nav-links a:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lang-switch {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.lang-switch button {
  border: none;
  background: var(--surface);
  color: var(--text-muted);
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  font-size: 0.8rem;
}

.lang-switch button.active {
  background: var(--primary);
  color: var(--primary-contrast);
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  font-size: 0.95rem;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-contrast);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ---------- Auth page ---------- */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
}

.auth-card .brand {
  justify-content: center;
  margin-bottom: 0.25rem;
  font-size: 1.1rem;
}

.auth-tagline {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 0 0 1.5rem;
}

.auth-card h1 {
  font-size: 1.3rem;
  text-align: center;
  margin: 0 0 1.25rem;
}

.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.field input {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

.field input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.auth-error {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.2em;
  margin-bottom: 0.5rem;
}

.auth-submit {
  width: 100%;
  margin-top: 0.25rem;
}

.auth-toggle-row {
  text-align: center;
  margin-top: 1rem;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.88rem;
}

.auth-loading {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.lang-switch.centered {
  justify-content: center;
  margin: 0 auto 1.25rem;
  width: fit-content;
}

/* ---------- App layout (chatbot / profile) ---------- */
.app-layout {
  display: flex;
  min-height: calc(100vh - 57px);
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem;
  overflow-y: auto;
}

.sidebar h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 0.6rem;
}

.section-chip {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.55rem 0.6rem;
  margin-bottom: 0.3rem;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

.section-chip:hover {
  background: var(--surface-alt);
}

.section-chip.active {
  background: var(--primary);
  color: var(--primary-contrast);
}

.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.chat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}

.examples-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
}

.example-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
}

.example-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.empty-state {
  color: var(--text-muted);
  text-align: center;
  margin: auto;
  font-size: 0.9rem;
  max-width: 320px;
}

.msg {
  display: flex;
}

.msg-user {
  justify-content: flex-end;
}

.msg-model {
  justify-content: flex-start;
}

.bubble {
  max-width: 75%;
  padding: 0.6rem 0.85rem;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
  box-shadow: var(--shadow);
}

.msg-user .bubble {
  background: var(--primary);
  color: var(--primary-contrast);
  border-bottom-right-radius: 3px;
}

.msg-model .bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
}

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

.bubble p {
  margin: 0 0 0.5em;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.bubble ul,
.bubble ol {
  margin: 0.2em 0 0.6em;
  padding-left: 1.2em;
}

.bubble li {
  margin-bottom: 0.3em;
}

.bubble li:last-child {
  margin-bottom: 0;
}

.bubble strong {
  color: var(--primary);
}

html[data-theme="dark"] .msg-model .bubble strong {
  color: var(--primary);
}

.chat-form {
  display: flex;
  gap: 0.6rem;
  padding: 0.9rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.chat-form input {
  flex: 1;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.92rem;
}

.chat-form input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

/* ---------- Profile page ---------- */
.profile-wrap {
  max-width: 480px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  text-align: center;
}

.profile-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 1rem;
  border: 2px solid var(--border);
}

.profile-field {
  text-align: left;
  border-top: 1px solid var(--border);
  padding: 0.75rem 0;
}

.profile-field .label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.profile-field .value {
  font-size: 0.98rem;
  margin-top: 0.15rem;
  word-break: break-word;
}

.profile-card .btn {
  margin-top: 1.25rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 800px) {
  .app-layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar h2 {
    margin-top: 0;
  }
  #section-list {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
  }
  .section-chip {
    width: auto;
    white-space: nowrap;
  }
  .bubble {
    max-width: 88%;
  }
}

@media (max-width: 480px) {
  .topnav {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .nav-links a {
    font-size: 0.85rem;
    padding: 0.35rem 0.5rem;
  }
}
