@import url("https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,100..900&display=swap");

/* ============================================================
   SAUDI TOURISM – CHATBOT STYLES
   Follows same token system as itinerary:
   - Backgrounds: var(--color-bg-base / surface / elevated)
   - Text: var(--color-text-primary / secondary)
   - Accent: var(--color-accent-emerald)
   - Borders: var(--color-border / border-subtle)
   - Shadows: var(--shadow-sm / shadow-lg)
   ============================================================ */

/* =============== Chatbot Toggler Button =============== */
#chatbot-toggler {
  position: fixed;
  z-index: 100;
  bottom: 30px;
  right: 35px;
  height: 50px;
  width: 50px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  background: var(--color-accent-emerald);
  box-shadow: var(--shadow-lg);
  transition: all 0.2s ease;
}

#chatbot-toggler:hover {
  transform: translateY(-2px);
}

body.show-chatbot #chatbot-toggler {
  transform: rotate(90deg);
}

#chatbot-toggler span {
  color: #fff;
  position: absolute;
}

/* hide "open" icon when open, hide "close" icon when closed */
body.show-chatbot #chatbot-toggler span:first-child,
#chatbot-toggler span:last-child {
  opacity: 0;
}

body.show-chatbot #chatbot-toggler span:last-child {
  opacity: 1;
}

/* =============== Chatbot Popup Container =============== */
.chatbot-popup {
  direction: ltr;
  font-family: "Inter", sans-serif;
  position: fixed;
  right: 25px;
  bottom: 90px;
  width: 420px;
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  overflow: hidden;
  border-radius: 20px;
  z-index: 2000;
  opacity: 0;
  transform: scale(0.2);
  transform-origin: bottom right;
  pointer-events: none;
  border: 1px solid var(--color-border-subtle);
  box-shadow: var(--shadow-lg);
  transition: all 0.1s ease;
}

body.show-chatbot .chatbot-popup {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

/* =============== Header =============== */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-bg-surface);
  padding: 15px 22px;
  border-bottom: 1px solid var(--color-border-subtle);
}

.chat-header .header-info {
  display: flex;
  gap: 10px;
  align-items: center;
}

.header-info .chatbot-logo {
  height: 35px;
  width: 35px;
  padding: 6px;
  fill: var(--color-accent-emerald);
  flex-shrink: 0;
  background: var(--color-bg-base);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

.header-info .logo-text {
  color: var(--color-text-primary);
  font-size: 1.1rem;
  font-weight: 600;
}

/* small "Online" text under title */
.header-info .status-text {
  font-size: 0.78rem;
  color: var(--color-accent-emerald);
  margin-top: 2px;
}

.chat-header #close-chatbot {
  border: none;
  color: var(--color-text-primary);
  height: 40px;
  width: 40px;
  font-size: 1.9rem;
  margin-right: -10px;
  padding-top: 2px;
  cursor: pointer;
  border-radius: 50%;
  background: none;
  transition: 0.2s ease;
}

.chat-header #close-chatbot:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* =============== Chat Body (Messages Area) =============== */
.chat-body {
  padding: 20px 18px 0;
  background-color: var(--color-bg-base);
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 460px;
  margin-bottom: 82px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-subtle) transparent;
}

.chat-body::-webkit-scrollbar {
  width: 6px;
}

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

.chat-body::-webkit-scrollbar-thumb {
  background: var(--color-border-subtle);
  border-radius: 999px;
}

.chat-body .message {
  display: flex;
  gap: 11px;
  align-items: flex-end;
}

/* avatar circle (if used) */
.chat-body .bot-message .bot-avatar {
  height: 35px;
  width: 35px;
  padding: 6px;
  fill: var(--color-accent-emerald);
  flex-shrink: 0;
  margin-bottom: 2px;
  background: var(--color-bg-surface);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

.chat-body .user-message {
  flex-direction: column;
  align-items: flex-end;
}

/* Shared message bubble styles */
.chat-body .message .message-text {
  padding: 10px 14px;
  max-width: 75%;
  font-size: 0.95rem;
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
  border-radius: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Thinking state */
.chat-body .bot-message.thinking .message-text {
  padding: 2px 16px;
}

/* Bot bubble - emerald accent, left side corner clipped */
.chat-body .bot-message .message-text {
  background-color: var(--color-accent-emerald);
  color: var(--color-text-on-accent, #ffffff);
  border-radius: 16px 16px 16px 4px;
}

/* User bubble - elevated card style */
.chat-body .user-message .message-text {
  background-color: var(--color-bg-elevated);
  color: var(--color-text-primary);
  border-radius: 16px 16px 4px 16px;
  border: 1px solid var(--color-border-subtle);
}

/* Attachments in user messages */
.chat-body .user-message .attachment {
  width: 50%;
  margin-top: -7px;
  border-radius: 13px 3px 13px 3px;
}

/* =============== Thinking Indicator (Typing Dots) =============== */
.chat-body .bot-message .thinking-indicator {
  display: flex;
  gap: 4px;
  padding-block: 15px;
}

.chat-body .bot-message .thinking-indicator .dot {
  height: 7px;
  width: 7px;
  opacity: 0.9;
  border-radius: 50%;
  background: var(--color-accent-emerald);
  animation: dotPulse 1.8s ease-in-out infinite;
}

.chat-body .bot-message .thinking-indicator .dot:nth-child(1) {
  animation-delay: 0.2s;
}

.chat-body .bot-message .thinking-indicator .dot:nth-child(2) {
  animation-delay: 0.3s;
}

.chat-body .bot-message .thinking-indicator .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes dotPulse {
  0%,
  44% {
    transform: translateY(0);
  }

  28% {
    opacity: 0.4;
    transform: translateY(-4px);
  }

  44% {
    opacity: 0.2;
  }
}

/* =============== Footer / Input Area =============== */
.chat-footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  background: var(--color-bg-base);
  padding: 12px 16px 18px;
  border-top: 1px solid var(--color-border-subtle);
}

.chat-footer .chat-form {
  display: flex;
  align-items: center;
  background: var(--color-bg-elevated);
  border-radius: 24px;
  padding-left: 10px;
}

.chat-footer .chat-form:focus-within {
  outline: 1px solid var(--color-accent-emerald);
}

/* Textarea / Input */
.chat-form .message-input {
  border: none;
  outline: none;
  max-height: 47px;
  width: 100%;
  background: transparent;
  color: var(--color-text-primary);
  resize: none;
  white-space: pre-line;
  font-size: 0.95rem;
  padding: 13px 4px;
  border-radius: inherit;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  font-family: "Inter", sans-serif;
}

.chat-form .message-input::placeholder {
  color: var(--color-text-secondary);
  font-family: "Inter", sans-serif;
}

.chat-form .message-input:hover {
  scrollbar-color: var(--color-border-subtle) transparent;
}

/* Controls (send + icons) */
.chat-form .chat-controls {
  padding-right: 6px;
}

.chat-form .chat-controls button {
  height: 35px;
  width: 35px;
  border: none;
  font-size: 1.15rem;
  cursor: pointer;
  color: var(--color-text-secondary);
  background: none;
  border-radius: 50%;
  transition: 0.2s ease;
}

/* Send button – emerald circle */
.chat-form .chat-controls #send-message {
  color: var(--color-text-on-accent, #0b141a);
  display: none;
  background: var(--color-accent-emerald);
  box-shadow: var(--shadow-sm);
}

.chat-form .message-input:valid ~ .chat-controls #send-message {
  display: block;
}

.chat-form .chat-controls #send-message:hover {
  filter: brightness(1.05);
}

.chat-form .chat-controls button:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* =============== Emoji Picker =============== */
em-emoji-picker {
  position: absolute;
  left: 50%;
  top: -337px;
  width: 100%;
  max-width: 350px;
  max-height: 330px;
  visibility: hidden;
  transform: translateX(-50%);
}

body.show-emoji-picker em-emoji-picker {
  visibility: visible;
}

/* =============== Responsive (Mobile) =============== */
@media screen and (max-width: 600px) {
  .chatbot-popup {
    width: 100%;
    right: 0;
    bottom: 0;
    border-radius: 0;
    height: 100%;
  }

  .chat-header .header-info .logo-text {
    font-size: 1rem;
  }

  .chat-body {
    height: 100%;
    margin-bottom: 0;
  }

  .chat-body .message .message-text {
    max-width: 85%;
  }

  .chat-footer .chat-form {
    border-radius: 18px;
  }

  .chat-footer .chat-form .chat-controls {
    padding-right: 10px;
  }

  .chat-footer .chat-form .chat-controls button {
    height: 40px;
    width: 40px;
  }
}

/* =============== RTL SUPPORT =============== */

/* Header: keep close button on the outer side, swap logo/text flow */
[dir="rtl"] .chat-header {
  direction: rtl;
}

[dir="rtl"] .chat-header .header-info {
  flex-direction: row-reverse;
}

[dir="rtl"] .chat-header #close-chatbot {
  margin-right: 0;
  margin-left: -10px;
}

[dir="rtl"] .message .bot-message img{
  direction: ltr;
}

[dir="rtl"] .chat-body .message .message-text {
  text-align: right;
}

/* Input row: RTL typing & paddings swapped */
[dir="rtl"] .chat-footer .chat-form {
  direction: rtl;
  padding-left: 0;
  padding-right: 10px;
}

[dir="rtl"] .chat-form .message-input {
  direction: rtl;
  text-align: right;
}

[dir="rtl"] .chat-form .chat-controls {
  padding-right: 0;
  padding-left: 6px;
}

/* Optional: header text alignment (for multi-line titles) */
[dir="rtl"] .chat-header .header-info .logo-text,
[dir="rtl"] .chat-header .header-info .status-text {
  text-align: right;
}

