/* ==========================================================================
   FALTCO AI COACH — CHATBOT WIDGET STYLING
   Desktop: Luminous Electric Royal Blue & Obsidian Glass Floating Widget
   Mobile: WhatsApp Native Full-Screen Interface with Fixed Bars
   ========================================================================== */

/* --- Status Indicator Dot --- */
.ai-status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
  margin-right: 4px;
}

/* --- Back Button (Hidden on Desktop by default) --- */
.ai-btn-back {
  display: none;
}

/* ==========================================================================
   DESKTOP FLOATING LAUNCHER BUTTON
   ========================================================================== */
.faltco-ai-launcher {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 60%, #1e40af 100%);
  border: 1.5px solid rgba(56, 189, 248, 0.45);
  border-radius: var(--radius-pill, 9999px);
  padding: 0.65rem 1.25rem 0.65rem 0.75rem;
  color: #ffffff;
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.6), 0 0 25px rgba(56, 189, 248, 0.45);
  cursor: pointer;
  transition: all 0.25s ease;
}

.faltco-ai-launcher:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 15px 40px rgba(37, 99, 235, 0.8), 0 0 35px rgba(56, 189, 248, 0.7);
}

.ai-launcher-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #38bdf8;
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

.ai-launcher-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ai-launcher-text {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.ai-launcher-title {
  font-family: var(--font-display, sans-serif);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.1;
  color: #ffffff;
}

.ai-launcher-sub {
  font-size: 0.75rem;
  color: #7dd3fc;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.ai-launcher-sub::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #34d399;
  border-radius: 50%;
  box-shadow: 0 0 8px #34d399;
}

/* ==========================================================================
   DESKTOP CHAT MODAL WINDOW
   ========================================================================== */
.faltco-ai-modal {
  position: fixed;
  bottom: 5.5rem;
  right: 1.75rem;
  width: 420px;
  height: 600px;
  max-height: calc(100vh - 7rem);
  background: rgba(10, 15, 26, 0.96);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1.5px solid rgba(56, 189, 248, 0.35);
  border-radius: 1.25rem;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.9), 0 0 45px rgba(37, 99, 235, 0.4);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.faltco-ai-modal.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Desktop Header */
.ai-modal-header {
  background: #0c1322;
  border-bottom: 1px solid rgba(56, 189, 248, 0.2);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.ai-header-profile {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.ai-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
  flex-shrink: 0;
}

.ai-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ai-header-meta h4 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
  color: #ffffff;
}

.ai-header-status {
  font-size: 0.75rem;
  color: #34d399;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.ai-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ai-btn-icon {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ai-btn-icon:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #38bdf8;
}

/* Quick Chips */
.ai-quick-chips {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.65rem 1.25rem;
  background: rgba(15, 23, 42, 0.7);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.quick-chip-btn {
  background: #0f172a;
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #7dd3fc;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.quick-chip-btn:hover {
  background: rgba(37, 99, 235, 0.35);
  border-color: #38bdf8;
  color: #ffffff;
}

/* Chat Message Body */
.ai-messages-area {
  flex: 1 1 auto;
  min-height: 0;
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

/* Message Bubble */
.chat-msg {
  max-width: 86%;
  padding: 0.85rem 1.15rem;
  border-radius: 1.25rem;
  font-size: 0.925rem;
  line-height: 1.55;
  word-wrap: break-word;
  position: relative;
  animation: fadeInMsg 0.25s ease-out;
}

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

.chat-msg.bot {
  align-self: flex-start;
  background: #111a2e;
  border: 1px solid rgba(56, 189, 248, 0.2);
  color: #f1f5f9;
  border-bottom-left-radius: 0.3rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  border-bottom-right-radius: 0.3rem;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
}

.chat-msg-time {
  font-size: 0.7rem;
  color: #94a3b8;
  margin-top: 0.35rem;
  text-align: right;
}

.chat-msg.user .chat-msg-time {
  color: rgba(255, 255, 255, 0.75);
}

/* Chat Input Bar */
.ai-input-area {
  padding: 0.85rem 1.25rem;
  background: #0c1322;
  border-top: 1px solid rgba(56, 189, 248, 0.2);
  flex-shrink: 0;
}

.ai-input-form {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: #060911;
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 9999px;
  padding: 0.35rem 0.45rem 0.35rem 1.15rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ai-input-form:focus-within {
  border-color: #38bdf8;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

.ai-input-field {
  flex: 1;
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 16px; /* Prevents auto zoom */
  outline: none;
}

.ai-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.ai-send-btn:hover {
  transform: scale(1.08);
}
.ai-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Embedded Lead Card Inside Chat */
.chat-lead-card {
  background: #080d1a;
  border: 1px solid #38bdf8;
  border-radius: 0.75rem;
  padding: 1.15rem;
  margin-top: 0.75rem;
  text-align: left;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5), 0 0 15px rgba(56, 189, 248, 0.25);
}

.chat-lead-card h5 {
  font-size: 0.95rem;
  color: #7dd3fc;
  margin-bottom: 0.4rem;
  font-weight: 700;
}

.chat-lead-card p {
  font-size: 0.85rem;
  color: #cbd5e1;
  margin-bottom: 0.75rem;
}

/* Typing Indicator Animation */
.ai-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.25rem 0.5rem;
}

.ai-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #38bdf8;
  animation: aiTyping 1.4s infinite ease-in-out;
}

.ai-typing-dot:nth-child(1) { animation-delay: 0s; }
.ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }

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


/* ==========================================================================
   MOBILE RESPONSIVE — WHATSAPP NATIVE APP EXPERIENCE (ONLY <= 767px)
   ========================================================================== */
@media (max-width: 767px) {

  /* Mobile Floating Launcher Button */
  .faltco-ai-launcher {
    bottom: 1.15rem;
    right: 1.15rem;
    padding: 0.5rem 0.95rem 0.5rem 0.6rem;
    gap: 0.55rem;
  }
  .ai-launcher-avatar {
    width: 34px;
    height: 34px;
  }
  .ai-launcher-title {
    font-size: 0.88rem;
  }
  .ai-launcher-sub {
    font-size: 0.7rem;
  }

  /* Full-Screen WhatsApp Native Container */
  .faltco-ai-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    width: 100dvw;
    height: var(--app-height, 100dvh);
    max-height: var(--app-height, 100dvh);
    margin: 0;
    border: none;
    border-radius: 0;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    background: #080c14;
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
    overflow: hidden;
  }

  .faltco-ai-modal.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  /* WhatsApp Static Fixed Top Banner */
  .ai-modal-header {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    flex-shrink: 0;
    padding: calc(0.65rem + env(safe-area-inset-top, 0px)) 0.85rem 0.65rem 0.65rem;
    background: #0b1220;
    border-bottom: 1px solid rgba(56, 189, 248, 0.2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .ai-header-profile {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex: 1;
    min-width: 0;
  }

  /* WhatsApp Back Arrow Button */
  .ai-btn-back {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #38bdf8;
    font-size: 1.15rem;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    transition: background 0.15s ease;
  }

  .ai-btn-back:active {
    background: rgba(56, 189, 248, 0.2);
  }

  .ai-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid #38bdf8;
    flex-shrink: 0;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
  }

  .ai-header-meta {
    min-width: 0;
    flex: 1;
  }

  .ai-header-meta h4 {
    font-size: 0.92rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #ffffff;
    margin: 0;
    line-height: 1.2;
  }

  .ai-header-status {
    font-size: 0.7rem;
    color: #34d399;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
  }

  .ai-header-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
  }

  .ai-btn-icon {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
  }

  /* Horizontal Swipeable Quick Chips */
  .ai-quick-chips {
    flex-shrink: 0;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0.55rem 0.85rem;
    gap: 0.45rem;
    background: rgba(11, 18, 32, 0.95);
    border-top: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .ai-quick-chips::-webkit-scrollbar {
    display: none;
  }

  .quick-chip-btn {
    font-size: 0.76rem;
    padding: 0.32rem 0.7rem;
    flex-shrink: 0;
  }

  /* Scrollable Conversation Stream (Only this scrolls) */
  .ai-messages-area {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding: 0.85rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    background: #080c14;
    background-image: radial-gradient(circle at 80% 20%, rgba(37, 99, 235, 0.08) 0%, transparent 60%);
  }

  /* WhatsApp Styled Chat Bubbles */
  .chat-msg {
    max-width: 88%;
    padding: 0.75rem 0.95rem;
    font-size: 0.9rem;
    line-height: 1.45;
  }

  .chat-msg.bot {
    background: #111a2d;
    border: 1px solid rgba(56, 189, 248, 0.18);
    border-radius: 14px 14px 14px 2px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  }

  .chat-msg.user {
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    border-radius: 14px 14px 2px 14px;
    box-shadow: 0 3px 12px rgba(37, 99, 235, 0.45);
  }

  .chat-lead-card {
    padding: 0.95rem;
    border-radius: 0.65rem;
  }

  /* WhatsApp Fixed Bottom Input Bar (Pinned above mobile virtual keyboard) */
  .ai-input-area {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    flex-shrink: 0;
    padding: 0.55rem 0.75rem calc(0.55rem + env(safe-area-inset-bottom, 0px)) 0.75rem;
    background: #0b1220;
    border-top: 1px solid rgba(56, 189, 248, 0.2);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.5);
  }

  .ai-input-form {
    padding: 0.25rem 0.35rem 0.25rem 0.95rem;
    background: #060911;
    border: 1.5px solid rgba(56, 189, 248, 0.35);
    border-radius: 28px;
    gap: 0.45rem;
  }

  .ai-input-field {
    font-size: 16px !important; /* Strictly prevents iOS Safari zooming */
    height: 38px;
  }

  .ai-send-btn {
    width: 36px;
    height: 36px;
    font-size: 0.92rem;
  }
}
