/**
 * AmourLuxe AI Stylist ✦ v3.0.0
 */

:root {
  --amai-black: #0a0a0a;
  --amai-black-2: #111111;
  --amai-black-3: #1a1a1a;
  --amai-gold: #c9a84c;
  --amai-gold-light: #e2c26a;
  --amai-gold-dark: #a07c30;
  --amai-gold-pale: #f5e6b8;
  --amai-ivory: #f8f4ed;
  --amai-gold-glow: rgba(201, 168, 76, 0.3);
  --amai-gold-border: rgba(201, 168, 76, 0.4);
  --amai-drawer-width: 480px;
  --amai-z: 999999;
  --amai-transition: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hide competing / legacy AI widgets — unified AI Stylist ✦ only */
.wa-chat-bubble:not(#amai-root *),
[class*="whatsapp-float"]:not(#amai-root *),
[class*="ai-concierge"]:not(#amai-root *),
[class*="luxury-concierge"]:not(#amai-root *),
[class*="float-ai"]:not(#amai-root *),
.amx-ai-luxury-concierge,
.amx-ai-luxury-concierge *,
.amx-concierge-v2,
.amx-concierge-v2 *,
.al-float-ai,
.al-float-ai *,
#al-float-ai,
.amx-ai-stylist-fab:not(#amai-launcher),
[id*="amourluxe-ai"]:not(#amai-root):not(#amai-launcher),
[id*="whatsapp-chat"]:not(#amai-root *),
[id*="wa-chat"]:not(#amai-root *),
.drift-widget-controller:not(#amai-root *),
[id^="crisp-chatbox"]:not(#amai-root *),
.intercom-launcher:not(#amai-root *),
.tidio-chat:not(#amai-root *) {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}

#amai-root {
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Launcher */
#amai-launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: calc(var(--amai-z) + 1);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px 14px 16px;
  background: linear-gradient(135deg, #1a1a1a 0%, #0d0d0d 100%);
  border: 1px solid var(--amai-gold-border);
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s, box-shadow 0.3s, border-color 0.3s;
  color: var(--amai-ivory);
}

#amai-launcher:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6), 0 0 24px var(--amai-gold-glow);
  border-color: var(--amai-gold);
}

.amai-launcher-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50px;
  border: 2px solid var(--amai-gold);
  opacity: 0;
  animation: amai-pulse-ring 3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes amai-pulse-ring {
  0%, 100% { opacity: 0; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.05); }
}

.amai-launcher-icon {
  display: flex;
  color: var(--amai-gold);
  animation: amai-spin-slow 8s linear infinite;
}

@keyframes amai-spin-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.amai-launcher-label {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.amai-launcher-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--amai-gold);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Backdrop */
#amai-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: calc(var(--amai-z) + 2);
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
}

#amai-root.amai-open #amai-backdrop {
  opacity: 1;
  pointer-events: all;
}

body.amai-body-lock {
  overflow: hidden !important;
}

/* Drawer */
#amai-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--amai-drawer-width);
  max-width: 94vw;
  z-index: calc(var(--amai-z) + 3);
  pointer-events: none;
}

#amai-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #111111 0%, #0a0a0a 100%);
  border-left: 1px solid var(--amai-gold-border);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(201, 168, 76, 0.2);
  transform: translateX(100%);
  transition: transform 0.5s var(--amai-transition);
}

#amai-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--amai-gold-dark) 20%,
    var(--amai-gold) 50%,
    var(--amai-gold-dark) 80%,
    transparent 100%
  );
  z-index: 2;
}

#amai-root.amai-open #amai-panel {
  transform: translateX(0);
}

#amai-root.amai-open #amai-drawer {
  pointer-events: all;
}

/* Header */
.amai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(201, 168, 76, 0.2);
  flex-shrink: 0;
}

.amai-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.amai-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 20%, rgba(201, 168, 76, 0.45), #0a0a0a);
  border: 2px solid var(--amai-gold);
  color: var(--amai-gold);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.amai-brand-title {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--amai-ivory);
  line-height: 1.2;
}

.amai-brand-sub {
  margin: 4px 0 0;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(201, 168, 76, 0.85);
  line-height: 1.35;
}

.amai-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.amai-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3dd68c;
  box-shadow: 0 0 8px rgba(61, 214, 140, 0.8);
}

.amai-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--amai-gold-border);
  background: rgba(0, 0, 0, 0.4);
  color: var(--amai-ivory);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

/* Body */
.amai-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.amai-welcome,
.amai-chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 18px;
}

.amai-hero-title {
  margin: 0 0 10px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--amai-ivory);
  line-height: 1.25;
}

.amai-hero-title em {
  display: block;
  font-style: italic;
  color: var(--amai-gold-light);
}

.amai-hero-sub {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.55;
  color: rgba(248, 244, 237, 0.72);
}

.amai-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.amai-action-btn {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  text-align: left;
  border-radius: 10px;
  border: 1px solid rgba(201, 168, 76, 0.25);
  background: rgba(255, 255, 255, 0.04);
  color: var(--amai-ivory);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.amai-action-btn:hover {
  border-color: var(--amai-gold);
  background: rgba(201, 168, 76, 0.12);
}

.amai-action-emoji {
  font-size: 1rem;
  flex-shrink: 0;
}

/* Messages */
.amai-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 8px;
}

.amai-msg {
  display: flex;
  gap: 10px;
  animation: amai-msg-in 0.35s both;
}

.amai-msg.amai-user {
  flex-direction: row-reverse;
}

@keyframes amai-msg-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.amai-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
  background: rgba(201, 168, 76, 0.15);
  border: 1px solid var(--amai-gold-border);
  color: var(--amai-gold);
}

.amai-msg-content {
  max-width: 85%;
  min-width: 0;
}

.amai-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  word-break: normal;
  overflow-wrap: break-word;
}

.amai-msg.amai-ai .amai-msg-bubble {
  background: linear-gradient(135deg, #1c1c1c, #181818);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.88);
  border-bottom-left-radius: 4px;
}

.amai-msg.amai-user .amai-msg-bubble {
  background: linear-gradient(135deg, #2a2218, #1f1a12);
  border: 1px solid var(--amai-gold-border);
  color: var(--amai-gold-pale);
  border-bottom-right-radius: 4px;
}

.amai-msg-time {
  margin-top: 4px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
}

.amai-msg.amai-user .amai-msg-time {
  text-align: right;
}

/* Typing */
.amai-typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.amai-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amai-gold);
  animation: amai-typing 1.4s ease-in-out infinite;
}

.amai-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.amai-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes amai-typing {
  0%, 100% { opacity: 0.2; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* Products */
.amai-product-strip {
  margin: 12px 0;
  padding-top: 8px;
  border-top: 1px solid rgba(201, 168, 76, 0.2);
}

.amai-products-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amai-gold);
  margin-bottom: 8px;
}

.amai-products-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.amai-product-card {
  flex: 0 0 140px;
  display: block;
  text-decoration: none;
  border-radius: 10px;
  border: 1px solid var(--amai-gold-border);
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
  color: inherit;
}

.amai-product-img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  display: block;
}

.amai-product-info {
  padding: 8px;
}

.amai-product-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--amai-ivory);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.amai-product-price {
  margin-top: 4px;
  font-size: 11px;
  color: var(--amai-gold-light);
}

/* Escalation */
.amai-escalation-bar {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.amai-esc-btn {
  flex: 1;
  text-align: center;
  padding: 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--amai-gold-border);
}

.amai-esc-btn--wa {
  background: #128c3d;
  color: #fff !important;
  border-color: #25d366;
}

.amai-esc-btn--email {
  background: rgba(201, 168, 76, 0.12);
  color: var(--amai-gold-pale) !important;
}

/* Footer */
.amai-footer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid rgba(201, 168, 76, 0.2);
  background: rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

.amai-back-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--amai-gold-border);
  background: transparent;
  color: var(--amai-gold);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.amai-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--amai-ivory);
  font-size: 15px;
  line-height: 1.45;
  font-family: inherit;
}

.amai-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.amai-send {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--amai-gold-light), var(--amai-gold-dark));
  color: #000;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.amai-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.amai-brand-bar {
  margin: 0;
  padding: 8px;
  text-align: center;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(201, 168, 76, 0.65);
  border-top: 1px solid rgba(201, 168, 76, 0.12);
  flex-shrink: 0;
}

/* RTL */
#amai-root.amai-rtl .amai-msg.amai-user {
  flex-direction: row;
}

#amai-root.amai-rtl .amai-msg.amai-ai {
  flex-direction: row-reverse;
}

@media (max-width: 768px) {
  #amai-drawer {
    width: 92vw;
    max-width: 460px;
  }
  #amai-launcher {
    bottom: 20px;
    right: 16px;
  }
}

@media (max-width: 480px) {
  #amai-drawer {
    width: 96vw;
  }
  #amai-panel {
    border-radius: 0;
    border-left: none;
  }
  #amai-launcher {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    right: 14px;
    padding: 12px 16px 12px 14px;
  }
  .amai-launcher-label {
    font-size: 0.95rem;
  }
  #amai-footer {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 360px) {
  .amai-actions-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .amai-launcher-ring,
  .amai-launcher-icon,
  .amai-avatar {
    animation: none !important;
  }
  #amai-panel,
  #amai-backdrop {
    transition-duration: 0.01ms !important;
  }
}

#amai-launcher:focus-visible,
.amai-action-btn:focus-visible,
#amai-send:focus-visible,
.amai-input:focus-visible {
  outline: 2px solid var(--amai-gold);
  outline-offset: 2px;
}

/* —— Phase 2: luxury UX —— */
.amai-mode-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 16px 0;
  border-bottom: 1px solid rgba(201, 168, 76, 0.15);
}
.amai-mode-tab {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px 10px 0 0;
  background: transparent;
  color: rgba(248, 244, 237, 0.65);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.35s var(--amai-transition);
}
.amai-mode-tab.is-active {
  color: var(--amai-gold-light);
  border-color: var(--amai-gold-border);
  background: linear-gradient(180deg, rgba(201, 168, 76, 0.12), transparent);
  box-shadow: 0 -2px 12px var(--amai-gold-glow);
}
.amai-onboarding {
  margin: 12px 16px;
  padding: 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(201, 168, 76, 0.18), rgba(10, 10, 10, 0.9));
  border: 1px solid var(--amai-gold-border);
  animation: amai-fade-in 0.6s ease;
}
.amai-onboarding[hidden] { display: none !important; }
.amai-onboarding-btn {
  margin-top: 10px;
  padding: 10px 16px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--amai-gold), var(--amai-gold-dark));
  color: #0a0a0a;
  font-weight: 700;
  cursor: pointer;
}
.amai-image-zone {
  margin: 0 16px 8px;
  padding: 12px;
  border: 1px dashed var(--amai-gold-border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
}
.amai-image-drop {
  display: block;
  text-align: center;
  cursor: pointer;
  color: var(--amai-gold-pale);
  font-size: 0.85rem;
}
.amai-tool-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--amai-gold-border);
  background: rgba(201, 168, 76, 0.08);
  color: var(--amai-gold-light);
  cursor: pointer;
  transition: transform 0.25s, box-shadow 0.25s;
}
.amai-tool-btn.is-active,
.amai-tool-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 16px var(--amai-gold-glow);
}
.amai-tool-btn:disabled { opacity: 0.4; cursor: not-allowed; }
#amai-panel.amai-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, rgba(201, 168, 76, 0.08), transparent 60%);
  pointer-events: none;
  animation: amai-pulse 2s ease infinite;
}
@keyframes amai-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes amai-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
.amai-launcher:hover .amai-launcher-ring {
  box-shadow: 0 0 28px var(--amai-gold-glow), 0 0 48px rgba(201, 168, 76, 0.15);
}
