/* ==========================================================================
   Alola Intelligent AI Concierge - Widget Styles
   ========================================================================== */

:root {
  --alola-chat-primary: #0284c7;
  --alola-chat-accent: #0ea5e9;
  --alola-chat-bg: #ffffff;
  --alola-chat-text: #0f172a;
  --alola-chat-muted: #64748b;
  --alola-chat-border: rgba(226, 232, 240, 0.95);
  --alola-chat-shadow: 0 24px 60px rgba(15, 23, 42, 0.20), 0 0 1px rgba(0, 0, 0, 0.1);
  --alola-chat-user-bg: linear-gradient(135deg, #0284c7, #025a9e);
  --alola-chat-bot-bg: #f8fafc;
  --alola-chat-font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html[data-theme="dark"] {
  --alola-chat-bg: #0b1528;
  --alola-chat-text: #f8fafc;
  --alola-chat-muted: #94a3b8;
  --alola-chat-border: rgba(255, 255, 255, 0.12);
  --alola-chat-shadow: 0 24px 60px rgba(0, 0, 0, 0.8), 0 0 35px rgba(14, 165, 233, 0.15);
  --alola-chat-user-bg: linear-gradient(135deg, #0284c7, #0369a1);
  --alola-chat-bot-bg: #0f1d35;
}

/* Floating Launcher Button */
.alola-chat-launcher {
  position: fixed;
  bottom: 26px;
  right: 26px;
  z-index: 99998;
  width: 60px;
  height: 60px;
  border-radius: 999px;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 28px rgba(2, 132, 199, 0.42), 0 0 0 0 rgba(14, 165, 233, 0.5);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s ease;
  outline: none;
}

html[lang="ar"] .alola-chat-launcher {
  right: auto;
  left: 26px;
}

.alola-chat-launcher:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 16px 36px rgba(2, 132, 199, 0.55), 0 0 20px rgba(14, 165, 233, 0.4);
}

.alola-chat-launcher:active {
  transform: scale(0.96);
}

/* Ambient Pulse Ring */
.alola-chat-launcher::before {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 999px;
  border: 2px solid rgba(14, 165, 233, 0.6);
  opacity: 0;
  animation: alolaLauncherPulse 3s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

@keyframes alolaLauncherPulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 0; }
  100% { transform: scale(1.3); opacity: 0; }
}

.alola-chat-launcher svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.alola-chat-launcher .close-icon {
  display: none;
}

.alola-chat-launcher.is-active .chat-icon {
  display: none;
}

.alola-chat-launcher.is-active .close-icon {
  display: block;
}

/* Unread Notification Badge */
.alola-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background: #10b981;
  border: 2.5px solid #ffffff;
  border-radius: 999px;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

html[data-theme="dark"] .alola-chat-badge {
  border-color: #0b1528;
}

/* Chat Drawer Container */
.alola-chat-window {
  position: fixed;
  bottom: 98px;
  right: 26px;
  width: 390px;
  height: 600px;
  max-height: calc(100vh - 120px);
  background: var(--alola-chat-bg);
  border: 1px solid var(--alola-chat-border);
  border-radius: 24px;
  box-shadow: var(--alola-chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  font-family: var(--alola-chat-font);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(16px);
}

html[lang="ar"] .alola-chat-window {
  right: auto;
  left: 26px;
  direction: rtl;
}

.alola-chat-window.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Chat Header */
.alola-chat-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.08) 0%, rgba(14, 165, 233, 0.03) 100%);
  border-bottom: 1px solid var(--alola-chat-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

html[data-theme="dark"] .alola-chat-header {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.12) 0%, rgba(2, 132, 199, 0.04) 100%);
}

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

.alola-chat-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.alola-chat-status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background: #10b981;
  border: 2px solid var(--alola-chat-bg);
  border-radius: 999px;
  box-shadow: 0 0 6px #10b981;
}

.alola-chat-title strong {
  display: block;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--alola-chat-text);
  line-height: 1.2;
}

.alola-chat-title small {
  display: block;
  font-size: 11px;
  color: #10b981;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.alola-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.alola-chat-btn-icon {
  background: transparent;
  border: none;
  color: var(--alola-chat-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.alola-chat-btn-icon:hover {
  background: rgba(14, 165, 233, 0.1);
  color: var(--alola-chat-text);
}

/* Chat Messages Stream */
.alola-chat-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

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

.alola-chat-body::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 999px;
}

/* Message Bubble */
.alola-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: alolaMsgFade 0.25s ease-out forwards;
}

@keyframes alolaMsgFade {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

.alola-msg.is-bot {
  align-self: flex-start;
}

.alola-msg.is-user {
  align-self: flex-end;
}

.alola-msg-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.alola-msg.is-bot .alola-msg-bubble {
  background: var(--alola-chat-bot-bg);
  border: 1px solid var(--alola-chat-border);
  color: var(--alola-chat-text);
  border-top-left-radius: 4px;
}

html[lang="ar"] .alola-msg.is-bot .alola-msg-bubble {
  border-top-left-radius: 18px;
  border-top-right-radius: 4px;
}

.alola-msg.is-user .alola-msg-bubble {
  background: var(--alola-chat-user-bg);
  color: #ffffff;
  border-top-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.25);
}

html[lang="ar"] .alola-msg.is-user .alola-msg-bubble {
  border-top-right-radius: 18px;
  border-top-left-radius: 4px;
}

/* Markdown styling inside bubbles */
.alola-msg-bubble h3 {
  margin: 0 0 8px;
  font-size: 14.5px;
  font-weight: 800;
  color: var(--alola-chat-text);
}
.alola-msg.is-user .alola-msg-bubble h3 { color: #fff; }

.alola-msg-bubble p {
  margin: 0 0 8px;
}
.alola-msg-bubble p:last-child {
  margin-bottom: 0;
}

.alola-msg-bubble ul {
  margin: 6px 0 10px;
  padding-left: 18px;
}

html[lang="ar"] .alola-msg-bubble ul {
  padding-left: 0;
  padding-right: 18px;
}

.alola-msg-bubble li {
  margin-bottom: 5px;
}

.alola-msg-bubble strong {
  color: var(--alola-chat-primary);
}
.alola-msg.is-user .alola-msg-bubble strong { color: #fff; }
html[data-theme="dark"] .alola-msg-bubble strong { color: #38bdf8; }

.alola-msg-bubble a {
  color: #0284c7;
  text-decoration: underline;
  font-weight: 600;
}
html[data-theme="dark"] .alola-msg-bubble a { color: #38bdf8; }

/* Quick Action Chips */
.alola-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

/* ==========================================================================
   Categorized Navigation Hub
   ========================================================================== */
.alola-hub-container {
  margin-top: 12px;
  background: var(--alola-chat-bg);
  border: 1px solid var(--alola-chat-border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.05);
}

.alola-hub-tabs {
  display: flex;
  background: rgba(14, 165, 233, 0.06);
  border-bottom: 1px solid var(--alola-chat-border);
  padding: 4px;
  gap: 4px;
  overflow-x: auto;
}

.alola-hub-tabs::-webkit-scrollbar {
  display: none;
}

.alola-hub-tab {
  flex: 1 1 auto;
  white-space: nowrap;
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 700;
  border: none;
  background: transparent;
  color: var(--alola-chat-muted);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  text-align: center;
}

.alola-hub-tab:hover {
  color: var(--alola-chat-text);
  background: rgba(255, 255, 255, 0.5);
}

html[data-theme="dark"] .alola-hub-tab:hover {
  background: rgba(255, 255, 255, 0.06);
}

.alola-hub-tab.active {
  background: var(--alola-chat-bg);
  color: var(--alola-chat-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

html[data-theme="dark"] .alola-hub-tab.active {
  color: #38bdf8;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.alola-hub-panel {
  display: none;
  padding: 10px;
  flex-direction: column;
  gap: 6px;
  animation: alolaHubFade 0.2s ease-out forwards;
}

.alola-hub-panel.active {
  display: flex;
}

@keyframes alolaHubFade {
  0% { opacity: 0; transform: translateY(4px); }
  100% { opacity: 1; transform: translateY(0); }
}

.alola-hub-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  background: var(--alola-chat-bot-bg);
  border: 1px solid var(--alola-chat-border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  outline: none;
  width: 100%;
}

html[lang="ar"] .alola-hub-item {
  text-align: right;
}

.alola-hub-item:hover {
  background: rgba(14, 165, 233, 0.09);
  border-color: var(--alola-chat-primary);
  transform: translateX(3px);
}

html[lang="ar"] .alola-hub-item:hover {
  transform: translateX(-3px);
}

.alola-hub-icon {
  font-size: 15px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(14, 165, 233, 0.1);
  border-radius: 7px;
  flex-shrink: 0;
}

.alola-hub-text strong {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--alola-chat-text);
  line-height: 1.25;
}

.alola-hub-text small {
  display: block;
  font-size: 10px;
  color: var(--alola-chat-muted);
  line-height: 1.2;
}

.alola-chip {
  background: rgba(14, 165, 233, 0.08);
  border: 1px solid rgba(14, 165, 233, 0.22);
  color: var(--alola-chat-text);
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.alola-chip:hover {
  background: var(--alola-chat-primary);
  border-color: var(--alola-chat-primary);
  color: #ffffff;
  transform: translateY(-1px);
}

.alola-chip.is-home-chip {
  background: rgba(16, 185, 129, 0.12) !important;
  border: 1px solid rgba(16, 185, 129, 0.45) !important;
  color: #047857 !important;
  font-weight: 700 !important;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.12) !important;
}

.alola-chip.is-home-chip:hover {
  background: #10b981 !important;
  border-color: #10b981 !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35) !important;
  transform: translateY(-1px) !important;
}

html[data-theme="dark"] .alola-chip.is-home-chip {
  background: rgba(16, 185, 129, 0.18) !important;
  border: 1px solid rgba(16, 185, 129, 0.55) !important;
  color: #34d399 !important;
}

html[data-theme="dark"] .alola-chip.is-home-chip:hover {
  background: #10b981 !important;
  border-color: #10b981 !important;
  color: #ffffff !important;
}

/* Action Buttons inside Bubble */
.alola-msg-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.alola-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #ffffff !important;
  font-size: 12.5px;
  font-weight: 700;
  border-radius: 10px;
  text-decoration: none !important;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.alola-action-btn:hover {
  background: linear-gradient(135deg, #0369a1, #075985);
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
}

/* In-Chat Lead Form */
.alola-lead-card {
  margin-top: 10px;
  padding: 14px;
  background: var(--alola-chat-bg);
  border: 1px solid var(--alola-chat-border);
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
}

.alola-lead-card input,
.alola-lead-card textarea {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 8px;
  font-size: 12px;
  border: 1px solid var(--alola-chat-border);
  border-radius: 8px;
  background: var(--alola-chat-bot-bg);
  color: var(--alola-chat-text);
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
}

.alola-lead-card input:focus,
.alola-lead-card textarea:focus {
  border-color: var(--alola-chat-primary);
}

.alola-lead-card button {
  width: 100%;
  padding: 9px;
  background: #0284c7;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.alola-lead-card button:hover {
  background: #0369a1;
}

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

.alola-typing-dot {
  width: 6px;
  height: 6px;
  background: var(--alola-chat-muted);
  border-radius: 999px;
  animation: alolaDotPulse 1.4s infinite ease-in-out;
}

.alola-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.alola-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes alolaDotPulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* Chat Input Footer */
.alola-chat-footer {
  padding: 12px 16px;
  background: var(--alola-chat-bg);
  border-top: 1px solid var(--alola-chat-border);
  flex-shrink: 0;
}

.alola-chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.alola-chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--alola-chat-border);
  border-radius: 999px;
  background: var(--alola-chat-bot-bg);
  color: var(--alola-chat-text);
  font-size: 13px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.alola-chat-input:focus {
  border-color: var(--alola-chat-primary);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

.alola-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
  outline: none;
}

.alola-chat-send:hover {
  transform: scale(1.06);
  background: linear-gradient(135deg, #0369a1, #075985);
}

.alola-chat-send svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: translateX(1px);
}

html[lang="ar"] .alola-chat-send svg {
  transform: scaleX(-1);
}

.alola-chat-caption {
  font-size: 10px;
  color: var(--alola-chat-muted);
  text-align: center;
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* Mobile Fullscreen Modal */
@media (max-width: 480px) {
  .alola-chat-window {
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
  .alola-chat-launcher {
    bottom: 18px;
    right: 18px;
  }
  html[lang="ar"] .alola-chat-launcher {
    left: 18px;
  }
}
