/* ==========================================================================
   3BOX ADVERTISING — LIGHTWEIGHT CHAT WIDGET
   Rule-based, zero-dependency, RTL Arabic, Mobile-friendly
   Accent: #D61020 on Dark Theme
   ========================================================================== */

:root {
  --chat-primary: #D61020;
  --chat-primary-hover: #b80d1a;
  --chat-primary-glow: rgba(214, 16, 32, 0.4);
  --chat-bg-panel: #0e0e13;
  --chat-bg-header: #15151c;
  --chat-bg-bubble-bot: #1a1a23;
  --chat-bg-input: #121217;
  --chat-border: rgba(214, 16, 32, 0.3);
  --chat-border-subtle: rgba(255, 255, 255, 0.08);
  --chat-text-main: #f0f0f4;
  --chat-text-muted: #9a9aa8;
}

/* Hide legacy partner pill to keep bottom-left exclusively for the chat assistant */
.box-partner-trigger {
  display: none !important;
}

/* Floating Trigger Button (Bottom-Left) */
.box-chat-trigger {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--chat-primary);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 8px 24px var(--chat-primary-glow), 0 3px 8px rgba(0, 0, 0, 0.6);
  cursor: pointer;
  z-index: 99998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, background-color 0.2s ease;
  outline: none;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.box-chat-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 10px 28px rgba(214, 16, 32, 0.6), 0 4px 10px rgba(0, 0, 0, 0.7);
  background: var(--chat-primary-hover);
}

.box-chat-trigger:active {
  transform: scale(0.96);
}

.box-chat-trigger .box-chat-icon-open,
.box-chat-trigger .box-chat-icon-close {
  width: 26px;
  height: 26px;
  position: absolute;
  transition: opacity 0.2s ease, transform 0.25s ease;
}

.box-chat-trigger .box-chat-icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.7);
}

.box-chat-trigger.is-active .box-chat-icon-open {
  opacity: 0;
  transform: rotate(90deg) scale(0.7);
}

.box-chat-trigger.is-active .box-chat-icon-close {
  opacity: 1;
  transform: rotate(0) scale(1);
}

/* Notification badge indicator */
.box-chat-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 13px;
  height: 13px;
  background: #25d366;
  border: 2.5px solid #0e0e13;
  border-radius: 50%;
  animation: boxChatPulse 2s infinite;
}

@keyframes boxChatPulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 7px rgba(37, 211, 102, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

/* Chat Panel */
.box-chat-panel {
  position: fixed;
  bottom: 92px;
  left: 24px;
  width: 375px;
  max-width: calc(100vw - 32px);
  height: 530px;
  max-height: calc(100vh - 110px);
  background: #0f0f15 !important;
  border: 1px solid var(--chat-border);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.9), 0 0 35px rgba(214, 16, 32, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  direction: rtl;
  text-align: right;
  font-family: 'Cairo', 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  opacity: 0;
  transform: translateY(18px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.box-chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Panel Header */
.box-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #161620 !important;
  border-bottom: 1px solid var(--chat-border-subtle);
  flex-shrink: 0;
}

.box-chat-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.box-chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #000000;
  border: 1.5px solid var(--chat-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: 0 0 10px rgba(214, 16, 32, 0.35);
  flex-shrink: 0;
}

.box-chat-avatar img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.box-chat-title-wrap {
  display: flex;
  flex-direction: column;
}

.box-chat-title {
  font-size: 0.96rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  line-height: 1.25;
}

.box-chat-status {
  font-size: 0.76rem;
  color: #25d366;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.box-chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #25d366;
  display: inline-block;
}

.box-chat-close-btn {
  background: none;
  border: none;
  color: var(--chat-text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease;
  font-size: 1.2rem;
  line-height: 1;
}

.box-chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

/* Messages Body */
.box-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

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

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

.box-chat-body::-webkit-scrollbar-thumb {
  background: rgba(214, 16, 32, 0.3);
  border-radius: 10px;
}

.box-chat-body::-webkit-scrollbar-thumb:hover {
  background: var(--chat-primary);
}

/* Message Rows */
.box-msg-row {
  display: flex;
  flex-direction: column;
  animation: boxMsgFadeIn 0.25s ease-out;
  max-width: 90%;
}

@keyframes boxMsgFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.box-msg-row.bot {
  align-self: flex-start;
}

.box-msg-row.user {
  align-self: flex-end;
}

.box-msg-bubble {
  padding: 11px 14px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--chat-text-main);
  word-break: break-word;
  white-space: pre-line;
}

.box-msg-row.bot .box-msg-bubble {
  background: #181824;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px 14px 2px 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  color: #ffffff;
}

.box-msg-row.user .box-msg-bubble {
  background: var(--chat-primary);
  color: #ffffff;
  border-radius: 14px 14px 14px 2px;
  box-shadow: 0 2px 10px var(--chat-primary-glow);
}

.box-msg-time {
  font-size: 0.68rem;
  color: var(--chat-text-muted);
  margin-top: 4px;
  padding-inline: 4px;
}

/* Typing Indicator */
.box-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--chat-bg-bubble-bot);
  border: 1px solid var(--chat-border-subtle);
  border-radius: 14px;
  width: fit-content;
}

.box-typing-dot {
  width: 6px;
  height: 6px;
  background: var(--chat-text-muted);
  border-radius: 50%;
  animation: boxTyping 1.4s infinite ease-in-out both;
}

.box-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.box-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes boxTyping {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.1); opacity: 1; background: var(--chat-primary); }
}

/* Quick Replies Container */
.box-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
  animation: boxMsgFadeIn 0.3s ease;
}

.box-chip-btn {
  background: rgba(214, 16, 32, 0.16);
  color: #ff6874;
  border: 1px solid rgba(214, 16, 32, 0.5);
  border-radius: 20px;
  padding: 7px 13px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  outline: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
}

.box-chip-btn:hover {
  background: var(--chat-primary);
  color: #ffffff;
  border-color: var(--chat-primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--chat-primary-glow);
}

.box-chip-btn:active {
  transform: translateY(0);
}

/* WhatsApp Action Link Button */
.box-wa-cta-btn {
  background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
  color: #ffffff !important;
  font-weight: 700;
  border-radius: 10px;
  padding: 9px 15px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  text-decoration: none;
  font-size: 0.85rem;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  width: fit-content;
}

.box-wa-cta-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(37, 211, 102, 0.5);
  color: #ffffff;
}

.box-wa-cta-btn svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

/* Page Link CTA Button */
.box-page-cta-btn {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff !important;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 8px 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  text-decoration: none;
  font-size: 0.82rem;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  width: fit-content;
}

.box-page-cta-btn:hover {
  background: rgba(214, 16, 32, 0.2);
  border-color: var(--chat-primary);
  color: #ff616d !important;
}

/* Footer / Input Area */
.box-chat-footer {
  padding: 10px 14px;
  background: #14141d;
  border-top: 1px solid var(--chat-border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.box-chat-input {
  flex: 1;
  background: var(--chat-bg-input);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  padding: 9px 14px;
  color: #ffffff;
  font-size: 0.86rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.box-chat-input:focus {
  border-color: var(--chat-primary);
  box-shadow: 0 0 0 3px rgba(214, 16, 32, 0.2);
}

.box-chat-input::placeholder {
  color: var(--chat-text-muted);
  opacity: 0.8;
}

.box-chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--chat-primary);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, transform 0.18s ease;
  flex-shrink: 0;
  outline: none;
  padding: 0;
}

.box-chat-send-btn:hover {
  background: var(--chat-primary-hover);
  transform: scale(1.05);
}

.box-chat-send-btn:active {
  transform: scale(0.94);
}

.box-chat-send-btn svg {
  width: 17px;
  height: 17px;
  transform: rotate(180deg); /* points appropriately in RTL */
}

/* Mobile Responsiveness (Screen <= 480px, including 390px) */
@media (max-width: 480px) {
  .box-chat-trigger {
    bottom: 16px;
    left: 16px;
    width: 52px;
    height: 52px;
  }
  
  .box-chat-panel {
    bottom: 76px;
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
    height: calc(100vh - 96px);
    max-height: 540px;
    border-radius: 16px;
  }
  
  .box-chat-header {
    padding: 12px 14px;
  }
  
  .box-msg-bubble {
    font-size: 0.85rem;
    padding: 10px 12px;
  }
  
  .box-chip-btn {
    font-size: 0.78rem;
    padding: 6px 11px;
  }
}
