/*!
 * Homeo Assist - AI Homeopathy Treatment Assistant
 * Copyright (c) 2025-2026 Vijaya Kumar Sala. All rights reserved.
 * Unauthorized copying, modification, or distribution is strictly prohibited.
 */

/* ===============================
   MODERN, SMOOTH UI — Homeo Assist
   Gradients + subtle animations + polished
   =============================== */

:root {
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
  --vh: 1vh;

  /* Color palette */
  --primary: #1a8a5c;
  --primary-dark: #14694a;
  --primary-light: #e8f5ee;
  --accent: #10b981;
  --accent-glow: rgba(16, 185, 129, 0.25);
  --bg: #f0f4f3;
  --surface: #ffffff;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
  --shadow-glow: 0 0 20px var(--accent-glow);
  --radius: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  /* Bubble colors */
  --user-bg: linear-gradient(135deg, #3b82f6, #2563eb);
  --user-text: #fff;
  --bot-bg: var(--surface);
  --bot-text: var(--text);
  --bot-border: var(--border);
}

html, body { height: 100%; margin: 0; padding: 0; }
* { box-sizing: border-box; }

body {
  font-family: 'Inter', 'Noto Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

/* ─── Container ─── */
.app-container {
  max-width: 720px;
  margin: 0 auto;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  height: calc(var(--vh) * 100);
  height: 100svh;
  height: 100dvh;
  min-height: -webkit-fill-available;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

/* ─── Header ─── */
header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: 6px 12px;
  display: flex; flex-direction: row; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
  box-shadow: 0 2px 12px rgba(26, 138, 92, 0.3);
  flex-shrink: 0;
  min-height: 0;
}
header h1 {
  margin: 0; font-size: 16px; font-weight: 700;
  letter-spacing: -0.3px;
  display: flex; align-items: center; gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.header-controls {
  margin-top: 0;
  display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; justify-content: flex-end;
  overflow-x: auto;
  flex-shrink: 1;
  min-width: 0;
}

/* Credits badge */
.header-controls #credits-badge,
.header-controls #creditsBadge,
.header-controls [data-credits-badge] {
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(8px);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.2px;
  transition: var(--transition);
  cursor: pointer;
}
.header-controls #credits-badge:hover { background: rgba(255,255,255,0.25); }

/* Login / Account buttons */
.login-btn, .header-controls .login-btn {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-weight: 600; font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
}
.login-btn:hover {
  background: rgba(255,255,255,0.22);
  transform: translateY(-1px);
}

/* Dropdowns */
.dropdown {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.25);
  font-size: 12px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  cursor: pointer;
  transition: var(--transition);
}
.dropdown:focus {
  outline: none;
  border-color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.2);
}
.dropdown option { background: var(--surface); color: var(--text); }

.voice-toggle-label {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; cursor: pointer; opacity: 0.9;
}
.voice-toggle-label input[type="checkbox"] { accent-color: var(--accent); }

/* Account menu */
.account-menu { position: relative; display: inline-block; }
.account-menu button {
  padding: 5px 12px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-radius: var(--radius-full);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.account-menu button:hover { background: rgba(255,255,255,0.22); }
.account-menu .menu {
  display: none; position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--surface); color: var(--text);
  min-width: 180px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 50; overflow: hidden;
}
.account-menu .menu a,
.account-menu .menu button {
  display: block; width: 100%; text-align: left;
  background: var(--surface); color: var(--text);
  padding: 10px 14px; border: none; border-bottom: 1px solid var(--border-light);
  cursor: pointer; font-size: 13px; transition: var(--transition);
}
.account-menu .menu a:hover,
.account-menu .menu button:hover { background: var(--primary-light); }
.account-menu .menu a:last-child,
.account-menu .menu button:last-child { border-bottom: none; }

/* ─── Chatbox ─── */
main.chatbox {
  flex: 1 1 0;
  min-height: 0;
  padding: 12px 12px;
  overflow-y: auto;
  background: var(--bg);
  scroll-behavior: smooth;
  background-image:
    radial-gradient(circle at 20% 50%, rgba(16,185,129,0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(59,130,246,0.03) 0%, transparent 50%);
}

/* ─── Message Bubbles ─── */
.user-msg, .bot-msg {
  margin: 6px 0; padding: 10px 14px;
  border-radius: var(--radius-lg);
  line-height: 1.5; font-size: 14px;
  max-width: 85%; word-wrap: break-word;
  animation: messageSlide 0.3s ease-out;
  position: relative;
}
@keyframes messageSlide {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.user-msg {
  background: var(--user-bg);
  color: var(--user-text);
  margin-left: auto;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
  font-weight: 500;
}
.user-msg strong { display: none; } /* Hide "You:" for cleaner look */
.bot-msg {
  background: var(--bot-bg);
  color: var(--bot-text);
  margin-right: auto;
  border: 1px solid var(--bot-border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}
.bot-msg strong {
  color: var(--primary);
  font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block; margin-bottom: 4px;
}

/* ─── Typing Indicator ─── */
.typing-indicator { background: var(--surface) !important; border: 1px solid var(--border) !important; padding: 12px 16px !important; }
.typing-indicator .typing-dots { display: inline-flex; gap: 4px; align-items: center; }
.typing-indicator .typing-dots span {
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
  animation: typingPulse 1.4s infinite ease-in-out;
  font-size: 0;
}
.typing-indicator .typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingPulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

/* ─── Input Composer ─── */
.input-group {
  display: flex; gap: 6px;
  padding: 8px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  align-items: center;
  flex-shrink: 0;
}
.input-group input {
  flex: 1; padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  transition: var(--transition);
  outline: none;
}
.input-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--surface);
}
.input-group input::placeholder { color: var(--text-muted); }
.input-group button {
  padding: 10px 16px; border: none;
  border-radius: var(--radius-full);
  cursor: pointer; font-weight: 600; font-size: 14px;
  transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
  min-width: 44px;
}
.input-group button[onclick="sendAnswer()"],
.input-group .send-btn {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.input-group button[onclick="sendAnswer()"]:hover,
.input-group .send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--accent-glow);
}
.input-group #micBtn {
  background: var(--bg);
  color: var(--text);
  border: 1.5px solid var(--border);
  font-size: 16px; padding: 10px;
}
.input-group #micBtn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

/* ─── Bottom Action Row ─── */
.btn-row {
  display: flex; justify-content: center; gap: 6px;
  padding: 4px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}
.btn-row button {
  padding: 4px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  background: var(--surface);
  color: var(--text-secondary);
  font-weight: 600; font-size: 11px;
  transition: var(--transition);
}
.btn-row button:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* ─── Disclaimer ─── */
.disclaimer-inline {
  margin: 0; padding: 0;
  font-size: 11px; line-height: 1.5;
  color: var(--text-secondary);
  background: linear-gradient(to right, #fffbeb, #fef3c7);
  border-left: 3px solid #f59e0b;
  flex-shrink: 0;
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease, padding 0.3s ease;
}
.disclaimer-inline.expanded {
  max-height: 200px;
  padding: 10px 14px;
}
.disclaimer-inline a { color: var(--primary); }
.disclaimer-toggle {
  display: flex; justify-content: center;
  padding: 2px 0;
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  cursor: pointer;
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
  user-select: none;
}
.disclaimer-toggle:hover { color: var(--primary); background: #fef3c7; }

/* ─── Footer ─── */
footer {
  text-align: center; font-size: 10px; padding: 4px 10px;
  background: var(--surface);
  color: var(--text-muted);
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}
footer a { color: var(--text-secondary); text-decoration: none; transition: var(--transition); }
footer a:hover { color: var(--primary); }

/* ─── CTA Buttons ─── */
.cta-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  padding: 9px 18px;
  border-radius: var(--radius-full);
  text-decoration: none;
  font-weight: 600; font-size: 13px;
  border: none; cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 2px 8px var(--accent-glow);
}
.cta-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--accent-glow);
}
.cta-button.secondary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 2px 8px rgba(59,130,246,0.25);
}
.cta-button.ghost {
  background: transparent; color: var(--text-secondary);
  border: 1.5px solid var(--border); box-shadow: none;
}
.cta-button.ghost:hover {
  background: var(--bg); color: var(--text);
  box-shadow: none; transform: none;
}

/* ─── Modals ─── */
#otp-modal > div,
#account-modal > div,
#voice-modal > div {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 20px;
  animation: modalSlide 0.25s ease-out;
}
@keyframes modalSlide {
  from { opacity: 0; transform: translateY(-20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
#otp-modal input, #voice-modal input, #voice-modal select {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 14px;
  transition: var(--transition);
  outline: none; margin-bottom: 8px;
}
#otp-modal input:focus, #voice-modal input:focus, #voice-modal select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ─── Recharge Banner ─── */
#recharge-banner {
  background: linear-gradient(to right, #fffbeb, #fef3c7) !important;
  border-top: 2px solid #f59e0b !important;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.08) !important;
}

/* ─── Pricing Cards ─── */
.pricing-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px; transition: var(--transition);
}
.pricing-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

/* ─── Landing ─── */
.landing-page .logo { width: 80px; height: 80px; border-radius: 20%; object-fit: cover; margin-bottom: 8px; }
.landing-hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff; padding: 24px; text-align: center;
}
.features { max-width: 900px; margin: 8px auto; padding: 0 16px; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.feature-grid > div {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; transition: var(--transition);
}
.feature-grid > div:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }

/* ─── Scrollbar ─── */
main.chatbox::-webkit-scrollbar { width: 5px; }
main.chatbox::-webkit-scrollbar-track { background: transparent; }
main.chatbox::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 10px; }
main.chatbox::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ─── Mobile ─── */
@media (max-width: 600px) {
  .app-container { border-radius: 0; box-shadow: none; max-width: 100%; }
  header {
    padding: 4px 8px;
    flex-wrap: wrap;
    gap: 2px;
  }
  header h1 { font-size: 15px; }
  .header-controls {
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
    font-size: 11px;
  }
  .header-controls .voice-toggle-label { font-size: 10px; }
  .header-controls #credits-badge,
  .header-controls [data-credits-badge] { font-size: 10px; padding: 3px 8px; }
  .header-controls .dropdown { font-size: 10px; padding: 3px 6px; }
  .header-controls .login-btn { font-size: 10px; padding: 3px 8px; }
  .account-menu button { font-size: 10px; padding: 3px 8px; }

  main.chatbox { padding: 8px 8px; }
  .user-msg, .bot-msg { max-width: 92%; font-size: 13.5px; padding: 8px 12px; }

  .input-group { padding: 6px 8px; gap: 4px; }
  .input-group input { padding: 8px 12px; font-size: 13px; }
  .input-group button { padding: 8px 12px; min-width: 38px; font-size: 13px; }

  .btn-row { padding: 3px 8px; gap: 4px; }
  .btn-row button { padding: 3px 8px; font-size: 10px; }

  .disclaimer-toggle { font-size: 9px; padding: 1px 0; }
  .disclaimer-inline.expanded { padding: 6px 10px; font-size: 10px; }

  footer { font-size: 9px; padding: 3px 8px; }

  /* Hide APK download on mobile to save space */
  #apkDownloadContainer { display: none !important; }
}

/* ─── Android ─── */
body.android #disclaimer { max-height: 0; padding: 0; }
body.android footer { font-size: 9px; padding: 3px; }
body.android #apkDownloadContainer { display: none !important; }
@media (max-height: 640px) {
  .disclaimer-inline { max-height: 0 !important; padding: 0 !important; }
  .disclaimer-toggle { display: none; }
  footer { font-size: 9px; padding: 2px 6px; }
  .input-group { padding: 5px 8px; }
  .btn-row { padding: 2px 8px; }
  #apkDownloadContainer { display: none !important; }
}

/* ─── Print ─── */
@media print {
  header, .input-group, .btn-row, footer, #disclaimer { display: none; }
  .app-container { box-shadow: none; height: auto; }
  main.chatbox { overflow: visible; }
}

/* ─── Structured Intake Question Widget ─── */
.question-widget-card {
  background: var(--primary-light, #e8f5ee);
  border: 1.5px solid var(--primary, #16a34a);
  border-radius: var(--radius-lg, 16px);
  padding: 16px;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.08));
  transition: opacity 0.3s;
}

.widget-question {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.widget-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text, #1f2937);
  line-height: 1.4;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--surface, #fff);
  border: 1.5px solid var(--border, #e5e7eb);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text, #1f2937);
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.radio-option:hover {
  border-color: var(--primary, #16a34a);
  background: var(--primary-light, #e8f5ee);
}

.radio-option input[type="radio"] {
  accent-color: var(--primary, #16a34a);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.radio-option:has(input:checked) {
  border-color: var(--primary, #16a34a);
  background: #c6ead9;
  font-weight: 600;
}

.checkbox-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--surface, #fff);
  border: 1.5px solid var(--border, #e5e7eb);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text, #1f2937);
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.checkbox-option:hover {
  border-color: var(--primary, #16a34a);
  background: var(--primary-light, #e8f5ee);
}

.checkbox-option input[type="checkbox"] {
  accent-color: var(--primary, #16a34a);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.checkbox-option:has(input:checked) {
  border-color: var(--primary, #16a34a);
  background: #c6ead9;
  font-weight: 600;
}

.widget-hint {
  font-size: 11px;
  color: var(--text-muted, #6b7280);
  margin-bottom: 4px;
  font-style: italic;
}

.scale-widget {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.scale-slider {
  width: 100%;
  accent-color: var(--primary, #16a34a);
  height: 6px;
  cursor: pointer;
}

.scale-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary, #16a34a);
  text-align: center;
  line-height: 1;
}

.scale-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary, #6b7280);
}

.widget-number-input,
.widget-text-input {
  padding: 9px 12px;
  border: 1.5px solid var(--border, #e5e7eb);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text, #1f2937);
  background: var(--surface, #fff);
  width: 100%;
  max-width: 200px;
  transition: border-color 0.15s;
}

.widget-number-input:focus,
.widget-text-input:focus {
  outline: none;
  border-color: var(--primary, #16a34a);
}

.widget-submit-btn {
  margin-top: 6px;
  padding: 12px 24px;
  background: var(--primary, #16a34a);
  color: #fff;
  border: none;
  border-radius: var(--radius-full, 9999px);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  align-self: stretch;
  transition: background 0.2s, transform 0.1s;
  letter-spacing: 0.3px;
}

.widget-submit-btn:hover {
  background: var(--primary-dark, #14694a);
}

.widget-submit-btn:active {
  transform: scale(0.98);
}

.widget-submit-btn:disabled {
  background: var(--text-muted, #9ca3af);
  cursor: not-allowed;
  transform: none;
}

/* ── Structured bot report (final answer) ─────────────────────────────── */
.bot-report {
  display: block;
  padding: 0;
  background: transparent;
}

.bot-name {
  display: block;
  margin-bottom: 6px;
  color: var(--primary, #16a34a);
  font-size: 13px;
}

.bot-report-body {
  background: #f0faf5;
  border: 1.5px solid #a7d9be;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text, #1f2937);
}

.bot-section-head {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary, #16a34a);
  margin: 12px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid #c6ead9;
}

.bot-section-head:first-child {
  margin-top: 0;
}

.bot-section-subhead {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #374151);
  margin: 8px 0 4px;
}

.bot-ul, .bot-ol {
  margin: 4px 0 8px 0;
  padding-left: 18px;
}

.bot-ul li, .bot-ol li {
  margin-bottom: 5px;
  line-height: 1.55;
}

.bot-p {
  margin: 4px 0 6px;
}

.bot-divider {
  border: none;
  border-top: 1px dashed #c6ead9;
  margin: 10px 0 8px;
}

.bot-report-body em {
  color: var(--text-muted, #6b7280);
  font-size: 12px;
}