/* Chatbot Stylesheet - Persistent AI Assistant Widget */

:root {
  --chat-btn-bg: #191b1d;
  --chat-btn-color: #ffffff;
  --chat-window-bg: #ffffff;
  --chat-window-border: rgba(0, 0, 0, 0.35);
  --chat-text-color: #000000;
  --chat-text-secondary: rgba(25, 27, 29, 0.65);
  --chat-bubble-user-bg: #191b1d;
  --chat-bubble-user-color: #ffffff;
  --chat-bubble-bot-bg: rgba(25, 27, 29, 0.05);
  --chat-bubble-bot-color: #000000;
  --chat-input-bg: #ebebeb;
  --chat-input-border: rgba(0, 0, 0, 0.35);
  --chat-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
  --chat-badge-bg: #191b1d;
  --chat-badge-color: #ffffff;
  --chat-badge-border: #ffffff;
  --chat-font-family: 'Neue', system-ui, sans-serif;
  --chat-title-font: 'Syne', sans-serif;
  
  /* Matches Theme Toggle / Back to Home buttons in light mode */
  --chat-secondary-btn-bg: #ebebeb;
  --chat-secondary-btn-border: rgba(0, 0, 0, 0.35);
  --chat-secondary-btn-color: #1d1b1c;
  --chat-secondary-btn-hover-bg: #f3f3f3;
  --chat-secondary-btn-hover-border: rgba(0, 0, 0, 0.5);
}

body.dark {
  --chat-btn-bg: #ebebeb;
  --chat-btn-color: #131313;
  --chat-window-bg: #000000;
  --chat-window-border: rgba(255, 255, 255, 0.35);
  --chat-text-color: #ffffff;
  --chat-text-secondary: rgba(235, 235, 235, 0.65);
  --chat-bubble-user-bg: #ebebeb;
  --chat-bubble-user-color: #131313;
  --chat-bubble-bot-bg: rgba(235, 235, 235, 0.06);
  --chat-bubble-bot-color: #ffffff;
  --chat-input-bg: #131313;
  --chat-input-border: rgba(255, 255, 255, 0.35);
  --chat-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --chat-badge-bg: #ebebeb;
  --chat-badge-color: #131313;
  --chat-badge-border: #131313;

  /* Matches Theme Toggle / Back to Home buttons in dark mode */
  --chat-secondary-btn-bg: #131313;
  --chat-secondary-btn-border: rgba(255, 255, 255, 0.35);
  --chat-secondary-btn-color: #eeeeee;
  --chat-secondary-btn-hover-bg: #1a1a1a;
  --chat-secondary-btn-hover-border: #9a9a9a;
}

/* Container for all chatbot elements to isolate them */
#ai-chat-widget {
  font-family: var(--chat-font-family);
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
}

#ai-chat-widget * {
  box-sizing: border-box;
}

/* Allow pointer events only where necessary.
   - `chat-toggle-btn` and `chat-avatar` must remain clickable at all times.
   - Other interactive elements should accept events only when widget is open. */
#ai-chat-widget .chat-toggle-btn,
#ai-chat-widget .chat-avatar {
  pointer-events: auto;
}

#ai-chat-widget.is-open .chat-window,
#ai-chat-widget.is-open .chat-suggestions,
#ai-chat-widget.is-open .chat-suggest-btn,
#ai-chat-widget.is-open .chat-input-area,
#ai-chat-widget.is-open .chat-send-btn,
#ai-chat-widget.is-open .chat-clear-btn,
#ai-chat-widget.is-open .chat-bubble {
  pointer-events: auto;
}

/* Floating Action Button */
.chat-toggle-btn {
  width: clamp(48px, 8vw, 64px);
  height: clamp(48px, 8vw, 64px);
  border-radius: 50%;
  background: var(--chat-secondary-btn-bg);
  color: var(--chat-secondary-btn-color);
  border: 1px solid var(--chat-secondary-btn-border);
  box-shadow: var(--chat-shadow);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: clamp(16px, 3vw, 22px);
  transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  z-index: 10;
}

.chat-toggle-btn:hover {
  background-color: var(--chat-secondary-btn-hover-bg);
  border-color: var(--chat-secondary-btn-hover-border);
  color: var(--chat-secondary-btn-color);
}

#ai-chat-widget.is-open .chat-toggle-btn {
  background-color: var(--chat-secondary-btn-hover-bg);
  border-color: var(--chat-secondary-btn-hover-border);
  color: var(--chat-secondary-btn-color);
}

.chat-toggle-btn i {
  color: inherit;
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  position: absolute;
  top: 50%;
  left: 50%;
}


.chat-toggle-btn .chat-icon-message {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1) rotate(0deg);
}

.chat-toggle-btn .chat-icon-close {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.4) rotate(-90deg);
}


/* Notification badge */
.chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--chat-badge-bg);
  color: var(--chat-badge-color);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 2px solid var(--chat-badge-border);
  animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* Chat Window */
.chat-window {
  width: 360px;
  height: 480px;
  background: var(--chat-window-bg);
  border: 1px solid var(--chat-window-border);
  border-radius: 20px;
  box-shadow: var(--chat-shadow);
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(30px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              background-color 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: bottom right;
}

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

/* Header */
.chat-header {
  padding: 20px;
  background: rgba(0, 0, 0, 0.02);
  border-bottom: 1px solid var(--chat-window-border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  transition: background-color 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--chat-secondary-btn-bg);
  color: var(--chat-secondary-btn-color);
  border: 1px solid var(--chat-secondary-btn-border);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 18px;
  transition: background-color 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              color 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Make avatar non-interactive: keep toggle button as the single control */
#ai-chat-widget .chat-avatar {
  pointer-events: none;
  cursor: default;
}

.chat-header-info {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.chat-header-title {
  font-family: "Neue", system-ui, sans-serif;
  font-size: 15px;
  font-weight: 500;
  color: #1d1b1c;
  margin: 0;
  letter-spacing: 0;
  line-height: 1.2;
  transition: color 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

body.dark .chat-header-title {
  color: #eeeeee;
}

.chat-header-status {
  font-size: 11px;
  color: var(--chat-text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-header-status::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--chat-text-color);
  opacity: 0.8;
  border-radius: 50%;
}

.chat-clear-btn {
  background: transparent;
  border: none;
  color: #1d1b1c;
  font-size: 14px;
  cursor: pointer;
  padding: 5px;
  border-radius: 4px;
  transition: color 0.8s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-clear-btn:hover {
  color: #474343;
}

body.dark .chat-clear-btn {
  color: #eeeeee;
}

body.dark .chat-clear-btn:hover {
  color: #bdbdbd;
}

/* Messages Area */
.chat-messages {
  flex-grow: 1;
  flex-shrink: 1;
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  scroll-behavior: smooth;
}

/* Scrollbar styles */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 10px;
}

body.dark .chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
}

/* Bubble design */
.chat-bubble {
  max-width: 80%;
  padding: 4px 8px;
  font-family: "Neue", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.3;
  color: #393334; /* pill text color */
  background: #f1f1f1; /* pill background */
  border: 1px solid #e1e1e1; /* pill border */
  border-radius: 12px;
  word-wrap: break-word;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s cubic-bezier(0.63, 0.03, 0.21, 1),
              transform 0.75s cubic-bezier(0.63, 0.03, 0.21, 1),
              background-color 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              color 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Triggered by JS to slide in */
.chat-bubble.bubble-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Dark mode bubble */
body.dark .chat-bubble {
  color: #ebe9e9; /* pill dark text color */
  background: #27282a; /* pill dark background */
  border: 1px solid #3c3d3f; /* pill dark border */
}

@keyframes message-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-bubble.bot {
  background: #f1f1f1; /* pill background */
  color: #393334; /* pill text color */
  border: 1px solid #e1e1e1; /* pill border */
  align-self: flex-start;
  border-radius: 12px; /* fully rounded */
}

body.dark .chat-bubble.bot {
  background: #27282a; /* pill dark background */
  color: #ebe9e9; /* pill dark text color */
  border: 1px solid #3c3d3f; /* pill dark border */
  border-radius: 12px; /* fully rounded */
}

.chat-bubble.user {
  background: #27282a; /* dark background */
  color: #ebe9e9; /* light text */
  border: 1px solid #3c3d3f; /* dark border */
  align-self: flex-end;
  border-radius: 12px; /* fully rounded */
}
body.dark .chat-bubble.user {
  background: #f1f1f1; /* pill background */
  color: #393334; /* pill text color */
  border: 1px solid #e1e1e1; /* pill border */
  align-self: flex-end;
  border-radius: 12px; /* fully rounded */
}


/* Link underlines inside chatbot bubbles matching design system */
.chat-bubble a {
  color: inherit;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--chat-secondary-btn-border);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-bubble a:hover {
  text-decoration-color: var(--chat-secondary-btn-border);
}


/* Typing Indicator */
.chat-typing-indicator {
  display: flex;
  gap: 4px;
  padding: 6px 12px;
  align-items: center;
}

.chat-typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--chat-text-secondary);
  border-radius: 50%;
  opacity: 0.4;
  animation: typing-bounce 1.4s infinite ease-in-out both;
}

.chat-typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.chat-typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1.0); }
}

/* Input Area */
.chat-input-area {
  padding: 15px 20px;
  border-top: 1px solid var(--chat-window-border);
  background: rgba(0, 0, 0, 0.01);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
  transition: background-color 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-input {
  flex-grow: 1;
  border: 1px solid var(--chat-input-border);
  background: var(--chat-input-bg);
  color: var(--chat-text-color);
  padding: 12px 16px;
  border-radius: 25px;
  font-family: var(--chat-font-family);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.02em;
  outline: none;
  transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-input:hover,
.chat-input:focus {
  border-color: rgba(0, 0, 0, 0.5);
  background-color: #f3f3f3;
}

body.dark .chat-input:hover,
body.dark .chat-input:focus {
  border-color: #9a9a9a;
  background-color: #1a1a1a;
}

.chat-send-btn {
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: #1d1b1c;
  border: none;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 15px;
  transition: color 0.8s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-send-btn:hover {
  color: #474343;
}

body.dark .chat-send-btn {
  color: #eeeeee;
}

body.dark .chat-send-btn:hover {
  color: #bdbdbd;
}

.chat-send-icon {
  width: 16px;
  height: 16px;
  font-size: 16px;
  display: inline-block;
  color: inherit;
  opacity: 0.85;
  transition: color 0.8s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Keep icon opacity consistent on hover so color transition matches `.chat-clear-btn` */
.chat-send-btn:hover .chat-send-icon {
  opacity: 0.85;
}


/* Responsive Styles */
@media (max-width: 480px) {
  #ai-chat-widget {
    bottom: 20px;
    right: 20px;
  }
  
  .chat-window {
    width: calc(100vw - 40px);
    height: 70vh;
    max-height: 480px;
  }

  .chat-suggestions {
    display: none !important;
  }
}

.chat-suggestions {
  position: absolute;
  right: 380px; /* Width of chat window (360px) + 20px gap */
  bottom: 80px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  width: max-content;
  max-width: 260px;
  opacity: 1;
  pointer-events: none;
  user-select: none;
  flex-shrink: 0;
}

#ai-chat-widget.is-open .chat-suggestions {
  pointer-events: auto;
}



.chat-suggestions::-webkit-scrollbar {
  display: none; /* Safari/Chrome */
}

.chat-suggest-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  font-family: "Neue", system-ui, sans-serif;
  font-size: 12px;
  letter-spacing: 0.02em;
  font-weight: 400;
  line-height: 1.3;
  color: #1d1b1c;
  background-color: #ebebeb;
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  cursor: pointer;
  transition: background-color 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              color 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.5s cubic-bezier(.63, .03, .21, 1),
              max-width 0.25s ease,
              padding-left 0.25s ease,
              padding-right 0.25s ease,
              margin-left 0.25s ease,
              margin-right 0.25s ease,
              border-left-width 0.25s ease,
              border-right-width 0.25s ease,
              transform 0.75s cubic-bezier(.63, .03, .21, 1);
  flex-shrink: 0;
  max-width: 240px;
  opacity: 0;
  transform: translateY(12px);
  overflow: hidden;
  white-space: nowrap;
  text-align: right;
  /* Stagger animation handled via JS adding .is-visible */
}

/* Stagger-in animation when chat is opened - slides up from below like site menu */
.chat-suggest-btn.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger delays for each chip (1 through 6) */
.chat-suggest-btn:nth-child(1).is-visible { transition-delay: 0ms; }
.chat-suggest-btn:nth-child(2).is-visible { transition-delay: 70ms; }
.chat-suggest-btn:nth-child(3).is-visible { transition-delay: 140ms; }
.chat-suggest-btn:nth-child(4).is-visible { transition-delay: 210ms; }
.chat-suggest-btn:nth-child(5).is-visible { transition-delay: 280ms; }
.chat-suggest-btn:nth-child(6).is-visible { transition-delay: 350ms; }



.chat-suggest-btn.is-hidden {
  opacity: 0 !important;
  max-width: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  border-left-width: 0 !important;
  border-right-width: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  pointer-events: none !important;
}

.chat-suggest-btn:hover {
  background-color: #f3f3f3;
  border-color: rgba(0, 0, 0, 0.5);
  transition: background-color 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

body.dark .chat-suggest-btn {
   color: #ffffff;
   background-color: #131313;
   border: 1px solid rgba(255, 255, 255, 0.35);
}

body.dark .chat-suggest-btn:hover {
  background-color: #1a1a1a;
  border-color: #9a9a9a;
}

/* Responsive styles for Mobile/Tablets */
@media (max-width: 768px) {
  .chat-suggestions {
    display: none !important;
  }

  .chat-suggest-btn {
    white-space: nowrap !important;
    text-align: center;
    max-width: 300px;
    padding: 0.22rem 0.55rem;
    font-size: 12px;
    letter-spacing: 0.02em;
    line-height: 1;
  }

  .chat-messages {
    padding-bottom: 50px !important; /* Make room for suggestions overlay on mobile */
  }
}

