/* ==========================================================================
   Tawarruk Construction Inc. — AI Advisor Chat Widget Styles
   Compact Side-Docked Widget with Radiating Aura & Real-Time Typing
   ========================================================================== */

:root {
  --ai-gold: #d4af37;
  --ai-gold-light: #f5e7b2;
  --ai-gold-dark: #8c641c;
  --ai-strong: #ffd875;
  --ai-gold-gradient: linear-gradient(135deg, #d4af37 0%, #b8860b 100%);
  --ai-bg-dark: #101416;
  --ai-bg-card: rgba(18, 24, 27, 0.97);
  --ai-border: rgba(212, 175, 55, 0.4);
  --ai-border-hover: rgba(212, 175, 55, 0.85);
  --ai-text: #f0f3f5;
  --ai-text-dim: #9aa8b0;
  --ai-bubble-bot: #161c1f;
  --ai-bubble-user: linear-gradient(135deg, #8c641c 0%, #5c4210 100%);
  --ai-shadow: 0 16px 45px rgba(0, 0, 0, 0.65), 0 0 24px rgba(212, 175, 55, 0.2);
}

[data-theme="light"] {
  --ai-bg-dark: #ffffff;
  --ai-bg-card: rgba(255, 255, 255, 0.98);
  --ai-border: rgba(184, 134, 11, 0.4);
  --ai-border-hover: rgba(184, 134, 11, 0.85);
  --ai-gold-light: #6d3f02;
  --ai-strong: #6d3f02;
  --ai-text: #141a1d;
  --ai-text-dim: #5c6c75;
  --ai-bubble-bot: #f2f5f7;
  --ai-bubble-user: linear-gradient(135deg, #c59b27 0%, #9e7512 100%);
  --ai-shadow: 0 16px 45px rgba(0, 0, 0, 0.15), 0 0 20px rgba(212, 175, 55, 0.15);
}

/* --------------------------------------------------------------------------
   Compact Circular Floating Trigger Button with Radiating Gold Aura
   -------------------------------------------------------------------------- */
.ai-advisor-trigger {
  position: fixed;
  bottom: 20px;
  right: 20px;
  left: auto;
  z-index: 100002;
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #263135 0%, #1a2124 100%) !important;
  border: 2px solid var(--ai-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
  animation: ai-radiant-glow 2.8s infinite ease-in-out;
}

[dir="rtl"] .ai-advisor-trigger {
  right: auto;
  left: 20px;
}

@keyframes ai-radiant-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.75), 0 0 16px rgba(212, 175, 55, 0.5), 0 8px 24px rgba(0, 0, 0, 0.7);
  }
  50% {
    box-shadow: 0 0 0 14px rgba(212, 175, 55, 0), 0 0 30px rgba(212, 175, 55, 0.9), 0 12px 30px rgba(0, 0, 0, 0.85);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(212, 175, 55, 0), 0 0 16px rgba(212, 175, 55, 0.5), 0 8px 24px rgba(0, 0, 0, 0.7);
  }
}

.ai-advisor-trigger:hover {
  transform: translateY(-3px) scale(1.1);
  box-shadow: 0 0 32px rgba(212, 175, 55, 1), 0 0 55px rgba(212, 175, 55, 0.6);
}

.ai-trigger-icon-wrap {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-trigger-icon-wrap img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  filter: brightness(1.3) drop-shadow(0 0 3px rgba(212, 175, 55, 0.95));
}

.ai-trigger-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  background: #10b981;
  border: 2px solid #1a2124;
  border-radius: 50%;
  box-shadow: 0 0 6px #10b981;
  animation: ai-pulse 2.2s infinite;
}

@keyframes ai-pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 10px #10b981; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* --------------------------------------------------------------------------
   Compact Side-Docked Chat Window (z-index above header & comfortable height)
   -------------------------------------------------------------------------- */
.ai-advisor-window {
  position: fixed;
  bottom: 84px;
  right: 20px;
  left: auto;
  width: 350px;
  max-width: calc(100vw - 30px);
  height: 480px;
  max-height: calc(100vh - 120px);
  z-index: 100005 !important;
  border-radius: 18px;
  background: var(--ai-bg-card);
  border: 1px solid var(--ai-border);
  box-shadow: var(--ai-shadow);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.96);
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Side dock for RTL (Uyghur on Left Side) */
[dir="rtl"] .ai-advisor-window {
  right: auto;
  left: 20px;
}

.ai-advisor-window.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* --------------------------------------------------------------------------
   Chat Header (Fixed at top, high z-index)
   -------------------------------------------------------------------------- */
.ai-chat-header {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 12px 16px;
  background: rgba(20, 26, 29, 0.98);
  border-bottom: 1px solid var(--ai-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

[data-theme="light"] .ai-chat-header {
  background: rgba(246, 248, 250, 0.98);
}

.ai-header-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-avatar {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: #111517;
  border: 1px solid var(--ai-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 8px rgba(212, 175, 55, 0.3);
}

.ai-avatar img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  filter: brightness(1.2) drop-shadow(0 0 2px rgba(212, 175, 55, 0.8));
}

.ai-header-meta h4 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ai-text);
  line-height: 1.25;
}

.ai-status-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  color: var(--ai-text-dim);
  margin-top: 1px;
}

.ai-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}

.ai-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-btn-icon {
  background: transparent;
  border: none;
  color: var(--ai-text-dim);
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1.05rem;
}

.ai-btn-icon:hover {
  background: rgba(212, 175, 55, 0.15);
  color: var(--ai-gold);
}

/* --------------------------------------------------------------------------
   Chat Messages Body
   -------------------------------------------------------------------------- */
.ai-chat-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

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

.ai-chat-body::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 55, 0.3);
  border-radius: 10px;
}

/* Single Message */
.ai-msg {
  display: flex;
  gap: 8px;
  max-width: 94%;
  animation: ai-fade-in 0.2s ease forwards;
}

@keyframes ai-fade-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.ai-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ai-msg-avatar {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: #111517;
  border: 1px solid var(--ai-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 3px;
}

.ai-msg-avatar img {
  width: 14px;
  height: 14px;
  filter: brightness(1.2) drop-shadow(0 0 1px rgba(212,175,55,0.8));
}

.ai-msg-bubble {
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.8;
  overflow-wrap: break-word;
  word-break: normal;
  text-align: justify;
  text-justify: inter-word;
  text-align-last: start;
}

[dir="rtl"] .ai-msg-bubble {
  font-family: 'UKIJ Ekran', 'UKIJ Tuz', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  text-align: justify !important;
  text-justify: inter-word !important;
  text-align-last: right !important;
  direction: rtl;
  line-height: 1.85;
}

[dir="ltr"] .ai-msg-bubble {
  text-align: justify !important;
  text-justify: inter-word !important;
  text-align-last: left !important;
  direction: ltr;
}

.ai-msg-bot .ai-msg-bubble {
  background: var(--ai-bubble-bot);
  border: 1px solid var(--ai-border);
  color: var(--ai-text);
  border-top-left-radius: 3px;
}

[dir="rtl"] .ai-msg-bot .ai-msg-bubble {
  border-top-left-radius: 14px;
  border-top-right-radius: 3px;
}

.ai-msg-user .ai-msg-bubble {
  background: var(--ai-bubble-user);
  color: #ffffff;
  border-top-right-radius: 3px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(140, 100, 28, 0.25);
  text-align: start !important;
  text-align-last: start !important;
}

[dir="rtl"] .ai-msg-user .ai-msg-bubble {
  border-top-right-radius: 14px;
  border-top-left-radius: 3px;
  text-align: right !important;
  text-align-last: right !important;
}

.ai-msg-user .ai-msg-bubble strong {
  color: #ffffff !important;
}

/* Bullet item styling - Robust block layout with absolute dot (NOT flex) */
.ai-bullet {
  position: relative;
  margin: 6px 0;
  line-height: 1.8;
  display: block;
}

.ai-bullet:first-of-type {
  margin-top: 10px;
}

[dir="rtl"] .ai-bullet {
  padding-right: 20px;
  padding-left: 0;
  text-align: justify;
  text-justify: inter-word;
  text-align-last: right;
  direction: rtl;
}

[dir="ltr"] .ai-bullet {
  padding-left: 20px;
  padding-right: 0;
  text-align: justify;
  text-justify: inter-word;
  text-align-last: left;
  direction: ltr;
}

.ai-bullet-dot {
  position: absolute;
  top: 0;
  color: var(--ai-gold, #8c5a08);
  font-size: 0.72rem;
  line-height: inherit;
  user-select: none;
}

[dir="rtl"] .ai-bullet-dot {
  right: 0;
  left: auto;
}

[dir="ltr"] .ai-bullet-dot {
  left: 0;
  right: auto;
}

.ai-bullet-content,
.ai-bullet-text {
  display: block;
  line-height: inherit;
  overflow-wrap: break-word;
  word-break: normal;
  text-align: justify;
  text-justify: inter-word;
  text-align-last: start;
}

[dir="rtl"] .ai-bullet-content,
[dir="rtl"] .ai-bullet-text {
  text-align: justify !important;
  text-justify: inter-word !important;
  text-align-last: right !important;
}

[dir="ltr"] .ai-bullet-content,
[dir="ltr"] .ai-bullet-text {
  text-align: justify !important;
  text-justify: inter-word !important;
  text-align-last: left !important;
}

/* High-contrast, crystal-clear bold headers & highlights */
.ai-msg-bubble strong,
.ai-bullet-content strong,
.ai-bullet-text strong {
  font-weight: 800;
  display: inline;
  color: var(--ai-strong, #6d3f02);
}

[data-theme="light"] .ai-msg-bubble strong,
[data-theme="light"] .ai-bullet-content strong,
[data-theme="light"] .ai-bullet-text strong {
  color: #6d3f02 !important; /* Deep rich bronze-amber with 8.1:1 contrast on #f2f5f7 */
}

[data-theme="light"] .ai-bullet-dot {
  color: #8c5a08 !important;
}

[data-theme="light"] .ai-msg-heading {
  color: #6d3f02 !important;
}

/* Dark Theme - Luminous warm gold */
:root:not([data-theme="light"]) .ai-msg-bubble strong,
:root:not([data-theme="light"]) .ai-bullet-content strong,
:root:not([data-theme="light"]) .ai-bullet-text strong,
[data-theme="dark"] .ai-msg-bubble strong,
[data-theme="dark"] .ai-bullet-content strong,
[data-theme="dark"] .ai-bullet-text strong {
  color: #ffd875 !important; /* Luminous warm gold with 12.5:1 contrast on #161c1f */
}

:root:not([data-theme="light"]) .ai-bullet-dot,
[data-theme="dark"] .ai-bullet-dot {
  color: #e5b93b !important;
}

:root:not([data-theme="light"]) .ai-msg-heading,
[data-theme="dark"] .ai-msg-heading {
  color: #ffd875 !important;
}

.ai-msg-heading {
  font-weight: 700;
  color: var(--ai-gold, #8c5a08);
  margin: 6px 0 6px;
  font-size: 0.88rem;
  text-align: start !important;
}

/* Typewriter Blinking Cursor */
.ai-typing-cursor {
  display: inline-block;
  width: 5px;
  height: 13px;
  background: var(--ai-gold);
  margin-inline-start: 4px;
  vertical-align: middle;
  animation: ai-cursor-blink 0.7s infinite;
}

@keyframes ai-cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Suggested Action Chips inside message */
.ai-chips-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.ai-chip-btn {
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--ai-gold);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.ai-chip-btn:hover {
  background: var(--ai-gold);
  color: #0e1214;
  border-color: var(--ai-gold);
  transform: translateY(-1px);
}

/* In-Chat Consultation Lead Form (Only when escalated) */
.ai-lead-card {
  margin-top: 8px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(212, 175, 55, 0.08);
  border: 1px dashed var(--ai-gold);
}

.ai-lead-card-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ai-gold);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ai-lead-input-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-lead-input {
  width: 100%;
  padding: 7px 9px;
  border-radius: 6px;
  border: 1px solid var(--ai-border);
  background: rgba(14, 18, 20, 0.6);
  color: var(--ai-text);
  font-size: 0.78rem;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
}

[data-theme="light"] .ai-lead-input {
  background: #ffffff;
}

.ai-lead-input:focus {
  border-color: var(--ai-gold);
}

.ai-lead-submit {
  padding: 7px 10px;
  border-radius: 6px;
  background: var(--ai-gold-gradient);
  color: #0e1214;
  font-weight: 700;
  font-size: 0.76rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.ai-lead-submit:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   Quick Starters Bar (5 Rotating Questions, 3s Cycle, Slide-up from bottom)
   -------------------------------------------------------------------------- */
.ai-quick-starters {
  flex-shrink: 0;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid rgba(212, 175, 55, 0.15);
  background: rgba(14, 18, 20, 0.65);
  backdrop-filter: blur(8px);
  position: relative;
  height: 44px;
  box-sizing: border-box;
  overflow: hidden;
}

[data-theme="light"] .ai-quick-starters {
  background: rgba(246, 248, 250, 0.85);
}

.ai-starter-slider {
  position: relative;
  width: 100%;
  height: 32px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-starter-btn {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 0);
  height: 30px;
  line-height: 28px;
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid var(--ai-border);
  border-radius: 999px;
  padding: 0 14px;
  font-size: 0.72rem;
  color: var(--ai-gold);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 96%;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  user-select: none;
}

.ai-starter-btn:hover {
  color: #0e1214;
  background: var(--ai-gold);
  border-color: var(--ai-gold);
  box-shadow: 0 4px 14px rgba(212, 175, 55, 0.45);
}

.ai-starter-btn.is-incoming {
  transform: translate(-50%, 100%);
  opacity: 0;
}

.ai-starter-btn.is-active {
  transform: translate(-50%, 0);
  opacity: 1;
}

.ai-starter-btn.is-outgoing {
  transform: translate(-50%, -100%);
  opacity: 0;
}

/* --------------------------------------------------------------------------
   Footer Input Bar (Fixed at bottom)
   -------------------------------------------------------------------------- */
.ai-chat-footer {
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 10;
  padding: 8px 10px;
  background: rgba(14, 18, 20, 0.98);
  border-top: 1px solid var(--ai-border);
}

[data-theme="light"] .ai-chat-footer {
  background: #ffffff;
}

.ai-input-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-text-input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--ai-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ai-text);
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease;
}

[data-theme="light"] .ai-text-input {
  background: #f4f6f8;
  color: #111416;
}

.ai-text-input:focus {
  border-color: var(--ai-gold);
}

.ai-btn-send {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--ai-gold-gradient);
  border: none;
  color: #0e1214;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.ai-btn-send:hover {
  transform: scale(1.08);
  filter: brightness(1.1);
}

.ai-btn-send svg {
  width: 15px;
  height: 15px;
  transform: rotate(45deg);
}

[dir="rtl"] .ai-btn-send svg {
  transform: rotate(-135deg);
}

/* Typing Indicator Animation */
.ai-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 11px;
  background: var(--ai-bubble-bot);
  border: 1px solid var(--ai-border);
  border-radius: 12px;
  width: fit-content;
}

.ai-typing-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ai-gold);
  animation: ai-bounce 1.4s infinite ease-in-out;
}

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

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

@keyframes ai-bounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* --------------------------------------------------------------------------
   Mobile Viewports
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .ai-advisor-trigger {
    bottom: 78px;
    right: 14px;
    left: auto;
    width: 48px;
    height: 48px;
  }

  [dir="rtl"] .ai-advisor-trigger {
    right: auto;
    left: 14px;
  }

  .ai-advisor-widget-root.is-chat-open .ai-advisor-trigger {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.85);
  }

  .ai-advisor-window,
  [dir="rtl"] .ai-advisor-window {
    bottom: 82px;
    right: 10px;
    left: 10px;
    margin: 0 auto;
    width: auto;
    max-width: 400px;
    height: min(500px, calc(100dvh - 104px));
    max-height: calc(100dvh - 96px);
    border-radius: 16px;
  }
}

.ai-lead-consent-label{display:flex;gap:8px;align-items:flex-start;font-size:13px;line-height:1.7;margin:12px 0}.ai-lead-error{color:#ef4444;font-size:14px}
