/* ==========================================================================
   BioPhyto-AI - Sistema de Diseño Botánico & Monitoreo de Gases MQ
   Paleta: Verdes de Fitoterapia, Tonos Neutros, Ámbar de Alerta y Modo Oscuro
   ========================================================================== */

:root {
  /* Paleta Verde & Fitoterapia (Modo Claro) */
  --primary-50: #f0fdf4;
  --primary-100: #dcfce7;
  --primary-200: #bbf7d0;
  --primary-300: #86efac;
  --primary-400: #4ade80;
  --primary-500: #22c55e;
  --primary-600: #16a34a;
  --primary-700: #15803d;
  --primary-800: #166534;
  --primary-900: #14532d;
  --primary-950: #052e16;

  /* Tonos de alerta de gases */
  --co2-color: #10b981;
  --co-color: #f59e0b;
  --danger-color: #ef4444;

  /* Superficies */
  --bg-page: #f8faf7;
  --bg-card: #ffffff;
  --bg-card-subtle: #f0fdf4;
  --bg-card-alt: #f1f5f2;
  --border-color: #e2e8f0;
  --border-focus: #16a34a;

  /* Textos */
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  /* Sombras y redondeos */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  /* Fuentes */
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="dark"] {
  --primary-50: #062412;
  --primary-100: #0a3a1d;
  --primary-200: #0f5129;
  --primary-300: #17713b;
  --primary-400: #22c55e;
  --primary-500: #4ade80;
  --primary-600: #86efac;
  --primary-700: #bbf7d0;
  --primary-800: #dcfce7;
  --primary-900: #f0fdf4;

  --bg-page: #0a140d;
  --bg-card: #112015;
  --bg-card-subtle: #172c1e;
  --bg-card-alt: #0d1a10;
  --border-color: #1f3b28;
  --border-focus: #4ade80;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
}

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

html {
  scroll-behavior: smooth;
  font-family: var(--font-sans);
}

body {
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.section {
  padding: 4.5rem 0;
}

.section-alt {
  background-color: var(--bg-card-alt);
}

.section-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary-700);
  background: var(--primary-100);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  margin-bottom: 0.6rem;
}

[data-theme="dark"] .section-tag {
  color: var(--primary-300);
  background: var(--primary-100);
}

.section-title {
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.section-subtitle {
  color: var(--text-muted);
  max-width: 650px;
  font-size: 1rem;
}

.section-header {
  margin-bottom: 2.5rem;
}

/* ==========================================================================
   HEADER & NAVBAR
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  height: 72px;
  display: flex;
  align-items: center;
}

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

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand-badge-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary-600), var(--primary-800));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: #fff;
  box-shadow: 0 4px 10px rgba(22, 163, 74, 0.25);
}

.brand-name {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  display: block;
  line-height: 1.1;
}

.brand-ai-badge {
  color: var(--primary-600);
  font-style: italic;
  margin-left: 2px;
}

.brand-pill {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--primary-600);
  background: var(--primary-100);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
}

[data-theme="dark"] .brand-pill {
  color: var(--primary-300);
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 1.75rem;
}

.nav-link {
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.925rem;
  transition: color 0.2s;
}

.nav-link:hover,
.nav-link.active {
  color: var(--primary-600);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sensor-status-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--primary-700);
}

[data-theme="dark"] .sensor-status-badge {
  color: var(--primary-300);
}

.status-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-500);
  box-shadow: 0 0 8px var(--primary-500);
  animation: pulseDot 1.8s infinite;
}

@keyframes pulseDot {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

.theme-toggle-btn {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: transform 0.2s;
}

.theme-toggle-btn:hover {
  transform: scale(1.08);
}

.theme-icon-light { display: none; }
.theme-icon-dark { display: inline-block; }

[data-theme="dark"] .theme-icon-light { display: inline-block; }
[data-theme="dark"] .theme-icon-dark { display: none; }

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  width: 28px;
  height: 28px;
}

/* ==========================================================================
   HERO SECTION
   ========================================================================== */
.hero-section {
  padding: 5rem 0 3.5rem;
  text-align: center;
  background: radial-gradient(circle at 50% 20%, var(--primary-50) 0%, var(--bg-page) 75%);
}

.hero-badge {
  display: inline-block;
  background: var(--bg-card);
  border: 1px solid var(--primary-200);
  padding: 0.4rem 1.1rem;
  border-radius: var(--radius-full);
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--primary-700);
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .hero-badge {
  color: var(--primary-300);
  border-color: var(--primary-300);
}

.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(2.3rem, 4.5vw, 3.6rem);
  font-weight: 800;
  line-height: 1.18;
  max-width: 900px;
  margin: 0 auto 1.25rem;
}

.highlight-green {
  color: var(--primary-600);
  background: linear-gradient(120deg, var(--primary-600), #059669);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 720px;
  margin: 0 auto 2.25rem;
  line-height: 1.7;
}

.hero-cta-group {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.75rem 1.6rem;
  border-radius: var(--radius-full);
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all 0.25s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  color: #fff;
  box-shadow: 0 4px 15px rgba(22, 163, 74, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(22, 163, 74, 0.4);
}

.btn-usb-glow {
  background: linear-gradient(135deg, #059669, #10b981);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.35);
}

.btn-usb-glow:hover {
  background: linear-gradient(135deg, #047857, #059669);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.btn-usb-highlight {
  background: #10b981;
  color: #ffffff;
  border-color: #059669;
}

.btn-usb-highlight:hover {
  background: #059669;
  color: #ffffff;
}

.btn-connected {
  background: #15803d !important;
  color: #ffffff !important;
  border-color: #166534 !important;
}

.status-live {
  background: #dcfce7 !important;
  color: #15803d !important;
  border-color: #86efac !important;
}

[data-theme="dark"] .status-live {
  background: #064e3b !important;
  color: #a7f3d0 !important;
  border-color: #047857 !important;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--bg-card-subtle);
  transform: translateY(-2px);
}

.btn-sm {
  padding: 0.5rem 1.1rem;
  font-size: 0.85rem;
}

.btn-lg {
  padding: 0.9rem 2rem;
  font-size: 1.05rem;
}

/* ==========================================================================
   MÉTRICAS / DASHBOARD
   ========================================================================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s, box-shadow 0.2s;
}

.metric-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.metric-tag {
  font-size: 0.725rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 0.2rem;
}

.co2-tag { color: var(--co2-color); }
.co-tag { color: var(--co-color); }
.aqi-tag { color: var(--primary-600); }
.hw-tag { color: #6366f1; }

.metric-header h3 {
  font-size: 1.4rem;
  font-weight: 800;
}

.metric-status-pill {
  font-size: 0.725rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
}

.pill-good { background: #dcfce7; color: #15803d; }
.pill-warn { background: #fef3c7; color: #b45309; }
.pill-danger { background: #fee2e2; color: #b91c1c; }
.pill-active { background: #e0e7ff; color: #4338ca; }

.metric-value-box {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.metric-big-value {
  font-size: 3rem;
  font-weight: 800;
  font-family: var(--font-mono);
  line-height: 1;
}

.metric-unit {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 600;
}

.metric-progress-bar-wrap {
  width: 100%;
  height: 8px;
  background: var(--border-color);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.metric-progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

.bar-co2 { background: var(--co2-color); }
.bar-co { background: var(--co-color); }

.metric-footer-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.775rem;
  color: var(--text-muted);
}

.metric-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.hardware-info-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.hw-item {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dashed var(--border-color);
  padding-bottom: 0.35rem;
}

.hw-label { color: var(--text-muted); }

/* ==========================================================================
   GRÁFICA EN VIVO
   ========================================================================== */
.chart-container-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.chart-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.chart-controls {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.chart-btn {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.45rem 1rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s;
}

.chart-btn:hover {
  background: var(--primary-100);
  border-color: var(--primary-400);
}

.btn-warning-soft {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

.btn-warning-soft:hover {
  background: #fde68a;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-line {
  width: 22px;
  height: 4px;
  border-radius: 2px;
  display: inline-block;
}

.line-co2 { background: var(--co2-color); }
.line-co { background: var(--co-color); }

.legend-alert-indicator {
  margin-left: auto;
  font-weight: 600;
  font-size: 0.825rem;
  color: var(--primary-700);
}

[data-theme="dark"] .legend-alert-indicator {
  color: var(--primary-300);
}

.chart-canvas-wrapper {
  position: relative;
  width: 100%;
  height: 340px;
  background: var(--bg-card-alt);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

canvas#gasChart {
  width: 100%;
  height: 100%;
  display: block;
}

.manual-input-box {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--bg-card-subtle);
  border-radius: var(--radius-md);
  border: 1px dashed var(--primary-300);
}

.manual-input-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary-800);
  margin-bottom: 0.75rem;
}

[data-theme="dark"] .manual-input-title {
  color: var(--primary-300);
}

.manual-form-grid {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-group label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}

.form-group input {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.9rem;
  width: 120px;
}

/* ==========================================================================
   DIAGNÓSTICO FITORREMEDIACIÓN
   ========================================================================== */
.diagnosis-wrapper {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 2rem;
}

.diagnosis-trigger-card {
  background: linear-gradient(135deg, var(--primary-900), var(--primary-950));
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.diagnosis-trigger-content h3 {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  margin-bottom: 0.75rem;
}

.diagnosis-trigger-content p {
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 1.75rem;
  line-height: 1.6;
}

.diagnosis-result-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.diagnosis-placeholder {
  text-align: center;
  color: var(--text-muted);
}

.placeholder-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.5rem;
}

.diagnosis-loading {
  text-align: center;
  color: var(--primary-700);
}

[data-theme="dark"] .diagnosis-loading {
  color: var(--primary-300);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color);
  border-top-color: var(--primary-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.diagnosis-content {
  width: 100%;
}

.diagnosis-badge-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.diagnosis-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
}

.plant-recommendations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.plant-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.plant-card h5 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary-800);
  margin-bottom: 0.25rem;
}

[data-theme="dark"] .plant-card h5 {
  color: var(--primary-300);
}

.plant-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ==========================================================================
   GUÍA ARDUINO
   ========================================================================== */
.arduino-code-card {
  background: #0f172a;
  color: #f8fafc;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.25rem;
  background: #1e293b;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  color: #94a3b8;
}

.copy-code-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.775rem;
  transition: all 0.2s;
}

.copy-code-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.code-block {
  padding: 1.5rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
}

/* ==========================================================================
   CHATBOT WIDGET
   ========================================================================== */
.chatbot-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1500;
}

.chatbot-toggle-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: linear-gradient(135deg, var(--primary-700), var(--primary-900));
  color: #ffffff;
  padding: 0.85rem 1.4rem;
  border-radius: var(--radius-full);
  box-shadow: 0 8px 24px rgba(22, 101, 52, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.chatbot-toggle-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 30px rgba(22, 101, 52, 0.45);
}

.chatbot-window {
  position: absolute;
  bottom: calc(100% + 14px);
  right: 0;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 120px);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transition: all 0.25s ease;
}

.chatbot-window.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.chatbot-header {
  background: linear-gradient(135deg, var(--primary-900), var(--primary-950));
  color: #ffffff;
  padding: 1rem 1.15rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.chatbot-avatar-badge {
  font-size: 1.5rem;
}

.chatbot-title-box h4 {
  font-size: 1.05rem;
  font-weight: 700;
}

.chatbot-status-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.725rem;
  color: var(--primary-200);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
}

.chatbot-header-actions {
  display: flex;
  gap: 0.35rem;
}

.chatbot-action-btn,
.chatbot-close-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  opacity: 0.85;
}

.chatbot-action-btn:hover,
.chatbot-close-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
}

.chatbot-messages {
  flex: 1;
  padding: 1.15rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  background: var(--bg-page);
}

.chat-message {
  display: flex;
  max-width: 86%;
}

.chat-message.bot { align-self: flex-start; }
.chat-message.user { align-self: flex-end; }

.chat-bubble {
  padding: 0.8rem 1.05rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.5;
}

.chat-message.bot .chat-bubble {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-top-left-radius: 4px;
}

.chat-message.user .chat-bubble {
  background: var(--primary-600);
  color: #fff;
  border-top-right-radius: 4px;
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.chat-chip {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary-700);
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-full);
  cursor: pointer;
}

[data-theme="dark"] .chat-chip {
  color: var(--primary-300);
}

.chat-chip:hover {
  background: var(--primary-100);
}

.chat-typing-bubble {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.9rem;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  align-self: flex-start;
}

.typing-dots {
  display: flex;
  gap: 0.25rem;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--primary-500);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0s; }

.typing-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

.chatbot-input-bar {
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.chatbot-input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
}

.chat-input {
  width: 100%;
  padding: 0.65rem 0.95rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--bg-card-subtle);
  outline: none;
}

.chat-input:focus {
  border-color: var(--primary-500);
}

.chat-input.shake {
  animation: shake 0.35s ease-in-out;
  border-color: var(--danger-color);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%, 75% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
}

.chat-input-feedback {
  display: none;
  font-size: 0.725rem;
  color: var(--danger-color);
  margin-top: 0.25rem;
  padding-left: 0.5rem;
}

.chat-input-feedback.visible { display: block; }

.chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary-600);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.chat-send-btn:hover {
  background: var(--primary-500);
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.site-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 3rem 0;
  margin-top: 4rem;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.footer-logo {
  font-size: 1.25rem;
  font-weight: 800;
  display: block;
  margin-bottom: 0.25rem;
}

.footer-brand p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.footer-meta p {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */
@media (max-width: 860px) {
  .nav-links { display: none; }
  .mobile-toggle { display: block; }
  .diagnosis-wrapper { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .chatbot-wrapper { right: 16px; bottom: 16px; }
  .chatbot-window { width: calc(100vw - 32px); height: calc(85dvh - 70px); }
  .chatbot-toggle-label { display: none; }
  .chatbot-toggle-btn { padding: 0.85rem; border-radius: 50%; }
}
