/* ==========================================================================
   PURE ESTHETIC - ASSISTANT VIRTUEL INTERACTIF (SOFIA)
   Design System, Floating Widget, Chat Window, Glassmorphism & Responsiveness
   ========================================================================== */

:root {
  --ast-primary: #08111e;
  --ast-primary-gradient: linear-gradient(135deg, #08111e 0%, #10233d 100%);
  --ast-gold: #c59d5f;
  --ast-gold-hover: #b38b4d;
  --ast-gold-light: #f8f3ec;
  --ast-gold-glow: rgba(197, 157, 95, 0.35);
  --ast-emerald: #10b981;
  --ast-bg-light: #f8fafc;
  --ast-bg-chat: #f1f5f9;
  --ast-card-bg: #ffffff;
  --ast-text-dark: #0f172a;
  --ast-text-muted: #64748b;
  --ast-border-color: rgba(226, 232, 240, 0.8);
  --ast-shadow-lg: 0 20px 50px rgba(8, 17, 30, 0.25);
  --ast-shadow-md: 0 8px 24px rgba(8, 17, 30, 0.12);
  --ast-radius-lg: 20px;
  --ast-radius-md: 12px;
  --ast-radius-sm: 8px;
  --ast-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --------------------------------------------------------------------------
   1. Floating Trigger Button & Notification Badge
   -------------------------------------------------------------------------- */
.ast-trigger-wrapper {
  position: fixed;
  bottom: 24px;
  right: 88px; /* Offset to align nicely next to back-to-top & whatsapp buttons */
  z-index: 1055;
  display: flex;
  align-items: center;
  gap: 12px;
}

.ast-trigger-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--ast-primary-gradient);
  border: 2px solid var(--ast-gold);
  color: #ffffff;
  box-shadow: var(--ast-shadow-lg), 0 0 15px var(--ast-gold-glow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: var(--ast-transition);
  outline: none;
}

.ast-trigger-btn:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 15px 35px rgba(8, 17, 30, 0.35), 0 0 25px rgba(197, 157, 95, 0.6);
}

.ast-trigger-btn:active {
  transform: scale(0.96);
}

.ast-trigger-btn .ast-pulse-ring {
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 2px solid var(--ast-gold);
  animation: astPulse 2.2s infinite;
  opacity: 0;
  pointer-events: none;
}

@keyframes astPulse {
  0% {
    transform: scale(0.95);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.35);
    opacity: 0;
  }
}

.ast-trigger-btn .ast-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #ef4444;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  animation: astBounce 1s ease infinite alternate;
}

@keyframes astBounce {
  from { transform: translateY(0); }
  to { transform: translateY(-3px); }
}

.ast-trigger-avatar-img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}

/* --------------------------------------------------------------------------
   2. Teaser Bubble (Proactive Greeting)
   -------------------------------------------------------------------------- */
.ast-teaser-popover {
  position: fixed;
  bottom: 94px;
  right: 24px;
  z-index: 1054;
  width: 320px;
  background: #ffffff;
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 15px 35px rgba(8, 17, 30, 0.18), 0 0 0 1px rgba(197, 157, 95, 0.25);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  animation: astSlideInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  transition: var(--ast-transition);
}

.ast-teaser-popover.ast-hidden {
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
}

.ast-teaser-avatar {
  position: relative;
  flex-shrink: 0;
}

.ast-teaser-avatar img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--ast-gold);
  object-fit: cover;
}

.ast-teaser-avatar .ast-status-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  background: var(--ast-emerald);
  border: 2px solid #ffffff;
  border-radius: 50%;
}

.ast-teaser-content {
  flex-grow: 1;
}

.ast-teaser-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ast-primary);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ast-teaser-close {
  background: none;
  border: none;
  color: var(--ast-text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  border-radius: 4px;
}

.ast-teaser-close:hover {
  color: var(--ast-primary);
  background: #f1f5f9;
}

.ast-teaser-text {
  font-size: 0.82rem;
  color: #334155;
  line-height: 1.35;
  margin-bottom: 8px;
}

.ast-teaser-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ast-gold);
  background: var(--ast-gold-light);
  padding: 4px 10px;
  border-radius: 20px;
  text-decoration: none;
  border: 1px solid rgba(197, 157, 95, 0.3);
  cursor: pointer;
  transition: var(--ast-transition);
}

.ast-teaser-btn:hover {
  background: var(--ast-gold);
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   3. Main Chat Window Layout
   -------------------------------------------------------------------------- */
.ast-window {
  position: fixed;
  bottom: 94px;
  right: 24px;
  z-index: 1060;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 120px);
  background: var(--ast-card-bg);
  border-radius: var(--ast-radius-lg);
  box-shadow: var(--ast-shadow-lg), 0 0 0 1px rgba(197, 157, 95, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ast-window.ast-active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* --- Header --- */
.ast-header {
  background: var(--ast-primary-gradient);
  color: #ffffff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--ast-gold);
  position: relative;
}

.ast-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ast-avatar-box {
  position: relative;
}

.ast-avatar-box img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--ast-gold);
  object-fit: cover;
  background: #ffffff;
}

.ast-avatar-box .ast-status-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 11px;
  height: 11px;
  background: var(--ast-emerald);
  border: 2px solid var(--ast-primary);
  border-radius: 50%;
}

.ast-header-text h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
  color: #ffffff;
  letter-spacing: 0.2px;
}

.ast-header-text p {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.ast-header-icon-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: rgba(255, 255, 255, 0.85);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--ast-transition);
  font-size: 0.9rem;
}

.ast-header-icon-btn:hover {
  background: var(--ast-gold);
  color: #ffffff;
}

/* --- Banner Notice / VIP Badge --- */
.ast-vip-banner {
  background: linear-gradient(90deg, #faf6f0 0%, #ffffff 100%);
  border-bottom: 1px solid rgba(197, 157, 95, 0.2);
  padding: 8px 16px;
  font-size: 0.75rem;
  color: var(--ast-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.ast-vip-badge {
  background: var(--ast-gold);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

/* --- Body / Messages List --- */
.ast-body {
  flex-grow: 1;
  padding: 16px;
  overflow-y: auto;
  background: var(--ast-bg-light);
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

/* Custom Scrollbar */
.ast-body::-webkit-scrollbar {
  width: 5px;
}
.ast-body::-webkit-scrollbar-track {
  background: transparent;
}
.ast-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

/* Message Rows */
.ast-msg-row {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: astFadeIn 0.3s ease;
}

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

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

.ast-msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.86rem;
  line-height: 1.45;
  word-wrap: break-word;
  position: relative;
}

.ast-bot .ast-msg-bubble {
  background: #ffffff;
  color: var(--ast-text-dark);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.04);
  border-left: 3px solid var(--ast-gold);
}

.ast-user .ast-msg-bubble {
  background: var(--ast-primary-gradient);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(8, 17, 30, 0.2);
}

.ast-msg-time {
  font-size: 0.68rem;
  color: var(--ast-text-muted);
  margin-top: 4px;
  align-self: flex-end;
}

.ast-user .ast-msg-time {
  color: rgba(255, 255, 255, 0.7);
}

/* --- Typing Indicator --- */
.ast-typing-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: #ffffff;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  width: fit-content;
  align-self: flex-start;
  margin-bottom: 6px;
  border-left: 3px solid var(--ast-gold);
}

.ast-typing-dot {
  width: 7px;
  height: 7px;
  background: var(--ast-gold);
  border-radius: 50%;
  animation: astDotBlink 1.4s infinite ease-in-out both;
}

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

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

/* --- Quick Reply Chips / Options Container --- */
.ast-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.ast-chip-btn {
  background: #ffffff;
  border: 1px solid rgba(197, 157, 95, 0.4);
  color: var(--ast-primary);
  padding: 7px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--ast-transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
}

.ast-chip-btn:hover {
  background: var(--ast-gold-light);
  border-color: var(--ast-gold);
  color: var(--ast-primary);
  transform: translateY(-1px);
}

.ast-chip-btn.ast-chip-primary {
  background: var(--ast-gold);
  color: #ffffff;
  border-color: var(--ast-gold);
}

.ast-chip-btn.ast-chip-primary:hover {
  background: var(--ast-gold-hover);
}

.ast-chip-btn.ast-chip-whatsapp {
  background: #25d366;
  color: #ffffff;
  border-color: #25d366;
}

.ast-chip-btn.ast-chip-whatsapp:hover {
  background: #1eb857;
}

/* --- Devis Express Interactive Card / Mini-Form --- */
.ast-devis-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 14px;
  border: 1px solid rgba(197, 157, 95, 0.3);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
  margin-top: 8px;
  width: 100%;
}

.ast-devis-header {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ast-primary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 6px;
}

.ast-devis-step-label {
  font-size: 0.74rem;
  color: var(--ast-gold);
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 6px;
  display: block;
}

.ast-form-group {
  margin-bottom: 10px;
}

.ast-form-group label {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 4px;
}

.ast-form-input, .ast-form-select {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.8rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  outline: none;
  transition: var(--ast-transition);
  background: #fafafa;
}

.ast-form-input:focus, .ast-form-select:focus {
  border-color: var(--ast-gold);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(197, 157, 95, 0.2);
}

.ast-submit-devis-btn {
  width: 100%;
  background: var(--ast-gold);
  color: #ffffff;
  border: none;
  padding: 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--ast-transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.ast-submit-devis-btn:hover {
  background: var(--ast-gold-hover);
  box-shadow: 0 4px 12px rgba(197, 157, 95, 0.4);
}

/* --- Devis Express Iframe Container --- */
.ast-iframe-card {
  width: 100%;
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(197, 157, 95, 0.3);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
  margin-top: 8px;
}

.ast-iframe-card iframe {
  width: 100%;
  height: 540px;
  border: 0;
  display: block;
  border-radius: 12px;
}

/* --- Card Highlight Box --- */
.ast-highlight-box {
  background: var(--ast-gold-light);
  border-left: 3px solid var(--ast-gold);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  margin: 6px 0;
  color: var(--ast-primary);
}


.ast-highlight-box strong {
  color: #92400e;
}

/* --------------------------------------------------------------------------
   4. Footer & Input Form Bar
   -------------------------------------------------------------------------- */
.ast-footer {
  padding: 12px 14px;
  background: #ffffff;
  border-top: 1px solid var(--ast-border-color);
}

.ast-input-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 25px;
  padding: 4px 6px 4px 14px;
  transition: var(--ast-transition);
}

.ast-input-form:focus-within {
  border-color: var(--ast-gold);
  box-shadow: 0 0 0 3px rgba(197, 157, 95, 0.15);
  background: #ffffff;
}

.ast-input-field {
  flex-grow: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.84rem;
  color: var(--ast-text-dark);
}

.ast-input-field::placeholder {
  color: #94a3b8;
}

.ast-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ast-gold);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--ast-transition);
  flex-shrink: 0;
}

.ast-send-btn:hover {
  background: var(--ast-gold-hover);
  transform: scale(1.05);
}

.ast-send-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  transform: none;
}

.ast-footer-credits {
  font-size: 0.66rem;
  color: var(--ast-text-muted);
  text-align: center;
  margin-top: 6px;
}

/* --------------------------------------------------------------------------
   5. Keyframe Animations & Utilities
   -------------------------------------------------------------------------- */
@keyframes astFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

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

/* --------------------------------------------------------------------------
   6. Responsive Layouts (Mobile Full-Screen Sheet)
   -------------------------------------------------------------------------- */
@media (max-width: 576px) {
  .ast-trigger-wrapper {
    bottom: 16px;
    right: 16px;
  }
  
  .ast-teaser-popover {
    right: 16px;
    bottom: 84px;
    width: calc(100vw - 32px);
  }

  .ast-window {
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }

  .ast-header {
    padding: 12px 14px;
    border-radius: 0;
  }

  .ast-msg-row {
    max-width: 90%;
  }
}

/* --------------------------------------------------------------------------
   7. RTL Support (Arabic Language)
   -------------------------------------------------------------------------- */
#pure-assistant-root[dir="rtl"],
#pure-assistant-root.ast-rtl {
  direction: rtl;
  text-align: right;
}

#pure-assistant-root[dir="rtl"] .ast-window,
#pure-assistant-root.ast-rtl .ast-window {
  right: auto;
  left: 24px;
}

#pure-assistant-root[dir="rtl"] .ast-trigger-wrapper,
#pure-assistant-root.ast-rtl .ast-trigger-wrapper {
  right: auto;
  left: 24px;
}

#pure-assistant-root[dir="rtl"] .ast-teaser-popover,
#pure-assistant-root.ast-rtl .ast-teaser-popover {
  right: auto;
  left: 24px;
}

#pure-assistant-root[dir="rtl"] .ast-teaser-close,
#pure-assistant-root.ast-rtl .ast-teaser-close {
  left: 10px;
  right: auto;
}

#pure-assistant-root[dir="rtl"] .ast-bot .ast-msg-bubble,
#pure-assistant-root.ast-rtl .ast-bot .ast-msg-bubble {
  border-left: none;
  border-right: 3px solid var(--ast-gold);
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 4px;
}

#pure-assistant-root[dir="rtl"] .ast-user .ast-msg-bubble,
#pure-assistant-root.ast-rtl .ast-user .ast-msg-bubble {
  border-bottom-right-radius: 16px;
  border-bottom-left-radius: 4px;
}

#pure-assistant-root[dir="rtl"] .ast-send-btn svg,
#pure-assistant-root.ast-rtl .ast-send-btn svg {
  transform: scaleX(-1);
}

@media (max-width: 576px) {
  #pure-assistant-root[dir="rtl"] .ast-trigger-wrapper,
  #pure-assistant-root.ast-rtl .ast-trigger-wrapper {
    left: 16px;
  }
  #pure-assistant-root[dir="rtl"] .ast-window,
  #pure-assistant-root.ast-rtl .ast-window {
    left: 0;
    right: 0;
  }
}

