/* ═══════════════════════════════════════════════════════════════════════════
   AyuSeva — Medical Theme Stylesheet (Baby Pink, Light Only)
   ═══════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=DM+Sans:wght@400;500;700&display=swap');

:root {
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 14px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.1);
  --transition: .3s cubic-bezier(.4,0,.2,1);

  /* Baby Pink Palette */
  --bg-primary: #FFF0F3;
  --bg-secondary: #FFFFFF;
  --bg-glass: rgba(255,255,255,.72);
  --bg-glass-strong: rgba(255,255,255,.88);
  --text-primary: #2D2B3D;
  --text-secondary: #6B6880;
  --text-muted: #9E9BB0;
  --accent: #E8477E;
  --accent-light: #FBBDD1;
  --accent-soft: rgba(232,71,126,.08);
  --accent-hover: #D63A6E;
  --border: rgba(232,71,126,.15);
  --border-strong: rgba(232,71,126,.28);
  --input-bg: #FFF5F7;
  --user-msg-bg: linear-gradient(135deg, #E8477E, #F06292);
  --user-msg-text: #FFFFFF;
  --bot-msg-bg: #FFFFFF;
  --bot-msg-border: rgba(232,71,126,.12);
  --section-header-bg: linear-gradient(135deg,#E8477E,#F48FB1);
  --section-header-text: #fff;
  --header-bg: linear-gradient(135deg,#E8477E 0%,#F06292 50%,#F48FB1 100%);
  --header-text: #FFFFFF;
  --scrollbar-thumb: #F48FB1;
  --scrollbar-track: #FDE2E9;
  --pulse-color: rgba(232,71,126,.25);
  --shadow-accent: rgba(232,71,126,.18);
  --disclaimer-bg: rgba(232,71,126,.06);
  --disclaimer-border: #F48FB1;
  --modal-bg: rgba(255,240,243,.96);
  --modal-text: #2D2B3D;
}

/* ======================== GLOBAL ======================== */
body {
  font-family: 'Inter', 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ======================== AMBIENT BACKGROUND ======================== */
.ambient-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: .3;
  animation: orbFloat 20s ease-in-out infinite alternate;
}

.ambient-orb:nth-child(1) {
  width: 420px; height: 420px;
  top: -120px; left: -120px;
  background: #F48FB1;
  animation-duration: 25s;
}
.ambient-orb:nth-child(2) {
  width: 320px; height: 320px;
  bottom: -100px; right: -80px;
  background: #FBBDD1;
  animation-duration: 18s; animation-delay: -5s;
}
.ambient-orb:nth-child(3) {
  width: 220px; height: 220px;
  top: 50%; left: 60%;
  background: #E8477E;
  opacity: .15;
  animation-duration: 22s; animation-delay: -10s;
}

@keyframes orbFloat {
  0%   { transform: translate(0,0) scale(1); }
  50%  { transform: translate(40px,-30px) scale(1.1); }
  100% { transform: translate(-20px,20px) scale(.95); }
}

/* ======================== CHAT CONTAINER ======================== */
.chat-container {
  position: relative; z-index: 1;
  max-width: 820px;
  width: 92%;
  height: 88vh;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: var(--bg-glass);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--border);
  box-shadow: 0 8px 40px var(--shadow-accent), var(--shadow-lg);
  overflow: hidden;
  animation: containerIn .7s cubic-bezier(.16,1,.3,1);
}

@keyframes containerIn {
  0% { opacity: 0; transform: translateY(30px) scale(.97); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ======================== HEADER ======================== */
.chat-header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255,255,255,.15);
  flex-shrink: 0;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  width: 40px; height: 40px;
  background: rgba(255,255,255,.2);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  backdrop-filter: blur(8px);
}

.header-info h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.02em;
  margin: 0;
}

.header-info .subtitle {
  font-size: .72rem;
  font-weight: 500;
  opacity: .8;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Status Dot */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #4ADE80;
  box-shadow: 0 0 8px rgba(74,222,128,.5);
  animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
  0%,100% { box-shadow: 0 0 4px rgba(74,222,128,.3); }
  50% { box-shadow: 0 0 12px rgba(74,222,128,.6); }
}

/* ======================== PLANNER BUTTON ======================== */
.planner-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 16px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,.15);
  color: var(--header-text);
  text-decoration: none;
  font-weight: 600;
  font-size: .8rem;
  cursor: pointer;
  transition: all var(--transition);
  backdrop-filter: blur(8px);
  letter-spacing: .02em;
}

.planner-btn:hover {
  background: rgba(255,255,255,.25);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.planner-btn:focus { outline: 2px solid rgba(255,255,255,.5); outline-offset: 2px; }

/* ======================== CHAT WINDOW ======================== */
.chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: transparent;
  scroll-behavior: smooth;
}

/* Scrollbar */
.chat-window::-webkit-scrollbar { width: 6px; }
.chat-window::-webkit-scrollbar-track { background: transparent; }
.chat-window::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 6px;
}
.chat-window::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ======================== MESSAGES ======================== */
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  max-width: 78%;
  padding: 14px 18px;
  font-size: .935rem;
  line-height: 1.65;
  border-radius: var(--radius-lg);
  animation: msgIn .45s cubic-bezier(.16,1,.3,1);
  transition: transform var(--transition), box-shadow var(--transition);
  word-wrap: break-word;
}

.message:hover { transform: translateY(-1px); }

@keyframes msgIn {
  0% { opacity: 0; transform: translateY(12px) scale(.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* User Message */
.message.user {
  align-self: flex-end;
  background: var(--user-msg-bg);
  color: var(--user-msg-text);
  border-bottom-right-radius: 6px;
  box-shadow: 0 3px 12px var(--shadow-accent);
}

/* Bot Message */
.message.bot {
  align-self: flex-start;
  background: var(--bot-msg-bg);
  color: var(--text-primary);
  border: 1px solid var(--bot-msg-border);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-sm);
}

/* ======================== FORMATTED SECTIONS ======================== */
.section {
  margin: 10px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--accent-soft);
}

.section-title {
  display: block;
  padding: 10px 14px;
  font-size: .9rem;
  font-weight: 600;
  background: var(--section-header-bg);
  color: var(--section-header-text);
  letter-spacing: .01em;
}

.section ul {
  list-style: none;
  padding: 10px 14px;
  margin: 0;
}

.section li {
  position: relative;
  padding: 6px 0 6px 20px;
  font-size: .9rem;
  line-height: 1.55;
  border-bottom: 1px solid var(--border);
}
.section li:last-child { border-bottom: none; }

.section li::before {
  content: '•';
  position: absolute;
  left: 4px;
  color: var(--accent);
  font-weight: 700;
}

/* ======================== MESSAGE ACTIONS ======================== */
.message-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  justify-content: flex-end;
}

.speech-button {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all var(--transition);
}

.speech-button:hover {
  background: var(--accent);
  color: #fff;
  transform: scale(1.08);
  box-shadow: 0 3px 10px var(--shadow-accent);
}
.speech-button:focus { outline: 2px solid var(--accent); outline-offset: 2px; }

.speech-button[data-state="pause"] .speech-icon { animation: speakPulse 1s infinite; }

@keyframes speakPulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ======================== INPUT AREA ======================== */
.chat-input {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  gap: 10px;
  border-top: 1px solid var(--border);
  background: var(--bg-glass-strong);
  backdrop-filter: blur(20px);
  flex-shrink: 0;
}

.chat-input input {
  flex: 1;
  padding: 12px 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: .925rem;
  font-family: inherit;
  outline: none;
  transition: all var(--transition);
}

.chat-input input::placeholder {
  color: var(--text-muted);
  font-style: normal;
}

.chat-input input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--pulse-color);
}

/* Voice Button */
#voice-button {
  width: 42px; height: 42px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  transition: all var(--transition);
  flex-shrink: 0;
}

#voice-button:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: scale(1.06);
  box-shadow: 0 4px 14px var(--shadow-accent);
}
#voice-button:focus { outline: 2px solid var(--accent); outline-offset: 2px; }

#voice-button.listening {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  animation: listenPulse 1.2s ease-in-out infinite;
}

@keyframes listenPulse {
  0%,100% { box-shadow: 0 0 0 0 var(--pulse-color); }
  50% { box-shadow: 0 0 0 10px transparent; }
}

#voice-button:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* Send Button */
#send-button {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-xl);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: .88rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
  flex-shrink: 0;
  font-family: inherit;
}

#send-button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--shadow-accent);
}
#send-button:focus { outline: 2px solid var(--accent); outline-offset: 2px; }

#send-button svg {
  width: 16px; height: 16px;
  stroke: #fff;
  fill: none;
  stroke-width: 2;
}

/* ======================== TYPING INDICATOR ======================== */
#loading-indicator {
  display: none;
  padding: 8px 24px;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 16px;
  background: var(--bot-msg-bg);
  border: 1px solid var(--bot-msg-border);
  border-radius: var(--radius-lg);
  width: fit-content;
}

.typing-indicator span {
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: .15s; }
.typing-indicator span:nth-child(3) { animation-delay: .3s; }

@keyframes typingBounce {
  0%,60%,100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ======================== DISCLAIMER ======================== */
.disclaimer {
  background: var(--disclaimer-bg);
  border: 1.5px solid var(--disclaimer-border);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-size: .88rem;
  line-height: 1.6;
  position: relative;
}

.disclaimer::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--accent);
  border-radius: 4px 0 0 4px;
}

.disclaimer strong {
  color: var(--accent);
  font-weight: 700;
}

.disclaimer p {
  margin: 6px 0 0;
  color: var(--text-secondary);
}

/* ======================== FOOTER ======================== */
.footer {
  text-align: center;
  padding: 10px 16px;
  font-size: .78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--bg-glass);
  flex-shrink: 0;
}

.footer p { margin: 0; }

.footer .heartbeat {
  display: inline-block;
  animation: heartbeat 1.4s ease-in-out infinite;
}

@keyframes heartbeat {
  0%,100% { transform: scale(1); }
  15% { transform: scale(1.2); }
  30% { transform: scale(1); }
  45% { transform: scale(1.15); }
}

/* ======================== MODAL (Tutorial) ======================== */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(6px);
  animation: modalOverlayIn .3s ease;
}

@keyframes modalOverlayIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.modal-content {
  background: var(--modal-bg);
  color: var(--modal-text);
  padding: 32px;
  border-radius: var(--radius-lg);
  text-align: center;
  max-width: 420px;
  width: 90%;
  border: 1px solid var(--border-strong);
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  backdrop-filter: blur(20px);
  animation: modalIn .4s cubic-bezier(.16,1,.3,1);
}

@keyframes modalIn {
  0% { opacity: 0; transform: scale(.9) translateY(20px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-content .modal-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  display: block;
}

.modal-content h2 {
  margin: 0 0 8px;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
}

.modal-content p {
  color: var(--text-secondary);
  font-size: .92rem;
  line-height: 1.55;
  margin: 8px 0;
}

.modal-close {
  margin-top: 20px;
  padding: 10px 28px;
  border: none;
  border-radius: var(--radius-xl);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: .9rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.modal-close:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--shadow-accent);
}
.modal-close:focus { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ======================== SCREEN READER ======================== */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* ======================== RESPONSIVE ======================== */
@media (max-width: 768px) {
  .chat-container { width: 100%; height: 100vh; border-radius: 0; }
  .message { max-width: 88%; font-size: .9rem; }
  .chat-window { padding: 16px; }
  .header-info h1 { font-size: 1.1rem; }
  .header-info .subtitle { font-size: .65rem; }
  .planner-btn { font-size: .75rem; padding: 6px 12px; }
}

@media (max-width: 480px) {
  .chat-input { padding: 10px 12px; gap: 8px; }
  .chat-input input { padding: 10px 14px; font-size: .88rem; }
  #send-button span { display: none; }
  #send-button { padding: 10px 12px; }
  #voice-button { width: 38px; height: 38px; }
  .header-logo { width: 34px; height: 34px; font-size: 1.1rem; }
  .modal-content { padding: 24px 20px; }
}
