/* ============================================================
   GuaguaCare - Custom Styles
   ============================================================ */

/* --- Design Tokens --- */
:root {
  --color-primary-50: #EFF6FF;
  --color-primary-100: #DBEAFE;
  --color-primary-200: #BFDBFE;
  --color-primary-500: #3B82F6;
  --color-primary-600: #2563EB;
  --color-primary-700: #1E40AF;
  --color-primary-800: #1E3A5F;
  --color-primary-900: #0F2942;

  --color-accent-50: #ECFDF5;
  --color-accent-100: #D1FAE5;
  --color-accent-500: #34D399;
  --color-accent-600: #059669;
  --color-accent-700: #047857;

  --color-surface: #F8FAFC;
  --color-surface-alt: #F1F5F9;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
}

/* --- Base --- */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Animations --- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes bounceIn {
  0%   { transform: scale(0.9); opacity: 0; }
  60%  { transform: scale(1.02); opacity: 1; }
  100% { transform: scale(1); }
}

.animate-fade-in-up {
  animation: fadeInUp 0.4s ease-out both;
}

.animate-fade-in {
  animation: fadeIn 0.3s ease-out both;
}

.animate-slide-down {
  animation: slideDown 0.3s ease-out both;
}

.animate-bounce-in {
  animation: bounceIn 0.4s ease-out both;
}

/* --- Chat Message Bubbles --- */
.chat-message {
  max-width: 80%;
  word-wrap: break-word;
  line-height: 1.5;
}

.chat-message-user {
  background: linear-gradient(135deg, var(--color-primary-500), var(--color-primary-600));
  color: white;
  border-radius: 18px 18px 4px 18px;
  padding: 10px 16px;
  box-shadow: var(--shadow-sm);
}

.chat-message-bot {
  background: white;
  color: #1a1a2e;
  border: 1px solid #e2e8f0;
  border-radius: 18px 18px 18px 4px;
  padding: 10px 16px;
  box-shadow: var(--shadow-sm);
}

.chat-message-bot a {
  color: var(--color-primary-600);
  text-decoration: underline;
}

.chat-message-bot a.btn-link {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 8px;
  background: var(--color-primary-600);
  color: white;
  text-decoration: none;
  font-size: 13px;
  margin-top: 4px;
  transition: background 0.2s;
}

.chat-message-bot a.btn-link:hover {
  background: var(--color-primary-700);
}

/* --- Typing Indicator --- */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 18px 18px 18px 4px;
  box-shadow: var(--shadow-sm);
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--color-accent-500);
  border-radius: 50%;
  animation: pulseDot 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

/* --- Avatars --- */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar-bot {
  background: linear-gradient(135deg, var(--color-accent-500), var(--color-primary-500));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: white;
}

.avatar-bot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.avatar-user {
  background: var(--color-primary-600);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 13px;
}

/* --- Timestamp --- */
.chat-timestamp {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 3px;
  padding: 0 2px;
}

/* --- Scroll-to-Bottom Button --- */
.scroll-to-bottom-btn {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 10;
}

.scroll-to-bottom-btn.visible {
  opacity: 1;
  pointer-events: auto;
}

/* --- Navbar --- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.3s ease;
}

.navbar.scrolled {
  box-shadow: var(--shadow-md);
}

/* --- Hero Section --- */
.hero-section {
  background: linear-gradient(135deg, var(--color-primary-50) 0%, var(--color-accent-50) 50%, white 100%);
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -15%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--color-accent-100) 0%, transparent 70%);
  opacity: 0.6;
  pointer-events: none;
}

.hero-section::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--color-primary-100) 0%, transparent 70%);
  opacity: 0.4;
  pointer-events: none;
}

/* --- Feature Cards --- */
.feature-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

/* Staggered animation delays */
.feature-card:nth-child(1) { animation-delay: 0.05s; }
.feature-card:nth-child(2) { animation-delay: 0.10s; }
.feature-card:nth-child(3) { animation-delay: 0.15s; }
.feature-card:nth-child(4) { animation-delay: 0.20s; }
.feature-card:nth-child(5) { animation-delay: 0.25s; }
.feature-card:nth-child(6) { animation-delay: 0.30s; }
.feature-card:nth-child(7) { animation-delay: 0.35s; }

/* --- Form Validation --- */
.field-error {
  border-color: #EF4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12) !important;
}

.error-message {
  color: #EF4444;
  font-size: 12px;
  margin-top: 4px;
  padding-left: 4px;
  animation: fadeIn 0.2s ease-out;
}

/* --- Modal --- */
.modal-backdrop {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease-out;
}

.modal-content {
  animation: bounceIn 0.3s ease-out;
}

/* --- Testimonial Cards --- */
.testimonial-card {
  transition: transform 0.2s ease;
}

.testimonial-card:hover {
  transform: translateY(-2px);
}

/* --- Scroll-triggered animation (initially hidden) --- */
.observe-fade {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.observe-fade.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Suggestion Chips --- */
.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
  animation: fadeInUp 0.4s ease-out both;
  animation-delay: 0.3s;
}

.suggestion-chip {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid #e2e8f0;
  background: white;
  color: var(--color-primary-700);
  line-height: 1.3;
}

.suggestion-chip:hover {
  background: var(--color-primary-50);
  border-color: var(--color-primary-300, #93c5fd);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.suggestion-chip:active {
  transform: scale(0.97);
}

/* --- Mobile Menu --- */
.mobile-menu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  opacity: 0;
}

.mobile-menu.open {
  max-height: 300px;
  opacity: 1;
}

/* --- Theme Toggle Button --- */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  color: #64748b;
}

.theme-toggle:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* --- Medical Disclaimer Bar --- */
.disclaimer-bar {
  font-size: 11px;
  padding: 4px 12px;
  text-align: center;
  border-bottom: 1px solid #e2e8f0;
  color: #94a3b8;
  background: var(--color-surface);
}

/* ============================================================
   DARK MODE
   ============================================================ */
[data-theme="dark"] {
  --color-primary-50: #172554;
  --color-primary-100: #1e3a5f;
  --color-accent-50: #064e3b;
  --color-accent-100: #065f46;
  --color-surface: #0f172a;
  --color-surface-alt: #1e293b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -2px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5), 0 4px 6px -4px rgba(0,0,0,0.4);
}

/* Body & container backgrounds */
[data-theme="dark"] body {
  background: #0f172a;
  color: #e2e8f0;
}

/* Override Tailwind bg classes in dark mode */
[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-gray-50,
[data-theme="dark"] .bg-gray-50\/50 {
  background-color: #1e293b !important;
}

[data-theme="dark"] .bg-gradient-to-br {
  background: #0f172a !important;
}

/* Container card */
[data-theme="dark"] #container {
  background: #1e293b;
  border-color: #334155;
}

/* Text colors */
[data-theme="dark"] .text-gray-800 { color: #e2e8f0 !important; }
[data-theme="dark"] .text-gray-700 { color: #cbd5e1 !important; }
[data-theme="dark"] .text-gray-600 { color: #94a3b8 !important; }
[data-theme="dark"] .text-gray-500 { color: #94a3b8 !important; }
[data-theme="dark"] .text-gray-400 { color: #64748b !important; }

/* Borders */
[data-theme="dark"] .border-gray-100,
[data-theme="dark"] .border-gray-200 {
  border-color: #334155 !important;
}

/* Inputs */
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"] {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}

[data-theme="dark"] input::placeholder {
  color: #64748b;
}

[data-theme="dark"] input:focus {
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2) !important;
}

/* Chat bubbles */
[data-theme="dark"] .chat-message-bot {
  background: #334155;
  color: #e2e8f0;
  border-color: #475569;
}

[data-theme="dark"] .chat-message-bot a {
  color: #60a5fa;
}

[data-theme="dark"] .chat-message-bot a.btn-link {
  background: #3b82f6;
}

/* Typing indicator */
[data-theme="dark"] .typing-indicator {
  background: #334155;
  border-color: #475569;
}

/* Chat area */
[data-theme="dark"] #chatbox {
  background: #0f172a !important;
}

/* Chat header & input area */
[data-theme="dark"] .border-b,
[data-theme="dark"] .border-t {
  border-color: #334155 !important;
}

[data-theme="dark"] form.bg-white,
[data-theme="dark"] div.bg-white {
  background-color: #1e293b !important;
}

/* Scroll-to-bottom button */
[data-theme="dark"] .scroll-to-bottom-btn {
  background: #334155;
  border-color: #475569;
}

[data-theme="dark"] .scroll-to-bottom-btn svg {
  color: #94a3b8;
}

/* Banner */
[data-theme="dark"] .bg-amber-50 {
  background-color: rgba(251, 191, 36, 0.1) !important;
  border-color: rgba(251, 191, 36, 0.2) !important;
}

[data-theme="dark"] .text-amber-700 {
  color: #fbbf24 !important;
}

/* Suggestion chips */
[data-theme="dark"] .suggestion-chip {
  background: #334155;
  border-color: #475569;
  color: #93c5fd;
}

[data-theme="dark"] .suggestion-chip:hover {
  background: #3b4f6b;
  border-color: #60a5fa;
}

/* Modal */
[data-theme="dark"] .modal-content {
  background: #1e293b;
}

[data-theme="dark"] .modal-backdrop {
  background: rgba(0, 0, 0, 0.7);
}

/* Navbar dark */
[data-theme="dark"] .navbar {
  background: rgba(15, 23, 42, 0.95);
  border-bottom-color: #1e293b;
}

/* Theme toggle dark */
[data-theme="dark"] .theme-toggle {
  color: #fbbf24;
}

[data-theme="dark"] .theme-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Disclaimer bar */
[data-theme="dark"] .disclaimer-bar {
  background: #1e293b;
  border-bottom-color: #334155;
  color: #64748b;
}

/* Hero in dark */
[data-theme="dark"] .hero-section {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}

[data-theme="dark"] .hero-section::before {
  background: radial-gradient(circle, rgba(52, 211, 153, 0.1) 0%, transparent 70%);
}

[data-theme="dark"] .hero-section::after {
  background: radial-gradient(circle, rgba(59, 130, 246, 0.1) 0%, transparent 70%);
}

/* Feature cards dark */
[data-theme="dark"] .feature-card {
  background: #1e293b !important;
  border-color: #334155 !important;
}

[data-theme="dark"] .feature-card .bg-blue-100 { background-color: rgba(59, 130, 246, 0.15) !important; }
[data-theme="dark"] .feature-card .bg-amber-100 { background-color: rgba(251, 191, 36, 0.15) !important; }
[data-theme="dark"] .feature-card .bg-indigo-100 { background-color: rgba(99, 102, 241, 0.15) !important; }
[data-theme="dark"] .feature-card .bg-yellow-100 { background-color: rgba(250, 204, 21, 0.15) !important; }
[data-theme="dark"] .feature-card .bg-purple-100 { background-color: rgba(168, 85, 247, 0.15) !important; }
[data-theme="dark"] .feature-card .bg-pink-100 { background-color: rgba(236, 72, 153, 0.15) !important; }
[data-theme="dark"] .feature-card .bg-green-100 { background-color: rgba(52, 211, 153, 0.15) !important; }

/* Testimonials dark */
[data-theme="dark"] .testimonial-card {
  background: #1e293b !important;
}

[data-theme="dark"] .testimonial-card .bg-blue-100 { background-color: rgba(59, 130, 246, 0.2) !important; }
[data-theme="dark"] .testimonial-card .bg-green-100 { background-color: rgba(52, 211, 153, 0.2) !important; }
[data-theme="dark"] .testimonial-card .bg-purple-100 { background-color: rgba(168, 85, 247, 0.2) !important; }

/* Benefits dark */
[data-theme="dark"] .bg-green-100 {
  background-color: rgba(52, 211, 153, 0.15) !important;
}

/* Footer dark */
[data-theme="dark"] footer {
  border-top-color: #334155;
}

/* Links in dark */
[data-theme="dark"] a.text-gray-400:hover {
  color: #60a5fa !important;
}

/* Privacy page dark */
[data-theme="dark"] .list-disc li {
  color: #94a3b8;
}

/* Mobile menu dark */
[data-theme="dark"] .mobile-menu {
  background: #1e293b;
  border-color: #334155;
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .chat-message {
    max-width: 88%;
  }

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

  .hero-section h1 {
    font-size: 2rem;
  }

  .suggestion-chip {
    font-size: 12px;
    padding: 7px 12px;
  }
}
