/* ============================================================
   VoilaMed Chat Page Styles
   ============================================================ */

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* ─── Ambient Background Gradients ────────────────────────── */

.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.ambient-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
}

.ambient-blob-1 {
  top: -25%;
  right: -15%;
  width: 55%;
  height: 55%;
  background: rgba(186, 230, 230, 0.6);
}

.ambient-blob-2 {
  top: -20%;
  right: -5%;
  width: 50%;
  height: 50%;
  background: rgba(191, 219, 254, 0.65);
}

.ambient-blob-3 {
  top: -10%;
  right: 5%;
  width: 40%;
  height: 40%;
  background: rgba(224, 242, 254, 0.5);
}

/* Ensure all content sits above the gradient */
.chat-header,
.intake-overlay,
.chat-area {
  position: relative;
  z-index: 1;
}

/* ─── Header ──────────────────────────────────────────────── */

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

.chat-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--fg);
  font-weight: 600;
  font-size: 1.125rem;
}

.chat-header-logo {
  height: 30px;
  width: auto;
}

.chat-header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--fg-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s infinite;
}

/* ─── Intake Overlay ──────────────────────────────────────── */

.intake-overlay {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.intake-card {
  width: 100%;
  max-width: 520px;
  padding: 40px;
  animation: scaleIn 0.4s ease;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

.intake-card-header {
  text-align: center;
  margin-bottom: 32px;
}

.intake-card-header h2 {
  margin-bottom: 8px;
  font-size: 1.75rem;
}

.intake-card-header p {
  font-size: 1rem;
}

.intake-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--fg);
}

/* ─── Form Validation ────────────────────────────────────── */

.input-error {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15);
}

.validation-msg {
  display: block;
  font-size: 0.75rem;
  color: #ef4444;
  margin-top: 4px;
  animation: fadeIn 0.2s ease;
}

/* ─── Symptom Search ──────────────────────────────────────── */

.search-box {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search-input {
  padding-left: 42px !important;
}

.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 240px;
  overflow-y: auto;
  z-index: 50;
  animation: slideDown 0.2s ease;
}

.autocomplete-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 0.9375rem;
  color: var(--fg);
  transition: background var(--transition-fast);
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--accent-light);
  color: var(--accent);
}

.match-score {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}

/* ─── Selected Symptoms ───────────────────────────────────── */

.selected-symptoms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
}

.symptom-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid rgba(26, 138, 138, 0.2);
  animation: scaleIn 0.2s ease;
}

.remove-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--accent);
  transition: all var(--transition-fast);
  line-height: 1;
}

.remove-btn:hover {
  background: rgba(26, 138, 138, 0.2);
}

/* ─── Chat Area ───────────────────────────────────────────── */

.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fadeIn 0.4s ease;
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  padding-bottom: 8px;
}

.chat-messages {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ─── Chat Messages ───────────────────────────────────────── */

.chat-msg {
  display: flex;
  gap: 12px;
  animation: fadeInUp 0.3s ease;
}

.chat-msg.user {
  flex-direction: row-reverse;
}

.chat-msg-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.chat-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.chat-msg.assistant .chat-msg-avatar {
  background: transparent;
}

/* No avatar for user messages */
.chat-msg.user .chat-msg-avatar {
  display: none;
}

.chat-msg-bubble {
  max-width: 75%;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.chat-msg.assistant .chat-msg-bubble {
  background: var(--card-bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
}

.chat-msg.user .chat-msg-bubble {
  background: var(--accent);
  color: white;
  border-top-right-radius: 4px;
}

/* ─── Typing Indicator ────────────────────────────────────── */

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 720px;
  margin: 8px auto 0;
  padding: 0 12px;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.4s ease infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

.typing-text {
  font-size: 0.8125rem;
  color: var(--muted);
}

/* ─── ChatGPT-Style Prompt Box ───────────────────────────── */

.chat-input-bar {
  flex-shrink: 0;
  padding: 12px 24px 20px;
  background: var(--bg);
}

.prompt-box {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  padding: 8px;
  background: white;
  border: 1px solid var(--border);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
  cursor: text;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.prompt-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 1px 8px rgba(26, 138, 138, 0.1);
}

.prompt-textarea {
  width: 100%;
  min-height: 48px;
  max-height: 200px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.4;
  color: var(--fg);
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  overflow-y: auto;
}

.prompt-textarea::placeholder {
  color: rgba(0, 0, 0, 0.35);
}

/* Hide scrollbar */
.prompt-textarea::-webkit-scrollbar { display: none; }
.prompt-textarea { -ms-overflow-style: none; scrollbar-width: none; }

/* ── Toolbar ── */
.prompt-toolbar {
  display: flex;
  align-items: center;
  padding: 4px 4px 2px;
}

.prompt-toolbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Icon button (mic) ── */
.prompt-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--fg-secondary);
  transition: all 0.15s ease;
}

.prompt-icon-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--fg);
}

/* Mic recording state */
.prompt-icon-btn.recording {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  animation: mic-pulse 1.5s ease infinite;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

/* ── Send button (circular, dark) ── */
.prompt-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--fg);
  border: none;
  cursor: pointer;
  color: white;
  transition: all 0.15s ease;
}

.prompt-send-btn:hover {
  background: var(--accent);
}

.prompt-send-btn:disabled {
  background: rgba(0, 0, 0, 0.15);
  cursor: default;
  pointer-events: none;
}

/* ─── Intake Complete Card ────────────────────────────────── */

.intake-complete-card {
  background: var(--card-bg);
  border: 2px solid var(--success);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  animation: scaleIn 0.4s ease;
  margin-top: 8px;
}

.intake-complete-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--success-light);
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 auto 16px;
}

.intake-complete-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 8px;
}

.intake-complete-desc {
  font-size: 0.9375rem;
  color: var(--fg-secondary);
  line-height: 1.5;
  margin-bottom: 20px;
}

.session-code-display {
  display: inline-block;
  padding: 12px 28px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: 'SFMono-Regular', 'Consolas', monospace;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: 0.05em;
  margin-bottom: 20px;
}

.intake-complete-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border);
  background: var(--card-bg);
  color: var(--fg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-copy:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-doctor-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: white;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.btn-doctor-link:hover {
  background: var(--accent-hover);
  color: white;
}

/* ─── Responsive ──────────────────────────────────────────── */

@media (max-width: 640px) {
  .intake-card {
    padding: 24px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .chat-msg-bubble {
    max-width: 85%;
  }

  .chat-input-bar {
    padding: 12px 16px 16px;
  }
}
