/* Floating chatbot widget - relies on the --falcon-* custom properties
   already defined on :root in main.css (loaded first). */

/* The browser's own [hidden] { display: none } rule is user-agent origin,
   so it loses to the author-origin `display: flex` set unconditionally
   below - the panel stayed laid out (and, at the mobile breakpoint,
   fixed/full-viewport) even while `hidden`, silently eating every tap on
   the toggle button underneath it since opacity:0 doesn't disable pointer
   events. This more-specific [hidden] selector restores the toggle. */
.falcon-chatbot-panel[hidden] {
  display: none;
}

/* Part of the site-wide z-index scale documented in main.css: header 100,
   megamenu 90, chatbot bubble (this) 150, mobile Filters drawer 200,
   chatbot open panel 250, modals 300. Collapsed and open states get
   different tiers on purpose - the widget currently being used (open
   panel, or the Filters drawer if that's what's open) should win, but an
   idle bubble shouldn't outrank a drawer the visitor just opened. */
.falcon-chatbot {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 150;
}
.falcon-chatbot.is-open {
  z-index: 250;
}

.falcon-chatbot-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--falcon-gold);
  color: var(--falcon-black);
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  animation: falcon-chatbot-pulse 2.6s ease-in-out infinite;
}
.falcon-chatbot-toggle:hover {
  background: var(--falcon-gold-light);
}
.falcon-chatbot-toggle-icon-close {
  display: none;
}
.falcon-chatbot.is-open .falcon-chatbot-toggle {
  animation: none;
}
.falcon-chatbot.is-open .falcon-chatbot-toggle-icon-chat {
  display: none;
}
.falcon-chatbot.is-open .falcon-chatbot-toggle-icon-close {
  display: block;
}

@keyframes falcon-chatbot-pulse {
  0%, 100% { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25), 0 0 0 0 rgba(212, 167, 44, 0.5); }
  50% { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25), 0 0 0 10px rgba(212, 167, 44, 0); }
}

.falcon-chatbot-panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: 350px;
  height: 480px;
  max-height: 70vh;
  background: var(--falcon-white);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(16px) scale(0.98);
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
}
.falcon-chatbot.is-open .falcon-chatbot-panel {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.falcon-chatbot-header {
  background: var(--falcon-black);
  color: var(--falcon-white);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
}
.falcon-chatbot-header-text strong {
  display: block;
  font-size: 14px;
  color: var(--falcon-white);
}
.falcon-chatbot-header-sub {
  display: block;
  font-size: 11.5px;
  color: var(--falcon-gold-light);
  margin-top: 2px;
}
.falcon-chatbot-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-right: -10px;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--falcon-white);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}
.falcon-chatbot-close:hover,
.falcon-chatbot-close:focus-visible {
  color: var(--falcon-gold-light);
  background: rgba(255, 255, 255, 0.1);
}

.falcon-chatbot-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--falcon-offwhite);
}

.falcon-chatbot-msg {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.falcon-chatbot-msg-bot {
  align-self: flex-start;
  background: var(--falcon-white);
  border: 1px solid var(--falcon-lightgray);
  color: var(--falcon-black);
  border-bottom-left-radius: 4px;
}
.falcon-chatbot-msg-visitor {
  align-self: flex-end;
  background: var(--falcon-gold);
  color: var(--falcon-black);
  border-bottom-right-radius: 4px;
  font-weight: 600;
}

.falcon-chatbot-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: var(--falcon-white);
  border: 1px solid var(--falcon-lightgray);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.falcon-chatbot-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--falcon-gray);
  animation: falcon-chatbot-typing-dot 1.2s infinite;
}
.falcon-chatbot-typing span:nth-child(2) { animation-delay: 0.15s; }
.falcon-chatbot-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes falcon-chatbot-typing-dot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.falcon-chatbot-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 10px;
  flex: 0 0 auto;
  background: var(--falcon-offwhite);
}
.falcon-chatbot-quick-reply {
  padding: 7px 14px;
  border-radius: 16px;
  border: 1.5px solid var(--falcon-gold-dark);
  background: var(--falcon-white);
  color: var(--falcon-black);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.falcon-chatbot-quick-reply:hover {
  background: var(--falcon-gold);
  border-color: var(--falcon-gold);
}

.falcon-chatbot-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--falcon-lightgray);
  flex: 0 0 auto;
  background: var(--falcon-white);
}
.falcon-chatbot-input {
  flex: 1;
  border: 1px solid var(--falcon-lightgray);
  border-radius: 20px;
  padding: 9px 15px;
  font-size: 13.5px;
  font-family: inherit;
}
.falcon-chatbot-input:focus {
  outline: none;
  border-color: var(--falcon-gold);
}
.falcon-chatbot-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--falcon-gold);
  color: var(--falcon-black);
  font-size: 15px;
  cursor: pointer;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.falcon-chatbot-send:hover {
  background: var(--falcon-gold-light);
}

@media (max-width: 560px) {
  .falcon-chatbot {
    right: 14px;
    bottom: 14px;
  }
  .falcon-chatbot-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    bottom: 0;
    right: 0;
  }
}
