/**
 * Mimino FAQ Bot Styles
 */

#faq-bot-widget {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  left: max(20px, env(safe-area-inset-left, 0px));
  right: auto;
  z-index: 9998;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Toggle button */
#faq-bot-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-gold, #C9A456), var(--brand-gold-dark, #A68736));
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(201, 164, 86, 0.4);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

#faq-bot-toggle i {
  font-size: 24px;
  color: white;
}

#faq-bot-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 25px rgba(201, 164, 86, 0.5);
}

#faq-bot-toggle.active {
  background: var(--text-primary, #2D2926);
}

/* Chat window */
#faq-bot-chat {
  position: absolute;
  bottom: 70px;
  left: 0;
  right: auto;
  width: 350px;
  max-width: calc(100vw - 40px);
  height: 450px;
  max-height: calc(100vh - 100px);
  background: var(--bg-primary, #FDFBF7);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(45, 41, 38, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s ease;
}

#faq-bot-chat.hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
}

#faq-bot-chat.rtl {
  direction: rtl;
  text-align: right;
}

/* Header */
#faq-bot-header {
  background: linear-gradient(135deg, var(--brand-gold, #C9A456), var(--brand-gold-dark, #A68736));
  color: white;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

#faq-bot-header-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

#faq-bot-reset,
#faq-bot-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.8;
  transition: all 0.2s;
}

#faq-bot-reset {
  font-size: 14px;
  padding: 5px;
}

#faq-bot-close {
  font-size: 24px;
}

#faq-bot-reset:hover,
#faq-bot-close:hover {
  opacity: 1;
}

#faq-bot-reset:hover {
  transform: rotate(-180deg);
}

/* Messages area */
#faq-bot-messages {
  flex: 1 1 0;
  min-height: 0; /* Required so flex child can actually scroll */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* iOS momentum scrolling */
  overscroll-behavior: contain; /* Prevent scroll chaining */
  touch-action: pan-y; /* Allow vertical touch scrolling */
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.faq-bot-message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.5;
  white-space: pre-line;
  font-size: 14px;
}

.faq-bot-message.bot {
  background: var(--bg-secondary, #F5F0E8);
  color: var(--text-primary, #2D2926);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.faq-bot-message.user {
  background: linear-gradient(135deg, var(--brand-gold, #C9A456), var(--brand-gold-dark, #A68736));
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

#faq-bot-chat.rtl .faq-bot-message.bot {
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 4px;
}

#faq-bot-chat.rtl .faq-bot-message.user {
  border-bottom-right-radius: 16px;
  border-bottom-left-radius: 4px;
}

/* Quick replies */
#faq-bot-quick-replies {
  padding: 0 15px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 0;
  overflow: hidden;
  transition: all 0.3s ease;
}

#faq-bot-quick-replies.visible {
  padding: 10px 15px;
  max-height: 200px;
}

.faq-bot-quick-reply {
  padding: 8px 16px;
  border: 2px solid var(--brand-gold, #C9A456);
  border-radius: 20px;
  background: transparent;
  color: var(--brand-gold, #C9A456);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.faq-bot-quick-reply:hover {
  background: var(--brand-gold, #C9A456);
  color: white;
  transform: translateY(-2px);
}

.faq-bot-quick-reply:active {
  transform: translateY(0);
}

#faq-bot-chat.rtl #faq-bot-quick-replies {
  direction: rtl;
}

/* Input area */
#faq-bot-input-area {
  padding: 15px;
  border-top: 1px solid var(--bg-tertiary, #EDE6DA);
  display: flex;
  gap: 10px;
}

#faq-bot-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--bg-tertiary, #EDE6DA);
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

#faq-bot-input:focus {
  border-color: var(--brand-gold, #C9A456);
}

#faq-bot-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-gold, #C9A456), var(--brand-gold-dark, #A68736));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

#faq-bot-send:hover:not(:disabled) {
  transform: scale(1.05);
}

#faq-bot-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#faq-bot-send i {
  color: white;
  font-size: 16px;
}

#faq-bot-input:disabled {
  background: var(--bg-secondary, #F5F0E8);
  opacity: 0.7;
}

/* Mobile styles */
@media (max-width: 480px) {
  #faq-bot-widget {
    bottom: calc(15px + env(safe-area-inset-bottom, 0px));
    left: max(15px, env(safe-area-inset-left, 0px));
    right: auto;
  }

  #faq-bot-toggle {
    width: 50px;
    height: 50px;
  }

  #faq-bot-toggle i {
    font-size: 20px;
  }

  #faq-bot-chat {
    width: calc(100vw - 30px);
    height: min(70dvh, calc(100vh - 110px));
    bottom: 60px;
    left: -7px;
    right: auto;
    touch-action: none; /* Prevent page scroll when interacting with chat */
  }

  .faq-bot-quick-reply {
    min-height: 44px;
    white-space: normal;
    text-align: center;
    line-height: 1.3;
  }

  #faq-bot-messages {
    min-height: 0; /* Fix flexbox scrolling issue */
    touch-action: pan-y; /* Allow only vertical scroll in messages */
  }
}

/* RTL positioning for Hebrew — chat bot moves to the right, a11y takes the left */
html[lang="he"] #faq-bot-widget {
  left: auto;
  right: max(20px, env(safe-area-inset-right, 0px));
}

html[lang="he"] #faq-bot-chat {
  left: auto;
  right: 0;
}

@media (max-width: 480px) {
  html[lang="he"] #faq-bot-widget {
    left: auto;
    right: max(15px, env(safe-area-inset-right, 0px));
  }

  html[lang="he"] #faq-bot-chat {
    left: auto;
    right: -7px;
  }
}

/* Typing indicator */
.faq-bot-message.typing {
  display: flex;
  gap: 4px;
  padding: 16px 20px;
}

.faq-bot-message.typing span {
  width: 8px;
  height: 8px;
  background: var(--brand-gold, #C9A456);
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out;
}

.faq-bot-message.typing span:nth-child(1) {
  animation-delay: 0s;
}

.faq-bot-message.typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.faq-bot-message.typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-bounce {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  40% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* UserWay widget - force bottom-left position */
.userway_buttons_wrapper,
.uwy.userway_p1,
.uwy.userway_p2,
.uwy.userway_p3,
.uwy.userway_p4,
div[data-userway] {
  top: auto !important;
  bottom: 80px !important;
  left: 10px !important;
  right: auto !important;
}
