/* ===== CHAT WIDGET - Modern 3-State Style ===== */

/* Base container & typography */
.chat-panel * {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  box-sizing: border-box;
}

/* Chat Panel (Header + Messages scroll) */
.chat-panel {
  position: fixed;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.98) 0%, rgba(30, 41, 59, 0.96) 100%);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  overflow: hidden;
  transition: opacity 0.4s cubic-bezier(0.32, 0.72, 0, 1), transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
  will-change: transform, opacity;
  
  /* Mobile Layout (<640px) */
  bottom: 88px;
  left: 12px;
  right: 12px;
  width: calc(100% - 24px);
  height: calc(100dvh - env(safe-area-inset-bottom) - 160px);
  border-radius: 1.5rem;
}

/* Desktop Styles Override */
@media (min-width: 640px) {
  .chat-panel {
    bottom: 96px;
    left: 0;
    right: 0;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    max-width: 448px; /* max-w-md */
    height: 480px;
    border-radius: 1.5rem;
  }
}

/* Focus Overlay */
.chat-focus-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 9, 13, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 40;
  cursor: pointer;
}

/* Scrollable message panel */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Scrollbar Customization */
.chat-messages::-webkit-scrollbar {
  width: 4px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 10px;
}

/* Welcome Card */
.chat-welcome {
  background: rgba(30, 41, 59, 0.45);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1rem;
  padding: 1.25rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  animation: welcomeFadeIn 0.5s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes welcomeFadeIn {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* Message Bubbles - Speech Style with Glassmorphism */
.chat-user-bubble {
  background: rgba(153, 27, 27, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
  border-radius: 12px;
  border-bottom-right-radius: 4px;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  line-height: 1.45;
  box-shadow: 0 4px 16px rgba(153, 27, 27, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  animation: userBubbleIn 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  word-break: break-word;
  max-width: 85%;
  align-self: flex-end;
}
@keyframes userBubbleIn {
  from { opacity: 0; transform: translateX(12px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

.chat-bot-bubble {
  background: rgba(30, 41, 59, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #E2E8F0;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  line-height: 1.45;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  animation: botBubbleIn 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  word-break: break-word;
  max-width: 85%;
  align-self: flex-start;
}
@keyframes botBubbleIn {
  from { opacity: 0; transform: translateX(-12px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

/* Text sizes for desktop and mobile */
@media (min-width: 640px) {
  .chat-user-bubble, .chat-bot-bubble, .chat-welcome {
    font-size: 1rem;
  }
}

/* Typography styles inside markdown messages */
.chat-bot-bubble p, .chat-welcome p {
  margin: 0 0 0.5rem 0;
}
.chat-bot-bubble p:last-child, .chat-welcome p:last-child {
  margin-bottom: 0;
}
.chat-bot-bubble strong, .chat-welcome strong {
  color: #FFFFFF;
  font-weight: 600;
}
.chat-bot-bubble ul, .chat-bot-bubble ol, .chat-welcome ul, .chat-welcome ol {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}
.chat-bot-bubble li, .chat-welcome li {
  margin-bottom: 0.25rem;
}
.chat-bot-bubble li::marker, .chat-welcome li::marker {
  color: #991B1B;
}
.chat-bot-bubble a {
  color: #60A5FA;
  text-decoration: underline;
}

/* Input Shell Fixed Base */
.chat-input-shell {
  position: fixed;
  z-index: 50;
  background: #0F172A;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: all 0.4s cubic-bezier(0.32, 0.72, 0, 1);
  height: 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Compact pill version */
.chat-input-compact {
  bottom: 24px;
  left: 0;
  right: 0;
  margin-left: auto;
  margin-right: auto;
  width: 200px;
  max-width: 200px;
  border-radius: 9999px; /* pill shape */
}

/* Expanded full width version */
.chat-input-expanded {
  /* Mobile default */
  bottom: 20px;
  left: 12px;
  right: 12px;
  width: calc(100% - 24px);
  border-radius: 1rem;
}

@media (min-width: 640px) {
  .chat-input-expanded {
    bottom: 24px;
    left: 0;
    right: 0;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    max-width: 448px; /* max-w-md */
    border-radius: 1rem;
  }
}

/* Typing Indicator Animation */
.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #94A3B8;
  display: inline-block;
}

/* WhatsApp Floating Button Pulsing */
.wa-pulse {
  animation: waPulse 2s infinite;
}
@keyframes waPulse {
  0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.4); }
  70% { box-shadow: 0 0 0 15px rgba(37, 211, 102, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}
