/* ══════════════════════════════════════════════════════════════════════════
   Vetraj Pet Health Chat — Stylesheet
   ══════════════════════════════════════════════════════════════════════════ */

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

:root {
  --blue:       #1a73e8;
  --blue-light: #e8f0fe;
  --teal:       #00bfa5;
  --teal-light: #e0f7f5;
  --green:      #27ae60;
  --yellow:     #f39c12;
  --orange:     #e67e22;
  --red:        #e74c3c;
  --bg:         #f0f2f5;
  --surface:    #ffffff;
  --border:     #dee2e6;
  --text-dark:  #1a1a2e;
  --text-mid:   #495057;
  --text-light: #868e96;
  --shadow-sm:  0 1px 4px rgba(0,0,0,.08);
  --shadow-md:  0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.14);
  --radius:     12px;
  --radius-lg:  20px;
  --sidebar-w:  260px;
  --header-h:   64px;
  --input-h:    80px;
}

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-dark);
  overflow: hidden;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */

.app-shell {
  display: flex;
  height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow-y: auto;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  background: linear-gradient(135deg, var(--blue), #4285f4);
  color: white;
}

.brand-icon {
  font-size: 28px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.2));
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.brand-tagline {
  font-size: 11px;
  opacity: 0.8;
  margin-top: 1px;
}

.sidebar-section {
  padding: 16px 16px 4px;
}

.sidebar-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-light);
  margin-bottom: 8px;
}

/* Mode toggle */
.mode-toggle {
  display: flex;
  background: var(--bg);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 8px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-mid);
  transition: all .2s;
}

.mode-btn.active {
  background: white;
  color: var(--blue);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

/* Language select */
.lang-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  font-size: 13px;
  color: var(--text-dark);
  cursor: pointer;
  outline: none;
  margin-bottom: 8px;
}

.lang-select:focus { border-color: var(--blue); }

/* Toggle switch */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  margin-bottom: 8px;
}

.toggle-label input { display: none; }

.toggle-slider {
  width: 38px;
  height: 21px;
  background: var(--border);
  border-radius: 20px;
  position: relative;
  transition: background .2s;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  width: 17px;
  height: 17px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.toggle-label input:checked + .toggle-slider { background: var(--teal); }
.toggle-label input:checked + .toggle-slider::after { transform: translateX(17px); }

.toggle-text {
  font-size: 13px;
  color: var(--text-mid);
}

/* Progress bar */
.progress-bar-container {
  background: var(--bg);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--blue));
  border-radius: 4px;
  transition: width .5s cubic-bezier(.4,0,.2,1);
}

.progress-text {
  font-size: 12px;
  color: var(--text-light);
  text-align: right;
  margin-bottom: 8px;
}

/* Score card */
.score-card {
  margin: 8px 16px;
  background: linear-gradient(135deg, var(--blue-light), var(--teal-light));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}

.score-card.hidden { display: none; }

.score-card-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-light);
  margin-bottom: 4px;
}

.score-display {
  font-size: 32px;
  font-weight: 700;
  color: var(--blue);
  line-height: 1;
  margin-bottom: 4px;
}

.score-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mid);
}

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid var(--border);
}

.restart-btn {
  width: 100%;
  padding: 9px;
  background: var(--blue-light);
  color: var(--blue);
  border: 1px solid #c5d9f8;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  margin-bottom: 8px;
}

.restart-btn:hover {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

.sidebar-note {
  font-size: 10px;
  color: var(--text-light);
  text-align: center;
}

/* ── Chat Main ───────────────────────────────────────────────────────────── */

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

/* Header */
.chat-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

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

.avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--blue), var(--teal));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.avatar.mini {
  width: 28px;
  height: 28px;
  font-size: 14px;
}

.chat-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dark);
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-light);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.connecting { background: var(--yellow); animation: pulse 1.5s infinite; }
.status-dot.connected  { background: var(--green); }
.status-dot.error      { background: var(--red); }

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

.icon-btn {
  padding: 7px 14px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
}

.icon-btn:hover { background: #1557b0; }

/* ── Messages ────────────────────────────────────────────────────────────── */

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar { width: 6px; }
.messages-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Welcome banner */
.welcome-banner {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}

.welcome-icon { font-size: 52px; margin-bottom: 12px; }
.welcome-title { font-size: 20px; font-weight: 700; color: var(--text-mid); margin-bottom: 6px; }
.welcome-sub { font-size: 13px; }

/* Message bubbles */
.message-row {
  display: flex;
  gap: 8px;
  max-width: 75%;
  animation: msgIn .3s ease;
}

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

.message-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-row.assistant { align-self: flex-start; }

.bubble {
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  max-width: 100%;
  word-break: break-word;
}

.message-row.assistant .bubble {
  background: var(--surface);
  color: var(--text-dark);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.message-row.user .bubble {
  background: linear-gradient(135deg, var(--blue), #4285f4);
  color: white;
  border-bottom-right-radius: 4px;
}

.bubble-time {
  font-size: 10px;
  color: var(--text-light);
  margin-top: 3px;
  align-self: flex-end;
  white-space: nowrap;
}

/* Question bubble — special styling */
.question-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  max-width: 80%;
  align-self: flex-start;
  box-shadow: var(--shadow-sm);
  animation: msgIn .3s ease;
}

.question-section-tag {
  display: inline-block;
  background: var(--blue-light);
  color: var(--blue);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.question-text {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-dark);
}

/* Report card bubble */
.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  max-width: 85%;
  align-self: flex-start;
  box-shadow: var(--shadow-md);
  animation: msgIn .4s ease;
}

.report-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-big {
  font-size: 42px;
  font-weight: 800;
  line-height: 1;
}

.score-meta { font-size: 13px; color: var(--text-mid); margin-top: 2px; }

.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 8px;
  color: white;
}

.risk-areas-list {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.risk-area-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 4px 0;
  color: var(--text-mid);
}

.risk-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.report-dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 9px 18px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all .2s;
}

.report-dl-btn:hover { background: #1557b0; }

/* ── Quick option buttons ────────────────────────────────────────────────── */

.options-area {
  padding: 8px 20px 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.options-area.hidden { display: none; }

.options-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.options-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 10px;
  max-height: 120px;
  overflow-y: auto;
}

.option-chip {
  padding: 6px 14px;
  background: var(--blue-light);
  color: var(--blue);
  border: 1px solid #c5d9f8;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.option-chip:hover {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(26,115,232,.3);
}

.option-chip.selected {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

.option-chip.multi-selected {
  background: var(--teal);
  color: white;
  border-color: var(--teal);
}

.multi-confirm-btn {
  padding: 6px 16px;
  background: var(--green);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}

.multi-confirm-btn:hover { background: #1e8449; }

/* ── Typing Indicator ────────────────────────────────────────────────────── */

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 20px;
}

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

.typing-dots {
  display: flex;
  gap: 4px;
  background: var(--surface);
  padding: 8px 12px;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-light);
  animation: typingBounce 1.2s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }

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

/* Streaming cursor shown while text hasn't started yet */
.stream-cursor {
  display: inline-block;
  color: var(--primary);
  animation: cursorBlink 0.7s step-end infinite;
}
@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Input Bar ───────────────────────────────────────────────────────────── */

.input-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  flex-shrink: 0;
  box-shadow: 0 -2px 8px rgba(0,0,0,.04);
}

.text-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.text-input {
  flex: 1;
  padding: 11px 16px;
  border: 1.5px solid var(--border);
  border-radius: 24px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: var(--bg);
  color: var(--text-dark);
  transition: border-color .2s;
}

.text-input:focus {
  border-color: var(--blue);
  background: white;
  box-shadow: 0 0 0 3px rgba(26,115,232,.1);
}

.text-input::placeholder { color: var(--text-light); }

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
  flex-shrink: 0;
}

.send-btn:hover { background: #1557b0; transform: scale(1.05); }
.send-btn:active { transform: scale(0.95); }
.send-btn:disabled { background: var(--border); cursor: not-allowed; }

/* Voice controls */
.voice-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.voice-controls.hidden { display: none; }

.mic-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border: 2px solid var(--blue);
  border-radius: 30px;
  background: var(--blue-light);
  color: var(--blue);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  user-select: none;
}

.mic-btn:hover, .mic-btn.recording {
  background: var(--blue);
  color: white;
  box-shadow: 0 4px 16px rgba(26,115,232,.35);
  transform: scale(1.03);
}

.mic-btn.recording {
  background: #e74c3c;
  border-color: #e74c3c;
  animation: recordPulse 1s infinite;
}

@keyframes recordPulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(231,76,60,.35); }
  50% { box-shadow: 0 4px 24px rgba(231,76,60,.6); }
}

.voice-wave {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 32px;
}

.voice-wave.hidden { display: none; }

.voice-wave span {
  width: 4px;
  background: var(--blue);
  border-radius: 2px;
  animation: waveBar 0.8s ease-in-out infinite;
}

.voice-wave span:nth-child(1) { animation-delay: 0s; }
.voice-wave span:nth-child(2) { animation-delay: .1s; }
.voice-wave span:nth-child(3) { animation-delay: .2s; }
.voice-wave span:nth-child(4) { animation-delay: .1s; }
.voice-wave span:nth-child(5) { animation-delay: 0s; }

@keyframes waveBar {
  0%, 100% { height: 8px; }
  50% { height: 28px; }
}

/* ── Report Panel ─────────────────────────────────────────────────────────── */

.report-panel {
  width: 300px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: -2px 0 8px rgba(0,0,0,.06);
  animation: slideInRight .3s ease;
}

.report-panel.hidden { display: none; }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

.report-panel-header {
  padding: 16px;
  background: var(--blue);
  color: white;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.close-panel-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
  opacity: 0.8;
  transition: opacity .2s;
}

.close-panel-btn:hover { opacity: 1; background: rgba(255,255,255,.15); }

.report-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.r-section {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.r-section:last-child { border-bottom: none; }

.r-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-light);
  margin-bottom: 6px;
}

.r-score {
  font-size: 36px;
  font-weight: 800;
  line-height: 1;
}

.r-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  color: white;
  margin-top: 4px;
}

.r-rec-item {
  font-size: 12px;
  color: var(--text-mid);
  padding: 5px 0 5px 14px;
  position: relative;
  line-height: 1.45;
}

.r-rec-item::before {
  content: '•';
  position: absolute;
  left: 4px;
  color: var(--teal);
}

.r-dl-btn {
  display: block;
  width: 100%;
  padding: 10px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: all .2s;
  margin-top: 8px;
}

.r-dl-btn:hover { background: #1557b0; }

/* ── Animations ─────────────────────────────────────────────────────────── */

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Utilities ───────────────────────────────────────────────────────────── */

.hidden { display: none !important; }

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar { width: 200px; }
  .report-panel { display: none; }
  .message-row { max-width: 90%; }
}

@media (max-width: 500px) {
  .sidebar { display: none; }
  .message-row { max-width: 95%; }
}
