/* ── Chat Page ── */

html, body {
  height: auto;
  overflow: visible;
}

html {
  font-size: 110%;
}

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

/* ── Top Nav ── */

.pres-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: linear-gradient(180deg, var(--color-bg) 60%, transparent);
}

.pres-back {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--color-accent);
  text-decoration: none;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  transition: opacity 0.3s;
}

.pres-back:hover {
  opacity: 0.8;
}

.chat-nav-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  color: var(--color-text-dim);
  letter-spacing: 0.04em;
}

.clear-btn {
  background: none;
  border: 1px solid rgba(232, 228, 220, 0.15);
  border-radius: 2rem;
  color: var(--color-text-dim);
  font-family: var(--font-body);
  font-size: 0.8rem;
  padding: 0.3rem 0.8rem;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: color 0.25s, border-color 0.25s;
}

.clear-btn:hover {
  color: var(--color-accent);
  border-color: rgba(201, 169, 110, 0.4);
}

/* ── Chat Container ── */

.chat-container {
  flex: 1;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 5rem 1.5rem 10rem;
  display: flex;
  flex-direction: column;
}

/* ── Welcome Section ── */

.welcome-section {
  text-align: center;
  padding: 3rem 1rem 2rem;
  transition: opacity 0.4s ease, max-height 0.5s ease;
  overflow: hidden;
}

.welcome-section.hidden {
  opacity: 0;
  max-height: 0;
  padding: 0;
  pointer-events: none;
}

.welcome-title {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 300;
  color: var(--color-text);
  letter-spacing: 0.04em;
  margin-bottom: 0.8rem;
}

.welcome-subtitle {
  font-size: 1rem;
  color: var(--color-text-dim);
  line-height: 1.6;
  max-width: 540px;
  margin: 0 auto 2rem;
}

/* ── Loading ── */

.loading-indicator {
  margin-bottom: 1.5rem;
}

.loading-indicator.hidden {
  display: none;
}

.loading-pulse {
  font-size: 0.95rem;
  color: var(--color-text-dim);
  font-style: italic;
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ── Browse Dropdowns ── */

.browse-dropdowns {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  margin-bottom: 1.5rem;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.browse-select {
  width: 50%;
  min-width: 0;
  padding: 0.5rem 0.8rem;
  background: rgba(232, 228, 220, 0.06);
  border: 1px solid rgba(201, 169, 110, 0.3);
  border-radius: 0.5rem;
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23c9a96e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  padding-right: 2rem;
  transition: border-color 0.25s;
}

.browse-select:hover,
.browse-select:focus {
  border-color: var(--color-accent);
}

.browse-select:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.browse-select option {
  background: var(--color-bg);
  color: var(--color-text);
}

/* ── Suggestion Chips ── */

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  max-width: 600px;
  margin: 0 auto;
}

.suggestion-chip {
  padding: 0.45rem 1rem;
  border: 1px solid rgba(201, 169, 110, 0.35);
  border-radius: 2rem;
  background: rgba(201, 169, 110, 0.06);
  color: var(--color-accent);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s;
  letter-spacing: 0.02em;
}

.suggestion-chip:hover {
  background: rgba(201, 169, 110, 0.15);
  border-color: var(--color-accent);
}

/* ── Messages Area ── */

.messages-area {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

/* ── Message Bubbles ── */

.message {
  max-width: 92%;
  animation: fadeIn 0.3s ease;
}

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

.message-user {
  align-self: flex-end;
  background: rgba(201, 169, 110, 0.12);
  border: 1px solid rgba(201, 169, 110, 0.2);
  border-radius: 1.2rem 1.2rem 0.3rem 1.2rem;
  padding: 0.7rem 1.1rem;
  color: var(--color-text);
  font-size: 0.95rem;
  line-height: 1.5;
}

.message-bot {
  align-self: flex-start;
  border-left: 2px solid rgba(201, 169, 110, 0.3);
  padding: 0.5rem 0 0.5rem 1.2rem;
}

/* ── Entity Header ── */

.entity-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.entity-thumb {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(201, 169, 110, 0.3);
}

.entity-name {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--color-accent);
  letter-spacing: 0.03em;
}

.entity-dates {
  font-size: 0.8rem;
  color: var(--color-text-dim);
  margin-top: 0.1rem;
}

.entity-count {
  font-size: 0.85rem;
  color: var(--color-text-dim);
  margin-bottom: 1rem;
  font-style: italic;
}

/* ── Passage Cards ── */

.passage-group {
  margin-bottom: 1rem;
}

.passage-group-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 400;
  color: var(--color-text);
  margin-bottom: 0.5rem;
  letter-spacing: 0.03em;
}

.passage-group-date {
  font-size: 0.8rem;
  color: var(--color-text-dim);
  margin-left: 0.5rem;
}

.passage-card {
  background: rgba(232, 228, 220, 0.03);
  border-radius: 0.5rem;
  padding: 0.8rem 1rem;
  margin-bottom: 0.6rem;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--color-text);
  border: 1px solid rgba(232, 228, 220, 0.05);
}

.passage-card mark {
  background: rgba(201, 169, 110, 0.25);
  color: var(--color-text);
  padding: 0.05em 0.15em;
  border-radius: 2px;
}

/* ── Sources ── */

.sources-toggle {
  display: inline-block;
  margin-top: 0.8rem;
  font-size: 0.8rem;
  color: var(--color-text-dim);
  cursor: pointer;
  transition: color 0.2s;
  background: none;
  border: none;
  font-family: var(--font-body);
  padding: 0;
  letter-spacing: 0.02em;
}

.sources-toggle:hover {
  color: var(--color-accent);
}

.sources-list {
  display: none;
  margin-top: 0.5rem;
  padding-left: 0;
  list-style: none;
}

.sources-list.open {
  display: block;
}

.sources-list li {
  margin-bottom: 0.3rem;
}

.sources-list a {
  font-size: 0.8rem;
  color: var(--color-accent);
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.sources-list a:hover {
  opacity: 1;
  text-decoration: underline;
}

/* ── No Results ── */

.no-results {
  font-size: 0.95rem;
  color: var(--color-text-dim);
  line-height: 1.6;
}

.no-results-suggestions {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--color-text-dim);
  font-style: italic;
}

/* ── Input Bar ── */

.input-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 0.8rem 1rem 1rem;
  background: linear-gradient(0deg, var(--color-bg) 70%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.input-bar-inner {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.chat-input {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 1rem;
  background: rgba(232, 228, 220, 0.06);
  border: 1px solid rgba(232, 228, 220, 0.12);
  border-radius: 1.5rem;
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.25s;
}

.chat-input::placeholder {
  color: var(--color-text-dim);
  opacity: 0.6;
}

.chat-input:focus {
  border-color: rgba(201, 169, 110, 0.5);
}

.chat-input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(201, 169, 110, 0.3);
  background: rgba(201, 169, 110, 0.1);
  color: var(--color-accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.25s, border-color 0.25s;
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  background: rgba(201, 169, 110, 0.25);
  border-color: var(--color-accent);
}

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

/* ── Nav Actions ── */

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

/* ── Mode Toggle ── */

.mode-toggle {
  display: flex;
  border: 1px solid rgba(201, 169, 110, 0.35);
  border-radius: 1.5rem;
  overflow: hidden;
  flex-shrink: 0;
}

.mode-toggle-btn {
  background: none;
  border: none;
  padding: 0.45rem 0.8rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--color-text-dim);
  cursor: pointer;
  transition: background 0.25s, color 0.25s;
  letter-spacing: 0.02em;
}

.mode-toggle-btn.active {
  background: rgba(201, 169, 110, 0.25);
  color: var(--color-accent);
}

.mode-toggle-btn:hover:not(.active) {
  background: rgba(201, 169, 110, 0.08);
}

/* ── LLM Response ── */

.llm-response {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--color-text);
}

.llm-response h3, .llm-response h4, .llm-response h5 {
  font-family: var(--font-heading);
  font-weight: 400;
  color: var(--color-accent);
  letter-spacing: 0.03em;
  margin: 1.2rem 0 0.4rem;
}

.llm-response h3 { font-size: 1.15rem; }
.llm-response h4 { font-size: 1.02rem; }
.llm-response h5 { font-size: 0.92rem; }

.llm-response h3:first-child,
.llm-response h4:first-child,
.llm-response h5:first-child {
  margin-top: 0;
}

.llm-response p {
  margin: 0 0 0.8rem;
}

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

.llm-response strong {
  color: var(--color-accent);
  font-weight: 500;
}

.llm-response em {
  color: var(--color-text);
  font-style: italic;
}

.llm-response ul, .llm-response ol {
  margin: 0.4rem 0 0.8rem 1.2rem;
  padding: 0;
}

.llm-response li {
  margin-bottom: 0.3rem;
}

.llm-thinking {
  font-size: 0.9rem;
  color: var(--color-text-dim);
  font-style: italic;
  animation: pulse 1.8s ease-in-out infinite;
}

.llm-error {
  font-size: 0.88rem;
  color: #d4756a;
  line-height: 1.5;
}

/* ── Responsive ── */

@media (max-width: 768px) {
  .pres-nav {
    padding: 0.8rem 1rem;
  }

  .chat-container {
    padding: 4.5rem 1rem 9rem;
  }

  .welcome-title {
    font-size: 1.8rem;
  }

  .welcome-subtitle {
    font-size: 0.9rem;
  }

  .entity-name {
    font-size: 1.2rem;
  }

  .message {
    max-width: 96%;
  }
}

@media (max-width: 600px) {
  .chat-container {
    padding: 4rem 0.7rem 8rem;
  }

  .browse-dropdowns {
    flex-direction: column;
    gap: 0.5rem;
  }

  .browse-select {
    width: 100%;
    font-size: 0.82rem;
  }

  .welcome-title {
    font-size: 1.5rem;
  }

  .welcome-subtitle {
    font-size: 0.85rem;
  }

  .suggestion-chip {
    font-size: 0.78rem;
    padding: 0.4rem 0.8rem;
  }

  .passage-card {
    font-size: 0.82rem;
    padding: 0.6rem 0.8rem;
  }

  .input-bar {
    padding: 0.6rem 0.5rem 0.8rem;
  }

  .input-bar-inner {
    gap: 0.4rem;
  }

  .chat-input {
    font-size: 0.9rem;
    padding: 0.6rem 0.7rem;
  }

  .mode-toggle-btn {
    font-size: 0.72rem;
    padding: 0.4rem 0.55rem;
  }

  .send-btn {
    width: 36px;
    height: 36px;
  }
}
