/* ── Viewer (public) styles ───────────────────────────────────────────────── */
:root {
  --mi-primary: #FFD400;
  --mi-primary-dark: #FFD400;
  --mi-dark: #0c559e;
}

body {
  font-size: 0.95rem;
}

/* ── Navigation ───────────────────────────────────────────────────────────── */
.viewer-nav {
  background: var(--mi-primary-dark);
  padding: 0.75rem 1.5rem;
}

.viewer-nav .nav-brand {
  color: rgb(24, 38, 172);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
}

.viewer-nav .nav-brand:hover {
  color: rgb(52, 67, 195);
}

/* ── Viewer nav buttons ──────────────────────────────────────────────────── */
.viewer-nav-btn {
  display: inline-block;
  padding: 0.3rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--mi-dark);
  background: rgba(255,255,255,0.5);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 0.375rem;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.viewer-nav-btn:hover {
  background: rgba(255,255,255,0.85);
  color: var(--mi-dark);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.viewer-nav-btn.active {
  background: #fff;
  color: var(--mi-dark);
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  border-color: rgba(0,0,0,0.12);
}

/* ── Hero ─────────────────────────────────────────────────────────────────── */
.hero-section {
  min-height: 85vh;
  display: flex;
  align-items: center;
  background: linear-gradient(135deg, #2c3e50 0%, #3d5a80 100%);
  color: #fff;
}

.hero-section h1 {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.hero-section p {
  font-size: 1.1rem;
  opacity: 0.85;
}

/* ── Tag input (submit form) ──────────────────────────────────────────────── */
.tag-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0.375rem;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  min-height: 2.5rem;
  background: #fff;
  cursor: text;
}

.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--mi-primary);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 500;
}

.tag-badge .tag-remove {
  cursor: pointer;
  opacity: 0.75;
  font-size: 0.9rem;
}

.tag-badge .tag-remove:hover {
  opacity: 1;
}

.countries-dropdown-wrapper {
  position: relative;
}

.countries-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: #fff;
  border: 1px solid #dee2e6;
  border-top: none;
  border-radius: 0 0 0.375rem 0.375rem;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.countries-dropdown-item {
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background 0.1s;
}

.countries-dropdown-item:hover,
.countries-dropdown-item.highlighted {
  background: #f0f4ff;
  color: var(--mi-primary);
}

/* ── Research page ────────────────────────────────────────────────────────── */
.research-hero {
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.research-search-box {
  max-width: 640px;
  width: 100%;
}

.research-search-box h2 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--mi-dark);
  margin-bottom: 1.25rem;
}

.chat-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem 0;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 62vh;
  overflow-y: auto;
  padding-right: 0.5rem;
  margin-bottom: 1rem;
}

.chat-bubble {
  padding: 1rem 1.25rem;
  border-radius: 1rem;
  line-height: 1.6;
  word-break: break-word;
}

.chat-bubble.user {
  background: rgb(229, 243, 255);
  color: rgb(0, 40, 77);
  align-self: flex-end;
  border-bottom-right-radius: 0.25rem;
  max-width: 80%;
  white-space: pre-wrap;  /* plain text — preserve line breaks */
}

.chat-bubble.assistant {
  background: #f1f3f4;
  color: #2c3e50;
  align-self: flex-start;
  border-bottom-left-radius: 0.25rem;
  max-width: 92%;
}

/* Streaming cursor */
.chat-bubble.assistant.streaming .bubble-text::after {
  content: '▋';
  animation: blink 0.75s step-end infinite;
  color: #FFD400;
}

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

/* ── Tighten markdown spacing inside assistant bubbles ────────────────────── */
.chat-bubble.assistant .bubble-text p {
  margin-top: 0;
  margin-bottom: 0.35rem;
}
.chat-bubble.assistant .bubble-text p:last-child { margin-bottom: 0; }

.chat-bubble.assistant .bubble-text h1,
.chat-bubble.assistant .bubble-text h2,
.chat-bubble.assistant .bubble-text h3,
.chat-bubble.assistant .bubble-text h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-top: 0.65rem;
  margin-bottom: 0.15rem;
  line-height: 1.3;
}
.chat-bubble.assistant .bubble-text h1:first-child,
.chat-bubble.assistant .bubble-text h2:first-child,
.chat-bubble.assistant .bubble-text h3:first-child { margin-top: 0; }

.chat-bubble.assistant .bubble-text ul,
.chat-bubble.assistant .bubble-text ol {
  padding-left: 1.2rem;
  margin-top: 0.1rem;
  margin-bottom: 0.35rem;
}
.chat-bubble.assistant .bubble-text li {
  margin-bottom: 0.1rem;
}
.chat-bubble.assistant .bubble-text li:last-child { margin-bottom: 0; }

.chat-bubble.assistant .bubble-text code {
  background: rgba(0, 0, 0, 0.07);
  border-radius: 3px;
  padding: 0.1rem 0.3rem;
  font-size: 0.85em;
}

.chat-bubble.assistant .bubble-text pre {
  background: rgba(0, 0, 0, 0.06);
  border-radius: 0.375rem;
  padding: 0.6rem 0.75rem;
  overflow-x: auto;
  margin: 0.3rem 0;
}

.chat-bubble.assistant .bubble-text pre code {
  background: none;
  padding: 0;
  font-size: 0.82em;
}

.chat-bubble.assistant .bubble-text strong { font-weight: 600; }

.chat-bubble.assistant .bubble-text hr {
  border-color: rgba(0,0,0,0.1);
  margin: 0.4rem 0;
}

/* ── Bubble copy button ────────────────────────────────────────────────────── */
.bubble-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.bubble-copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #9aa0a6;
  padding: 0.15rem 0.3rem;
  border-radius: 0.25rem;
  font-size: 0.82rem;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}

.bubble-copy-btn:hover {
  color: #2c3e50;
  background: rgba(0, 0, 0, 0.06);
}

.bubble-copy-btn.copied { color: #27ae60; }

.chat-input-bar {
  border-top: 1px solid #e9ecef;
  padding-top: 1rem;
  background: #fff;
  position: sticky;
  bottom: 0;
}

.chat-input-bar .form-control:focus {
  box-shadow: none;
  border-color: #dee2e6;
}

/* ── Submit success ───────────────────────────────────────────────────────── */
.success-page {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Speech button ────────────────────────────────────────────────────────── */
#speech-btn.listening {
  background: #dc3545;
  border-color: #dc3545;
  color: #fff;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-mi {
  background: var(--mi-primary);
  color: #fff;
  border: none;
}

.btn-mi:hover {
  background: var(--mi-primary-dark);
  color: #fff;
}

/* ── Script response bubble ───────────────────────────────────────────────── */
.chat-bubble.assistant.script-response {
  background: #1e1e2e;
  color: #cdd6f4;
  border-left: 3px solid #FFD400;
}

.chat-bubble.assistant.script-response .bubble-text {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.88rem;
  line-height: 1.7;
}

.chat-bubble.assistant.script-response .bubble-text p {
  margin-bottom: 0.5rem;
}

.chat-bubble.assistant.script-response .bubble-text strong {
  color: #FFD400;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.chat-bubble.assistant.script-response .bubble-actions {
  border-top-color: rgba(255,255,255,0.1);
}

.chat-bubble.assistant.script-response .bubble-copy-btn {
  color: rgba(255,255,255,0.4);
}

.chat-bubble.assistant.script-response .bubble-copy-btn:hover {
  color: #cdd6f4;
  background: rgba(255,255,255,0.08);
}

.script-copy-btn {
  background: #FFD400;
  color: #1e1e2e;
  border: none;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.85rem;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: opacity 0.15s;
}

.script-copy-btn:hover { opacity: 0.85; }
.script-copy-btn.copied { background: #27ae60; color: #fff; }

/* ── Suggestion chips ─────────────────────────────────────────────────────── */
.suggestions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.65rem 0 0.25rem;
}

.suggestion-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.85rem;
  border: 1px solid #dee2e6;
  border-radius: 999px;
  background: #fff;
  color: #2c3e50;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.suggestion-chip:hover {
  background: var(--mi-dark);
  border-color: var(--mi-dark);
  color: #fff;
}

/* ── Passport answer edit ─────────────────────────────────────────────────── */
.passport-answer-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.passport-edit-btn {
  background: none;
  border: none;
  color: #adb5bd;
  font-size: 0.72rem;
  padding: 0.15rem 0.4rem;
  cursor: pointer;
  transition: color 0.12s;
  margin-top: 0.15rem;
}
.passport-edit-btn:hover { color: #667eea; }

.passport-inline-edit {
  width: 100%;
  max-width: 520px;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 0.625rem;
  padding: 0.75rem;
  margin-top: 0.25rem;
}

/* ── Passport section divider ─────────────────────────────────────────────── */
.passport-section-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  margin: 1.25rem 0;
  padding: 0;
}

.passport-section-line {
  height: 1px;
  width: 100%;
  background: linear-gradient(90deg, transparent, #667eea 30%, #667eea 70%, transparent);
  opacity: 0.35;
}

.passport-section-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #667eea;
  padding: 0.2rem 1rem;
  background: #eef0ff;
  border-radius: 999px;
}

.passport-section-helper {
  font-size: 0.75rem;
  color: #6c757d;
  text-align: center;
  margin-top: 0.1rem;
}
