/**
 * Take a Seat - AI Chat Widget Styles
 * Modern, clean, RTL-ready design
 */

#takeaseat-chat-widget {
  position: fixed;
  bottom: 20px;
  left: auto;
  right: 20px;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  direction: rtl;
  pointer-events: none;
}

/* Adjust position when sidebar is visible (authenticated users) */
/* Position will be handled by [dir] selectors below */
body:has(aside) #takeaseat-chat-widget {
  /* Position handled by [dir] selectors */
}

@media (max-width: 768px) {
  body:has(aside) #takeaseat-chat-widget {
    /* Position handled by [dir] selectors */
  }
}

#takeaseat-chat-widget > * {
  pointer-events: auto;
}

/* Chat Bubble */
.takeaseat-chat-bubble {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #426b67 0%, #3a5d59 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 20px rgba(66, 107, 103, 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.takeaseat-chat-bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(66, 107, 103, 0.5);
}

.takeaseat-chat-bubble:active {
  transform: scale(0.95);
}

.takeaseat-chat-bubble svg {
  width: 28px;
  height: 28px;
}

/* Chat Window */
.takeaseat-chat-window {
  /* Position will be overridden by .chatbot-container with !important */
  position: absolute;
  bottom: 80px;
  left: auto;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: takeaseat-slide-up 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid #eadfd2;
}

/* Adjust chat window width when sidebar is visible */
body:has(aside) .takeaseat-chat-window {
  max-width: calc(100vw - 256px - 40px); /* Account for sidebar on left */
}

.takeaseat-hidden {
  display: none !important;
}

/* Tabs */
.takeaseat-tabs {
  display: flex;
  border-bottom: 1px solid #eadfd2;
  background: #fafafa;
  padding: 0;
  margin: 0;
}

.takeaseat-tab {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: #636E72;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
  text-align: center;
}

.takeaseat-tab:hover {
  background: #f0f0f0;
  color: #2D3436;
}

.takeaseat-tab-active {
  color: #426b67;
  border-bottom-color: #426b67;
  background: white;
  font-weight: 600;
}

@keyframes takeaseat-slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Header */
.takeaseat-chat-header {
  background: linear-gradient(135deg, #426b67 0%, #3a5d59 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.takeaseat-chat-header-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.takeaseat-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.takeaseat-chat-title {
  font-weight: 600;
  font-size: 16px;
  line-height: 1.2;
}

.takeaseat-chat-subtitle {
  font-size: 12px;
  opacity: 0.9;
  line-height: 1.2;
}

.takeaseat-chat-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.2s;
  opacity: 0.8;
}

.takeaseat-chat-close:hover {
  background: rgba(255, 255, 255, 0.2);
  opacity: 1;
}

/* Messages Container */
.takeaseat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #FAFAFA;
}

.takeaseat-messages::-webkit-scrollbar {
  width: 6px;
}

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

.takeaseat-messages::-webkit-scrollbar-thumb {
  background: #eadfd2;
  border-radius: 3px;
}

.takeaseat-messages::-webkit-scrollbar-thumb:hover {
  background: #d7cec3;
}

/* Message */
.takeaseat-message {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  animation: takeaseat-message-appear 0.3s ease-out;
}

@keyframes takeaseat-message-appear {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.takeaseat-message-user {
  flex-direction: row-reverse;
}

.takeaseat-message-assistant {
  flex-direction: row;
}

.takeaseat-message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f0eae0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #426b67;
  flex-shrink: 0;
}

.takeaseat-message-content {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 14px;
  word-wrap: break-word;
}

.takeaseat-message-user .takeaseat-message-content {
  background: linear-gradient(135deg, #426b67 0%, #3a5d59 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.takeaseat-message-assistant .takeaseat-message-content {
  background: white;
  color: #2D3436;
  border: 1px solid #E9ECEF;
  border-bottom-left-radius: 4px;
}

/* Typing Indicator */
.takeaseat-typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.takeaseat-typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #426b67;
  animation: takeaseat-typing 1.4s infinite;
}

.takeaseat-typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.takeaseat-typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes takeaseat-typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Quick Replies */
.takeaseat-quick-replies {
  padding: 12px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: white;
  border-top: 1px solid #E9ECEF;
  flex-shrink: 0;
}

.takeaseat-quick-reply {
  padding: 8px 16px;
  background: #f0eae0;
  color: #426b67;
  border: 1px solid #eadfd2;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.takeaseat-quick-reply:hover {
  background: #f0eae0;
  border-color: #d7cec3;
  transform: translateY(-1px);
}

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

/* Mobile layout fixes for chatbot FAQ buttons */
@media (max-width: 480px) {
  .chatbot-faq-strip {
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    gap: 8px !important;
    padding: 8px 4px !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
  }

  .chatbot-faq-item {
    display: inline-flex !important;
    padding: 8px 14px !important;
    background-color: #f0eae0 !important;
    color: #426b67 !important;
    border: 1px solid #eadfd2 !important;
    border-radius: 25px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    font-size: 14px !important;
    cursor: pointer !important;
  }
}

/* Input Area */
.takeaseat-input-area {
  padding: 16px 20px;
  background: white;
  border-top: 1px solid #E9ECEF;
  flex-shrink: 0;
}

.takeaseat-input-wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
}

.takeaseat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #eadfd2;
  border-radius: 24px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s;
  background: #FAFAFA;
  color: #2D3436;
}

.takeaseat-input:focus {
  border-color: #426b67;
  background: white;
  box-shadow: 0 0 0 3px rgba(66, 107, 103, 0.1);
}

.takeaseat-input::placeholder {
  color: #636E72;
}

.takeaseat-send-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #426b67 0%, #3a5d59 100%);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.takeaseat-send-button:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(66, 107, 103, 0.4);
}

.takeaseat-send-button:active {
  transform: scale(0.95);
}

.takeaseat-send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* CHAT FLOATING BUTTON — FIX FOR MOBILE */
.chatbot-floating-button {
  position: fixed !important;
  bottom: 20px !important;
  right: 20px !important;
  z-index: 999999 !important;
  width: 65px !important;
  height: 65px !important;
}

.chatbot-container {
  position: fixed !important;
  bottom: 100px !important;
  right: 10px !important;
  width: 90% !important;
  max-width: 380px !important;
  z-index: 999999 !important;
}

/* Desktop-only chatbot height */
@media (min-width: 769px) {
  .chatbot-container,
  .takeaseat-chat-window.chatbot-container,
  #takeaseat-chat-window.chatbot-container {
    max-height: 75vh !important;
    height: 75vh !important;
  }
  
  /* Override the base .takeaseat-chat-window height on desktop */
  .takeaseat-chat-window {
    max-height: 75vh !important;
    height: 75vh !important;
  }
}

@media (max-width: 480px) {
  .chatbot-floating-button {
    width: 55px !important;
    height: 55px !important;
    bottom: 15px !important;
    /* Position will be handled by [dir] selectors below */
  }

  .chatbot-container {
    width: 95% !important;
    bottom: 80px !important;
    height: 75vh !important;
    /* Position will be handled by [dir] selectors below */
  }

  [dir="rtl"] .chatbot-floating-button {
    right: 15px !important;
    left: auto !important;
  }

  [dir="ltr"] .chatbot-floating-button {
    left: 15px !important;
    right: auto !important;
  }

  [dir="rtl"] .chatbot-container {
    right: 2.5% !important;
    left: auto !important;
  }

  [dir="ltr"] .chatbot-container {
    left: 2.5% !important;
    right: auto !important;
  }

  .takeaseat-message-content {
    max-width: 85%;
  }
}

/* RTL Support - Widget on right, opens to the left (inward) */
[dir="rtl"] #takeaseat-chat-widget {
  left: auto;
  right: 20px;
}

[dir="rtl"] .takeaseat-chat-window {
  left: auto;
  right: 0;
}

[dir="rtl"] .chatbot-floating-button {
  right: 20px !important;
  left: auto !important;
}

[dir="rtl"] .chatbot-container {
  right: 10px !important;
  left: auto !important;
}

/* LTR Support - Widget on left, opens to the right (inward) */
[dir="ltr"] #takeaseat-chat-widget {
  left: 20px;
  right: auto;
}

[dir="ltr"] .takeaseat-chat-window {
  left: 0;
  right: auto;
}

[dir="ltr"] .chatbot-floating-button {
  left: 20px !important;
  right: auto !important;
}

[dir="ltr"] .chatbot-container {
  left: 10px !important;
  right: auto !important;
}

[dir="ltr"] .takeaseat-message-user {
  flex-direction: row;
}

[dir="ltr"] .takeaseat-message-assistant {
  flex-direction: row-reverse;
}

