/**
 * Agile Legal Solutions® — AI Chat Widget Stylesheet
 * Optimized for Mobile Responsiveness, Micro-Interactions, and High Trust
 */

:root {
  --chat-primary: #0F172A;
  --chat-primary-light: #1E293B;
  --chat-accent: #2563EB;
  --chat-accent-hover: #1D4ED8;
  --chat-gold: #F59E0B;
  --chat-emerald: #10B981;
  --chat-whatsapp: #25D366;
  --chat-whatsapp-hover: #1EBE5D;
  --chat-bg: #F8FAFC;
  --chat-card-bg: #FFFFFF;
  --chat-text: #0F172A;
  --chat-text-muted: #64748B;
  --chat-border: #E2E8F0;
  --chat-shadow: 0 12px 36px -4px rgba(15, 23, 42, 0.25), 0 4px 12px -2px rgba(15, 23, 42, 0.12);
  --chat-radius: 16px;
  --chat-transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --------------------------------------------------------------------------
   1. Floating Trigger Button & Pulsing Badge
   -------------------------------------------------------------------------- */
.legal-chat-trigger {
  position: fixed;
  bottom: 96px;
  right: 28px;
  z-index: 1035;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 32px;
  padding: 8px 16px 8px 10px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.3);
  transition: var(--chat-transition);
  user-select: none;
}

.legal-chat-trigger:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.4);
  border-color: rgba(245, 158, 11, 0.5);
}

.legal-chat-trigger-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3B82F6 0%, #6366F1 50%, #4F46E5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  font-size: 1.2rem;
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.5);
}

.legal-chat-trigger:hover .legal-chat-trigger-icon {
  box-shadow: 0 0 18px rgba(99, 102, 241, 0.8);
  transform: rotate(5deg);
}

/* --------------------------------------------------------------------------
   1b. Proactive Teaser Speech Bubble
   -------------------------------------------------------------------------- */
.legal-chat-teaser {
  position: fixed;
  bottom: 155px;
  right: 28px;
  z-index: 1034;
  background: #FFFFFF;
  color: #0F172A;
  padding: 10px 14px;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16), 0 2px 6px rgba(15, 23, 42, 0.08);
  border: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  animation: teaserBounce 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  max-width: 270px;
  font-size: 0.82rem;
  line-height: 1.35;
  transition: all 0.2s ease;
}

.legal-chat-teaser:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.22);
  border-color: #3B82F6;
}

.legal-chat-teaser::after {
  content: '';
  position: absolute;
  bottom: -7px;
  right: 24px;
  width: 14px;
  height: 14px;
  background: #FFFFFF;
  border-right: 1px solid #E2E8F0;
  border-bottom: 1px solid #E2E8F0;
  transform: rotate(45deg);
}

.legal-chat-teaser-text {
  flex: 1;
}

.legal-chat-teaser-text strong {
  color: #2563EB;
}

.legal-chat-teaser-close {
  background: transparent;
  border: none;
  color: #94A3B8;
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  align-self: flex-start;
  transition: color 0.15s ease;
}

.legal-chat-teaser-close:hover {
  color: #0F172A;
}

@keyframes teaserBounce {
  0% { opacity: 0; transform: translateY(12px) scale(0.92); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.legal-chat-pulse {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background-color: var(--chat-emerald);
  border: 2px solid #0F172A;
  animation: legalPulse 2s infinite;
}

@keyframes legalPulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.legal-chat-trigger-label {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.legal-chat-trigger-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: -0.01em;
}

.legal-chat-trigger-subtitle {
  font-size: 0.68rem;
  color: #F59E0B;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   2. Main Chat Container Window
   -------------------------------------------------------------------------- */
.legal-chat-window {
  position: fixed;
  bottom: 96px;
  right: 28px;
  width: 380px;
  height: 580px;
  max-height: calc(100vh - 120px);
  background: var(--chat-bg);
  border-radius: var(--chat-radius);
  box-shadow: var(--chat-shadow);
  border: 1px solid var(--chat-border);
  display: flex;
  flex-direction: column;
  z-index: 1045;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.legal-chat-window.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* --------------------------------------------------------------------------
   3. Chat Header
   -------------------------------------------------------------------------- */
.legal-chat-header {
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
  color: #FFFFFF;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.legal-chat-header-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.legal-chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #1E293B;
  border: 1.5px solid var(--chat-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--chat-gold);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.legal-chat-header-info {
  line-height: 1.25;
}

.legal-chat-header-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  gap: 4px;
}

.legal-chat-header-status {
  font-size: 0.7rem;
  color: #CBD5E1;
  display: flex;
  align-items: center;
  gap: 5px;
}

.legal-chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--chat-emerald);
}

.legal-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legal-chat-btn-icon {
  background: transparent;
  border: none;
  color: #94A3B8;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: var(--chat-transition);
}

.legal-chat-btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #FFFFFF;
}

/* --------------------------------------------------------------------------
   4. BCI Compliance Disclaimer Banner
   -------------------------------------------------------------------------- */
.legal-chat-disclaimer {
  background-color: #FEF3C7;
  color: #92400E;
  font-size: 0.68rem;
  padding: 6px 12px;
  line-height: 1.35;
  border-bottom: 1px solid #FDE68A;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex-shrink: 0;
}

.legal-chat-disclaimer i {
  color: #D97706;
  margin-top: 1px;
}

/* --------------------------------------------------------------------------
   5. Message Body & Scroller
   -------------------------------------------------------------------------- */
.legal-chat-messages {
  flex: 1;
  padding: 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.legal-chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: fadeInMsg 0.2s ease-out;
}

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

.legal-chat-msg.bot {
  align-self: flex-start;
}

.legal-chat-msg.user {
  align-self: flex-end;
}

.legal-chat-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.84rem;
  line-height: 1.45;
  word-break: break-word;
}

.legal-chat-msg.bot .legal-chat-bubble {
  background: var(--chat-card-bg);
  color: var(--chat-text);
  border: 1px solid var(--chat-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.legal-chat-msg.user .legal-chat-bubble {
  background: linear-gradient(135deg, #1E293B 0%, #0F172A 100%);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
}

.legal-chat-bubble p {
  margin: 0 0 6px 0;
}

.legal-chat-bubble p:last-child {
  margin-bottom: 0;
}

.legal-chat-bubble ul, .legal-chat-bubble ol {
  margin: 4px 0 6px 16px;
  padding: 0;
}

.legal-chat-bubble li {
  margin-bottom: 3px;
}

.legal-chat-time {
  font-size: 0.65rem;
  color: var(--chat-text-muted);
  margin-top: 3px;
  align-self: flex-start;
}

.legal-chat-msg.user .legal-chat-time {
  align-self: flex-end;
}

/* --------------------------------------------------------------------------
   6. Quick Suggestion Pills / Chips
   -------------------------------------------------------------------------- */
.legal-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0 8px 0;
}

.legal-chat-chip {
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
  color: #1E293B;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: var(--chat-transition);
  text-align: left;
}

.legal-chat-chip:hover {
  background: #F1F5F9;
  border-color: var(--chat-accent);
  color: var(--chat-accent);
  transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   7. Action Cards Inside Chat (WhatsApp & Advocate Callback)
   -------------------------------------------------------------------------- */
.legal-chat-action-card {
  background: #FFFFFF;
  border: 1px solid var(--chat-border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.legal-chat-action-card-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #0F172A;
  margin-bottom: 4px;
}

.legal-chat-btn-wa {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background-color: var(--chat-whatsapp);
  color: #FFFFFF !important;
  font-size: 0.76rem;
  font-weight: 700;
  text-decoration: none !important;
  padding: 7px 12px;
  border-radius: 8px;
  width: 100%;
  margin-top: 6px;
  transition: var(--chat-transition);
}

.legal-chat-btn-wa:hover {
  background-color: var(--chat-whatsapp-hover);
  color: #FFFFFF;
}

/* --------------------------------------------------------------------------
   8. Typing Indicator Animation
   -------------------------------------------------------------------------- */
.legal-chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--chat-card-bg);
  border: 1px solid var(--chat-border);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  align-self: flex-start;
}

.legal-chat-dot {
  width: 6px;
  height: 6px;
  background: #94A3B8;
  border-radius: 50%;
  animation: legalBlink 1.4s infinite ease-in-out both;
}

.legal-chat-dot:nth-child(1) { animation-delay: -0.32s; }
.legal-chat-dot:nth-child(2) { animation-delay: -0.16s; }

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

/* --------------------------------------------------------------------------
   9. Chat Input Form Area
   -------------------------------------------------------------------------- */
.legal-chat-footer {
  padding: 10px 12px;
  background: #FFFFFF;
  border-top: 1px solid var(--chat-border);
  flex-shrink: 0;
}

.legal-chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
  border-radius: 24px;
  padding: 4px 6px 4px 14px;
  transition: var(--chat-transition);
}

.legal-chat-form:focus-within {
  border-color: var(--chat-accent);
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.legal-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 0.84rem;
  color: var(--chat-text);
  font-family: inherit;
  padding: 6px 0;
}

.legal-chat-input::placeholder {
  color: #94A3B8;
  font-size: 0.82rem;
}

.legal-chat-send-btn {
  background: var(--chat-accent);
  color: #FFFFFF;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--chat-transition);
  flex-shrink: 0;
}

.legal-chat-send-btn:hover {
  background: var(--chat-accent-hover);
  transform: scale(1.05);
}

.legal-chat-send-btn:disabled {
  background: #CBD5E1;
  cursor: not-allowed;
  transform: none;
}

/* Honeypot hidden field */
.legal-chat-hp {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  position: absolute !important;
  left: -9999px !important;
}

/* --------------------------------------------------------------------------
   10. Mobile Responsiveness (Bottom Sheet Modal)
   -------------------------------------------------------------------------- */
@media (max-width: 991px) {
  .legal-chat-teaser {
    bottom: 200px;
    right: 20px;
    max-width: 250px;
    font-size: 0.78rem;
  }

  .legal-chat-trigger {
    bottom: 145px;
    right: 20px;
    padding: 7px 12px 7px 8px;
  }
  
  .legal-chat-trigger-title {
    font-size: 0.76rem;
  }
  
  .legal-chat-trigger-subtitle {
    font-size: 0.64rem;
  }

  .legal-chat-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 85vh;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    z-index: 1060;
  }
}
