/* ==========================================================================
   OASIS POOL SERVICES — Chatbot Widget Styles
   Self-contained styles for the floating chat assistant.
   Uses brand tokens from base.css (:root custom properties).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. FAB (Floating Action Button)
   -------------------------------------------------------------------------- */
.oasis-chat__fab {
  position: fixed;
  bottom: 100px;
  right: 24px;
  z-index: 950;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-secondary);
  color: var(--color-white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 180, 216, 0.4);
  transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
  animation: oasisChatPulse 1.6s ease-in-out 3;
}

.oasis-chat__fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0, 180, 216, 0.55);
}

.oasis-chat__fab:focus-visible {
  outline: 3px solid var(--color-cta);
  outline-offset: 3px;
}

.oasis-chat__fab svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* Close icon state */
.oasis-chat__fab--open svg.oasis-chat__icon-chat {
  display: none;
}

.oasis-chat__fab--open svg.oasis-chat__icon-close {
  display: block;
}

.oasis-chat__fab svg.oasis-chat__icon-close {
  display: none;
}

@keyframes oasisChatPulse {
  0%, 100% {
    box-shadow: 0 4px 20px rgba(0, 180, 216, 0.4);
  }
  50% {
    box-shadow: 0 4px 20px rgba(0, 180, 216, 0.4),
                0 0 0 12px rgba(0, 180, 216, 0.15);
  }
}

/* --------------------------------------------------------------------------
   2. PANEL (Chat Window)
   -------------------------------------------------------------------------- */
.oasis-chat__panel {
  position: fixed;
  bottom: 170px;
  right: 24px;
  z-index: 949;
  width: 380px;
  height: 520px;
  max-height: calc(100vh - 200px);
  background: var(--color-white);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(12, 35, 64, 0.18),
              0 0 0 1px rgba(12, 35, 64, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
}

.oasis-chat__panel--open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* --------------------------------------------------------------------------
   2a. HEADER
   -------------------------------------------------------------------------- */
.oasis-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--color-primary);
  color: var(--color-white);
  flex-shrink: 0;
}

.oasis-chat__header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.oasis-chat__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.oasis-chat__avatar svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--color-white);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.oasis-chat__header-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.2;
}

.oasis-chat__header-status {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.65);
  display: flex;
  align-items: center;
  gap: 5px;
}

.oasis-chat__header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ADE80;
  flex-shrink: 0;
}

.oasis-chat__close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-white);
  transition: background 0.2s ease;
}

.oasis-chat__close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.oasis-chat__close:focus-visible {
  outline: 2px solid var(--color-secondary);
  outline-offset: 2px;
}

.oasis-chat__close svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --------------------------------------------------------------------------
   2b. MESSAGE LIST
   -------------------------------------------------------------------------- */
.oasis-chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  overscroll-behavior-y: contain;
}

/* Custom scrollbar */
.oasis-chat__messages::-webkit-scrollbar {
  width: 5px;
}

.oasis-chat__messages::-webkit-scrollbar-track {
  background: transparent;
}

.oasis-chat__messages::-webkit-scrollbar-thumb {
  background: rgba(12, 35, 64, 0.15);
  border-radius: 10px;
}

/* --------------------------------------------------------------------------
   3. MESSAGES
   -------------------------------------------------------------------------- */
.oasis-chat__message {
  max-width: 85%;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.oasis-chat__message a {
  color: var(--color-secondary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.oasis-chat__message--bot {
  align-self: flex-start;
  background: #F0F4F8;
  color: var(--color-primary);
  border-radius: 4px 16px 16px 16px;
}

.oasis-chat__message--bot a:hover {
  color: var(--color-cta);
}

.oasis-chat__message--user {
  align-self: flex-end;
  background: var(--color-secondary);
  color: var(--color-white);
  border-radius: 16px 4px 16px 16px;
}

.oasis-chat__message--user a {
  color: var(--color-white);
}

/* --------------------------------------------------------------------------
   4. TYPING INDICATOR
   -------------------------------------------------------------------------- */
.oasis-chat__typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 18px;
  background: #F0F4F8;
  border-radius: 4px 16px 16px 16px;
}

.oasis-chat__typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(12, 35, 64, 0.35);
  animation: oasisChatBounce 1.4s ease-in-out infinite;
}

.oasis-chat__typing-dot:nth-child(2) {
  animation-delay: 0.16s;
}

.oasis-chat__typing-dot:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes oasisChatBounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-6px);
  }
}

/* --------------------------------------------------------------------------
   5. SUGGESTION PILLS
   -------------------------------------------------------------------------- */
.oasis-chat__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
  flex-shrink: 0;
}

.oasis-chat__suggestion {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 16px;
  background: var(--color-cta);
  color: var(--color-white);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.82rem;
  border: none;
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
  white-space: nowrap;
}

.oasis-chat__suggestion:hover {
  background: var(--color-cta-hover);
  transform: translateY(-1px);
}

.oasis-chat__suggestion:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   6. INPUT BAR
   -------------------------------------------------------------------------- */
.oasis-chat__input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid rgba(12, 35, 64, 0.08);
  background: var(--color-white);
  flex-shrink: 0;
}

.oasis-chat__input {
  flex: 1;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid rgba(12, 35, 64, 0.12);
  border-radius: 20px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color 0.2s ease;
  outline: none;
}

.oasis-chat__input::placeholder {
  color: var(--color-text-light);
}

.oasis-chat__input:focus {
  border-color: var(--color-secondary);
}

.oasis-chat__send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-secondary);
  color: var(--color-white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s ease, transform 0.15s ease;
}

.oasis-chat__send:hover {
  background: #009BBF;
  transform: scale(1.05);
}

.oasis-chat__send:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.oasis-chat__send svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --------------------------------------------------------------------------
   7. MOBILE OVERRIDES (<768px)
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  .oasis-chat__fab {
    bottom: 80px;
    right: 16px;
  }

  .oasis-chat__panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    bottom: 0;
    right: 0;
  }

  .oasis-chat__input-bar {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  /* Hide sticky CTA when chat is open */
  body.oasis-chat-open .sticky-mobile-cta {
    display: none !important;
  }

  /* Prevent background scrolling when chat is open */
  body.oasis-chat-open {
    overflow: hidden;
  }

  /* Hide the floating financing button when chat is open */
  body.oasis-chat-open .floating-financing {
    display: none !important;
  }
}

/* --------------------------------------------------------------------------
   8. REDUCED MOTION
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .oasis-chat__fab {
    animation: none;
  }

  .oasis-chat__panel {
    transition: none;
  }

  .oasis-chat__typing-dot {
    animation: none;
  }

  .oasis-chat__fab,
  .oasis-chat__suggestion,
  .oasis-chat__send,
  .oasis-chat__close {
    transition: none;
  }
}
