/**
 * My Dream Flight AI Chat Widget Stylesheet
 * Ultra-modern, responsive, glassmorphism styling
 */

:root {
  --fc-primary: #0b1e3d;
  --fc-primary-light: #15325e;
  --fc-accent: #f8a23c;
  --fc-accent-hover: #e08c2a;
  --fc-text-main: #1f2937;
  --fc-text-muted: #6b7280;
  --fc-bg-chat: #ffffff;
  --fc-bg-header: linear-gradient(135deg, #0b1e3d 0%, #173663 100%);
  --fc-border: #e5e7eb;
  --fc-shadow-lg: 0 10px 30px rgba(11, 30, 61, 0.22);
  --fc-radius-lg: 16px;
  --fc-radius-md: 10px;
  --fc-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Mobile Dimming Backdrop Overlay (Strictly Mobile Only, Zero Page Blur) */
.fc-ai-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 9999997;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

@media (min-width: 641px) {
  .fc-ai-backdrop {
    display: none !important;
  }
}

.fc-ai-backdrop.fc-active {
  opacity: 1;
  pointer-events: auto;
}

/* Mobile Sheet Drag Handle Bar */
.fc-ai-sheet-handle-bar {
  display: none;
  width: 100%;
  padding: 8px 0 4px;
  justify-content: center;
  align-items: center;
  cursor: grab;
  touch-action: none;
  background: var(--fc-bg-header);
}

.fc-ai-sheet-handle {
  width: 36px;
  height: 4px;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 4px;
}

/* Floating Launcher Button */
.fc-ai-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--fc-bg-header);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 50px;
  box-shadow: 0 8px 24px rgba(11, 30, 61, 0.35);
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  font-family: var(--fc-font-family);
  font-size: inherit;
  text-align: left;
}

.fc-ai-launcher:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 28px rgba(11, 30, 61, 0.45);
}

.fc-ai-launcher-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.fc-ai-launcher-icon svg {
  width: 24px;
  height: 24px;
  fill: var(--fc-accent);
}

.fc-ai-launcher-pulse {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background-color: #10b981;
  border: 2px solid #ffffff;
  border-radius: 50%;
  animation: fcPulse 2s infinite;
}

@keyframes fcPulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.fc-ai-launcher-label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* Chat Widget Container */
.fc-ai-chat-window {
  position: fixed;
  bottom: 86px;
  right: 24px;
  width: 410px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 110px);
  background: var(--fc-bg-chat);
  border-radius: var(--fc-radius-lg);
  box-shadow: var(--fc-shadow-lg);
  z-index: 999999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--fc-border);
  font-family: var(--fc-font-family);
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.96);
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.fc-ai-chat-window.fc-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Header */
.fc-ai-header {
  background: var(--fc-bg-header);
  color: #ffffff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.fc-ai-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fc-ai-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fc-accent);
  font-size: 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.fc-ai-header-titles h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.fc-ai-header-titles p {
  margin: 2px 0 0;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.75);
}

.fc-ai-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fc-ai-btn-icon {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fc-ai-btn-icon:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

/* Trust Banner */
.fc-ai-trust-banner {
  background: #f8fafc;
  padding: 8px 14px;
  font-size: 11px;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #edf2f7;
}

.fc-ai-trust-banner a {
  color: #0b1e3d;
  font-weight: 700;
  text-decoration: none;
}

.fc-ai-trust-links {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fc-wa-banner-link {
  color: #16a34a !important;
  font-weight: 700;
}
.fc-wa-banner-link:hover {
  text-decoration: underline;
}

/* Messages Area */
.fc-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fdfdfd;
}

.fc-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  font-size: 13.5px;
  line-height: 1.45;
  word-break: break-word;
}

.fc-msg-assistant {
  align-self: flex-start;
}

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

.fc-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
}

.fc-msg-assistant .fc-msg-bubble {
  background: #f1f5f9;
  color: var(--fc-text-main);
  border-top-left-radius: 2px;
  border: 1px solid #e2e8f0;
}

.fc-msg-user .fc-msg-bubble {
  background: var(--fc-primary);
  color: #ffffff;
  border-top-right-radius: 2px;
}

.fc-msg-bubble a {
  color: #0284c7;
  text-decoration: underline;
  font-weight: 600;
  word-break: break-word;
}
.fc-msg-bubble a:hover {
  color: #0369a1;
}
.fc-msg-bubble a.fc-wa-link,
.fc-msg-bubble a[href*="wa.me"] {
  color: #16a34a;
  text-decoration: underline;
  font-weight: 700;
}
.fc-msg-bubble a.fc-wa-link:hover,
.fc-msg-bubble a[href*="wa.me"]:hover {
  color: #15803d;
}

.fc-msg-time {
  font-size: 10px;
  color: var(--fc-text-muted);
  margin-top: 3px;
  align-self: flex-end;
}

/* Quick Suggestion Chips */
.fc-ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.fc-chip {
  background: #ffffff;
  color: var(--fc-primary);
  border: 1px solid #cbd5e1;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.fc-chip:hover {
  background: var(--fc-primary);
  color: #ffffff;
  border-color: var(--fc-primary);
}

/* Flight Cards Container */
.fc-flight-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  width: 100%;
}

.fc-flight-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--fc-radius-md);
  padding: 12px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
}

.fc-flight-card:hover {
  border-color: var(--fc-accent);
  box-shadow: 0 4px 12px rgba(248, 162, 60, 0.15);
}

.fc-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed #e2e8f0;
}

.fc-card-airline {
  font-weight: 700;
  font-size: 13px;
  color: var(--fc-primary);
}

.fc-card-price {
  font-size: 16px;
  font-weight: 800;
  color: #0b1e3d;
}

.fc-card-route {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.fc-point {
  text-align: center;
}

.fc-point-time {
  font-size: 14px;
  font-weight: 700;
  color: #1e293b;
}

.fc-point-iata {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
}

.fc-flight-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 8px;
}

.fc-duration {
  font-size: 10.5px;
  color: #64748b;
  margin-bottom: 2px;
}

.fc-line-arrow {
  width: 60px;
  height: 2px;
  background: #cbd5e1;
  position: relative;
}

.fc-line-arrow::after {
  content: "✈";
  position: absolute;
  top: -8px;
  left: 45%;
  font-size: 10px;
  color: var(--fc-accent);
}

.fc-stops-badge {
  font-size: 10px;
  color: #059669;
  font-weight: 600;
  margin-top: 2px;
}

.fc-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.fc-btn-book {
  flex: 1;
  background: var(--fc-accent);
  color: #ffffff;
  border: none;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 0;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  transition: background 0.2s;
}

.fc-btn-book:hover {
  background: var(--fc-accent-hover);
}

.fc-btn-call {
  background: #f1f5f9;
  color: var(--fc-primary);
  border: 1px solid #cbd5e1;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fc-btn-call:hover {
  background: #e2e8f0;
}

/* Typing indicator */
.fc-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: #f1f5f9;
  border-radius: 12px;
  width: fit-content;
}

.fc-typing-dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: fcTypingDot 1.4s infinite ease-in-out both;
}

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

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

/* Footer / Input Area */
.fc-ai-input-area {
  padding: 12px 14px;
  border-top: 1px solid #edf2f7;
  background: #ffffff;
}

.fc-ai-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.fc-ai-input {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 13.5px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}

.fc-ai-input:focus {
  border-color: var(--fc-primary);
}

.fc-ai-send-btn {
  background: var(--fc-primary);
  color: #ffffff;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.fc-ai-send-btn:hover {
  background: var(--fc-primary-light);
  transform: scale(1.05);
}

.fc-ai-send-btn svg {
  width: 16px;
  height: 16px;
  fill: #ffffff;
}

/* Quick Callback Modal (Zero Page Blur) */
.fc-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(11, 30, 61, 0.72);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.fc-modal-overlay.fc-active {
  opacity: 1;
  pointer-events: auto;
}

.fc-modal-box {
  background: #ffffff;
  border-radius: var(--fc-radius-md);
  width: 100%;
  padding: 20px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.fc-modal-box h4 {
  margin: 0 0 4px;
  font-size: 16px;
  color: var(--fc-primary);
}

.fc-modal-box p {
  margin: 0 0 14px;
  font-size: 12px;
  color: #64748b;
}

.fc-form-group {
  margin-bottom: 10px;
}

.fc-form-group label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 3px;
}

.fc-form-group input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  box-sizing: border-box;
  outline: none;
}

.fc-form-group input:focus {
  border-color: var(--fc-primary);
}

.fc-modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.fc-btn-submit {
  flex: 1;
  background: var(--fc-accent);
  color: #ffffff;
  border: none;
  padding: 9px 0;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
}

.fc-btn-cancel {
  background: #f1f5f9;
  color: #475569;
  border: none;
  padding: 9px 14px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}

/* Mobile Responsiveness & Touch Optimization */
@media (max-width: 640px) {
  body.fc-chat-open {
    overflow: hidden !important;
    overscroll-behavior: none !important;
  }

  /* Show handle bar on mobile */
  .fc-ai-sheet-handle-bar {
    display: flex;
  }

  /* Hide floating launcher when chat window is open to prevent overlapping */
  body.fc-chat-open .fc-ai-launcher,
  .fc-ai-launcher.fc-hidden {
    display: none !important;
  }

  .fc-ai-launcher {
    bottom: max(16px, env(safe-area-inset-bottom, 16px));
    right: max(16px, env(safe-area-inset-right, 16px));
    padding: 10px 16px;
    gap: 8px;
  }

  .fc-ai-launcher-label {
    font-size: 13px;
  }

  /* Modern Mobile Bottom-Sheet (Anchored at Bottom, NEVER Stuck to Top: 0) */
  .fc-ai-chat-window {
    position: fixed !important;
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 88vh !important;
    height: 88dvh !important;
    max-height: calc(100dvh - 28px) !important;
    border-radius: 22px 22px 0 0 !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-bottom: none !important;
    box-shadow: 0 -12px 40px rgba(11, 30, 61, 0.4) !important;
    z-index: 9999999 !important;
    transform: translateY(100%) !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease !important;
    will-change: transform;
  }

  .fc-ai-chat-window.fc-open {
    transform: translateY(0) !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  /* Safe Area Header */
  .fc-ai-header {
    padding-top: max(8px, env(safe-area-inset-top, 8px));
    padding-left: max(14px, env(safe-area-inset-left, 14px));
    padding-right: max(14px, env(safe-area-inset-right, 14px));
    padding-bottom: 12px;
    flex-shrink: 0;
  }

  .fc-ai-header-brand {
    gap: 8px;
  }

  .fc-ai-avatar {
    width: 34px;
    height: 34px;
    font-size: 16px;
  }

  .fc-ai-header-titles h3 {
    font-size: 14px;
  }

  .fc-ai-header-titles p {
    font-size: 10.5px;
  }

  /* Accessible Touch Targets for Header Buttons (min 40px) */
  .fc-ai-btn-icon {
    min-width: 40px;
    min-height: 40px;
    padding: 8px;
  }

  .fc-ai-btn-icon svg {
    width: 18px;
    height: 18px;
  }

  /* Trust Banner */
  .fc-ai-trust-banner {
    padding: 6px 14px;
    font-size: 10.5px;
  }

  /* Messages Area with Momentum Touch Scrolling */
  .fc-ai-messages {
    padding: 12px 10px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    gap: 10px;
  }

  .fc-msg {
    max-width: 92%;
    font-size: 14px;
  }

  .fc-msg-bubble {
    padding: 10px 13px;
  }

  /* Suggestion Chips */
  .fc-ai-chips {
    gap: 5px;
  }

  .fc-chip {
    font-size: 11.5px;
    padding: 6px 11px;
  }

  /* Flight Cards Responsive Adaptations */
  .fc-flight-card {
    padding: 10px;
  }

  .fc-card-airline {
    font-size: 12.5px;
  }

  .fc-card-price {
    font-size: 15px;
  }

  .fc-line-arrow {
    width: 44px;
  }

  .fc-point-time {
    font-size: 13px;
  }

  .fc-point-iata {
    font-size: 10.5px;
  }

  .fc-duration {
    font-size: 10px;
  }

  .fc-btn-book {
    padding: 9px 0;
    font-size: 13px;
  }

  .fc-btn-call {
    padding: 9px 10px;
    font-size: 13px;
  }

  /* Safe Area Bottom Input Bar */
  .fc-ai-input-area {
    padding-top: 10px;
    padding-left: max(10px, env(safe-area-inset-left, 10px));
    padding-right: max(10px, env(safe-area-inset-right, 10px));
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  }

  /* 16px Font Size on Input - STRICTLY PREVENTS iOS AUTO-ZOOM */
  .fc-ai-input {
    font-size: 16px !important;
    padding: 10px 14px;
    -webkit-appearance: none;
    border-radius: 20px;
  }

  .fc-ai-send-btn {
    width: 42px;
    height: 42px;
    min-width: 42px;
  }

  .fc-ai-send-btn svg {
    width: 17px;
    height: 17px;
  }

  /* Callback Modal on Mobile */
  .fc-modal-overlay {
    padding: 12px;
  }

  .fc-modal-box {
    padding: 16px;
    max-height: 90vh;
    overflow-y: auto;
  }

  .fc-form-group input {
    font-size: 16px !important; /* Prevents iOS auto-zoom */
    padding: 10px;
  }

  .fc-btn-submit,
  .fc-btn-cancel {
    padding: 11px 0;
    font-size: 14px;
  }
}

/* Very Small Mobile Screens (320px-380px) */
@media (max-width: 380px) {
  .fc-ai-launcher-label {
    display: none;
  }
  .fc-ai-launcher {
    padding: 10px 12px;
  }
  .fc-line-arrow {
    width: 32px;
  }
}

/* Tablet Screens (641px to 1024px) */
@media (min-width: 641px) and (max-width: 1024px) {
  .fc-ai-chat-window {
    width: 390px;
    height: 580px;
    bottom: 84px;
    right: 20px;
    max-height: calc(100vh - 100px);
  }
}
