/* ==========================================================================
   GravityStore - AI Live Customer Support Chat Widget Styles
   ========================================================================== */

/* ── Floating AI Launcher Trigger (Desktop & Mobile Minimal Icon) ── */
.ai-chat-launcher {
  position: fixed !important;
  bottom: 24px !important;
  right: 24px !important;
  z-index: 2147483646 !important;
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(203,213,225,.9);
  padding: 6px 11px 6px 7px;
  border-radius: 99px;
  box-shadow: 0 7px 18px -6px rgba(15,23,42,.24);
  cursor: pointer !important;
  pointer-events: auto !important;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  user-select: none;
}
.ai-chat-launcher:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px -7px rgba(79,70,229,.35);
  border-color: rgba(108, 99, 255, 0.4);
}
.ai-chat-launcher:focus-visible,
.ai-chat-widget button:focus-visible,
.ai-chat-widget a:focus-visible {
  outline: 3px solid rgba(79, 70, 229, 0.35);
  outline-offset: 2px;
}

.ai-chat-link { color:#2563eb; text-decoration:underline; font-weight:600; }
.ai-msg-row.assistant:has(.ai-deliv-card) { width:100%; max-width:100%; }
.ai-deliv-card { width:100%; box-sizing:border-box; background:linear-gradient(180deg,#fff 0%,#fafaff 100%); border:1px solid #c7d2fe; border-radius:14px; padding:15px; margin:10px 0; box-shadow:0 6px 18px rgba(79,70,229,.09); }
.ai-deliv-head { display:flex; align-items:center; justify-content:space-between; gap:8px; border-bottom:1px solid #eef2ff; padding-bottom:8px; margin-bottom:9px; font-size:10px; color:#64748b; }
.ai-deliv-head strong { color:#3730a3; letter-spacing:.06em; }
.ai-deliv-title { font-size:13px; font-weight:750; color:#1e3a8a; margin-bottom:8px; }
.ai-deliv-field { display:grid; grid-template-columns:90px minmax(0,1fr); gap:8px; align-items:start; margin:5px 0; font-size:11px; color:#64748b; }
.ai-deliv-field code { user-select:all; overflow-wrap:anywhere; background:#f8fafc; border:1px solid #e2e8f0; border-radius:5px; padding:4px 6px; color:#0f172a; font-size:11px; }
.ai-deliv-link { display:inline-block; margin-top:7px; color:#2563eb; font-size:12px; font-weight:650; }
.ai-deliv-instructions { margin-top:8px; padding:8px; border-radius:7px; background:#f8fafc; color:#475569; font-size:11px; white-space:pre-wrap; }
.ai-deliv-copy { width:100%; margin-top:12px; border:0; border-radius:10px; padding:11px 14px; background:linear-gradient(135deg,#635bff,#4338ca); color:#fff; font:700 12px inherit; cursor:pointer; display:flex; align-items:center; justify-content:center; gap:7px; box-shadow:0 5px 12px rgba(79,70,229,.25); transition:transform .15s,box-shadow .15s; }
.ai-deliv-copy:hover { transform:translateY(-1px); box-shadow:0 8px 16px rgba(79,70,229,.3); }
.ai-deliv-copy.copied { background:linear-gradient(135deg,#059669,#047857); }
.ai-chat-launcher-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6c63ff, #4f46e5);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 8px rgba(108, 99, 255, 0.28);
  position:relative;
}
.ai-chat-launcher-icon svg { width:15px; height:15px; }
.ai-chat-launcher-icon::after { content:""; position:absolute; right:-1px; bottom:-1px; width:7px; height:7px; border-radius:50%; background:#22c55e; border:2px solid #fff; }
.ai-chat-launcher-text {
  font-size: 11.5px;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
}

/* ── Stack WhatsApp / Telegram float buttons above AI Chat launcher ── */
.float-support-wrap {
  bottom: 84px !important;
  right: 24px !important;
  z-index: 9990 !important;
}

/* ── Chat Modal Popup Box ── */
.ai-chat-widget {
  position: fixed !important;
  bottom: 84px !important;
  right: 24px !important;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 110px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.06);
  z-index: 2147483647 !important;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.ai-chat-widget.open {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: translateY(0) scale(1) !important;
}

/* ── Header ── */
.ai-chat-header {
  padding: 14px 18px;
  background: #ffffff;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.ai-chat-header-user {
  display: flex;
  align-items: center;
  gap: 12px;
}
.ai-chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #e0e7ff;
  color: #4f46e5;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ai-chat-title-group {
  display: flex;
  flex-direction: column;
}
.ai-chat-name {
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.2px;
  line-height: 1.2;
}
.ai-chat-role-badge {
  font-size: 10px;
  font-weight: 800;
  color: #64748b;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-top: 2px;
}
.ai-chat-close-btn {
  background: none;
  border: none;
  color: #94a3b8;
  padding: 6px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  touch-action: manipulation;
}
.ai-chat-close-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

/* ── Body Message Container ── */
.ai-chat-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #fafafa;
  scroll-behavior: smooth;
}

/* ── Message Rows ── */
.ai-msg-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 88%;
}
.ai-msg-row.user {
  align-self: flex-end;
  align-items: flex-end;
}
.ai-msg-row.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

/* Bubbles */
.ai-msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}
.ai-msg-row.user .ai-msg-bubble {
  background: #2563eb;
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2);
  font-weight: 500;
}
.ai-msg-row.assistant .ai-msg-bubble {
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}

/* ── Typing Indicator Dots ── */
.ai-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 18px;
}
.ai-typing-dots span {
  width: 7px;
  height: 7px;
  background: #64748b;
  border-radius: 50%;
  animation: aiTypingBounce 1.4s infinite ease-in-out both;
}
.ai-typing-dots span:nth-child(1) { animation-delay: 0s; }
.ai-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aiTypingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── Ultra Minimal Product Cards inside Chat ── */
.ai-product-card {
  width: 100%;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  display: block;
}
.ai-product-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.ai-product-card-left {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}
.ai-product-thumb {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #f1f5f9;
  border: 1px solid #f1f5f9;
}
.ai-product-info-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}
.ai-product-card-head {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-product-card-tags {
  display: flex;
  gap: 4px;
  align-items: center;
}
.ai-card-tag {
  color: #64748b;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.ai-product-card-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.ai-card-price {
  font-size: 14px;
  font-weight: 800;
  color: #2563eb;
  white-space: nowrap;
}
.ai-card-buy-btn {
  background: #6c5ce7;
  color: #ffffff;
  border: none;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.ai-card-buy-btn:hover {
  background: #5b4bc4;
  transform: scale(1.03);
}
.ai-variation-panel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #eef2f7;
}
.ai-variation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
  color: #172033;
  font-size: 11px;
  font-weight: 800;
}
.ai-variation-head span:last-child {
  color: #64748b;
  font-size: 9px;
  white-space: nowrap;
}
.ai-variation-list {
  overflow: hidden;
  border: 1px solid #e8edf5;
  border-radius: 9px;
  background: #f8fafc;
}
.ai-variation-row {
  min-height: 32px;
  padding: 7px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #e8edf5;
  font-size: 10.5px;
}
.ai-variation-row:last-child { border-bottom: 0; }
.ai-variation-row strong {
  color: #4f46e5;
  font-size: 11px;
  white-space: nowrap;
}
.ai-variation-name {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #334155;
  line-height: 1.25;
}
.ai-variation-name i {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: #22c55e;
}
.ai-variation-name i.out-stock { background: #ef4444; }
.ai-variation-more {
  padding: 6px 2px 0;
  color: #64748b;
  font-size: 9.5px;
  text-align: center;
}
.ai-variation-view {
  width: 100%;
  min-height: 34px;
  margin-top: 8px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #5b4df5, #6d3ee8);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  cursor: pointer;
}
.ai-variation-view:hover { filter: brightness(1.05); }

/* ── Modern Order Cards inside Chat ── */
.ai-order-card {
  width: 100%;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ai-order-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ai-order-num {
  font-size: 13.5px;
  font-weight: 800;
  color: #0f172a;
}
.ai-order-status {
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: capitalize;
}
.ai-order-status.delivered,
.ai-order-status.completed {
  background: #dcfce7;
  color: #15803d;
}
.ai-order-status.pending,
.ai-order-status.processing,
.ai-order-status.awaiting_payment {
  background: #fef3c7;
  color: #b45309;
}
.ai-order-status.failed,
.ai-order-status.cancelled,
.ai-order-status.refunded {
  background: #fee2e2;
  color: #b91c1c;
}
.ai-order-card-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #64748b;
  padding-top: 6px;
  border-top: 1px solid #f1f5f9;
}
.ai-order-total {
  font-weight: 700;
  color: #0f172a;
}
.ai-order-view-btn {
  color: #4f46e5;
  font-weight: 700;
  text-decoration: none;
  font-size: 11.5px;
}
.ai-order-view-btn:hover {
  text-decoration: underline;
}

/* ── Quick Suggestion Chips / Pills ── */
.ai-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}
.ai-chip-btn {
  background: #ffffff;
  border: 1px solid #dbeafe;
  color: #1d4ed8;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.ai-chip-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  transform: translateY(-1px);
}

/* ── Live Agent Escalation Card ── */
.ai-live-agent-card {
  background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
  border: 1px solid #a7f3d0;
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ai-live-agent-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #065f46;
}
.ai-live-agent-btns {
  display: flex;
  gap: 8px;
}
.ai-live-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  color: #ffffff;
}
.ai-live-btn.wa { background: #25d366; }
.ai-live-btn.tg { background: #0088cc; }
.ai-live-btn:hover { opacity: 0.9; }

/* ── Typing Indicator Dots ── */
.ai-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: #f1f5f9;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}
.ai-typing-dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: aiTypingBounce 1.4s infinite ease-in-out both;
}
.ai-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes aiTypingBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* ── Footer / Input Field ── */
.ai-chat-footer {
  padding: 12px 16px;
  background: #ffffff;
  border-top: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.ai-chat-input-wrap {
  flex: 1;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  transition: border-color 0.15s;
}
.ai-chat-input {
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: #0f172a;
}
.ai-chat-input::placeholder {
  color: #94a3b8;
}
.ai-chat-send-btn {
  background: none;
  border: none;
  color: #6c63ff;
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s, transform 0.1s;
}
.ai-chat-send-btn:hover {
  background: #f1f5f9;
  transform: scale(1.08);
}

/* ── Dark Mode ── */
[data-theme="dark"] .ai-chat-launcher {
  background: #1e1e2d;
  border-color: #2d2d3f;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}
[data-theme="dark"] .ai-chat-launcher-text {
  color: #f1f5f9;
}
[data-theme="dark"] .ai-chat-widget {
  background: #12121e;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .ai-chat-header {
  background: #12121e;
  border-bottom-color: #1e1e2d;
}
[data-theme="dark"] .ai-chat-name {
  color: #f8fafc;
}
[data-theme="dark"] .ai-chat-body {
  background: #0b0b14;
}
[data-theme="dark"] .ai-msg-row.assistant .ai-msg-bubble {
  background: #1e1e2d;
  color: #e2e8f0;
}
[data-theme="dark"] .ai-product-card,
[data-theme="dark"] .ai-order-card {
  background: #181826;
  border-color: #27273a;
}
[data-theme="dark"] .ai-product-card-head,
[data-theme="dark"] .ai-order-num,
[data-theme="dark"] .ai-order-total {
  color: #f8fafc;
}
[data-theme="dark"] .ai-card-tag {
  color: #94a3b8;
}
[data-theme="dark"] .ai-variation-panel { border-top-color: #2b2b40; }
[data-theme="dark"] .ai-variation-head { color: #f8fafc; }
[data-theme="dark"] .ai-variation-list { background: #11111d; border-color: #2b2b40; }
[data-theme="dark"] .ai-variation-row { border-bottom-color: #2b2b40; }
[data-theme="dark"] .ai-variation-name { color: #cbd5e1; }
[data-theme="dark"] .ai-order-card-body {
  border-top-color: #252538;
}
[data-theme="dark"] .ai-chip-btn {
  background: #181826;
  border-color: #312e81;
  color: #a5b4fc;
}
[data-theme="dark"] .ai-chip-btn:hover {
  background: #1e1b4b;
}
[data-theme="dark"] .ai-chat-footer {
  background: #12121e;
  border-top-color: #1e1e2d;
}
[data-theme="dark"] .ai-chat-input-wrap {
  background: #181826;
  border-color: #27273a;
}
[data-theme="dark"] .ai-chat-input {
  color: #f8fafc;
}

/* ── Responsive Mobile Layout & Clearance Above Mobile Nav ── */
@media (max-width: 768px) {
  .ai-chat-launcher {
    bottom: 60px !important;
    right: 16px !important;
    padding: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(108, 99, 255, 0.4);
  }
  .ai-chat-launcher-text {
    display: none; /* Icon-only on mobile */
  }
  .ai-chat-launcher-icon {
    width: 40px;
    height: 40px;
    box-shadow: none;
  }
  .float-support-wrap {
    bottom: 116px !important;
    right: 16px !important;
    z-index: 9990 !important;
  }
  .ai-chat-widget {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    z-index: 2147483647 !important;
  }
  .ai-chat-close-btn {
    padding: 10px 14px;
    font-size: 22px;
    z-index: 10001;
    cursor: pointer;
    touch-action: manipulation;
  }
}
