/* ==========================================================================
   Shopify AI Chatbot — Widget styles
   Glassmorphism • dark mode • smooth animations • fully responsive
   All classes are prefixed .sac- to avoid clashing with the Shopify theme.
   ========================================================================== */

:root {
  --sac-primary: #6c5ce7;
  --sac-primary-2: #8e7bff;
  --sac-accent: #00d2ff;
  --sac-bg: rgba(255, 255, 255, 0.72);
  --sac-bg-solid: #ffffff;
  --sac-text: #1f2333;
  --sac-muted: #6b7280;
  --sac-bot-bubble: rgba(108, 92, 231, 0.10);
  --sac-user-bubble: linear-gradient(135deg, var(--sac-primary), var(--sac-primary-2));
  --sac-border: rgba(255, 255, 255, 0.5);
  --sac-shadow: 0 20px 50px rgba(31, 35, 51, 0.25);
  --sac-radius: 20px;
}

.sac-dark {
  --sac-bg: rgba(24, 26, 38, 0.78);
  --sac-bg-solid: #1c1f2e;
  --sac-text: #eef0f7;
  --sac-muted: #9aa2b1;
  --sac-bot-bubble: rgba(255, 255, 255, 0.08);
  --sac-border: rgba(255, 255, 255, 0.12);
  --sac-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

/* ---- Reset within widget ---- */
.sac-root, .sac-root * { box-sizing: border-box; }
.sac-root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 2147483000;
}

/* ---- Floating launcher button ---- */
.sac-launcher {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--sac-primary), var(--sac-accent));
  box-shadow: 0 10px 30px rgba(108, 92, 231, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  animation: sac-float 3.5s ease-in-out infinite;
}
.sac-launcher:hover { transform: scale(1.08); }
.sac-launcher svg { width: 30px; height: 30px; fill: #fff; }
.sac-launcher .sac-badge {
  position: absolute; top: -3px; right: -3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #ff5c7c; border: 2px solid #fff;
}

@keyframes sac-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ---- Chat window ---- */
.sac-window {
  position: absolute;
  bottom: 78px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: var(--sac-bg);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid var(--sac-border);
  border-radius: var(--sac-radius);
  box-shadow: var(--sac-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.28s ease;
}
.sac-window.sac-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ---- Header ---- */
.sac-header {
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--sac-primary), var(--sac-primary-2));
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
}
.sac-header .sac-avatar { width: 40px; height: 40px; }
.sac-header-info { flex: 1; min-width: 0; }
.sac-header-info h4 { margin: 0; font-size: 15px; font-weight: 600; }
.sac-header-info span { font-size: 12px; opacity: 0.85; display: flex; align-items: center; gap: 6px; }
.sac-dot { width: 8px; height: 8px; border-radius: 50%; background: #37e6a0; box-shadow: 0 0 0 rgba(55,230,160,0.6); animation: sac-pulse 1.8s infinite; }
@keyframes sac-pulse { 0% { box-shadow: 0 0 0 0 rgba(55,230,160,0.6);} 70%{box-shadow:0 0 0 8px rgba(55,230,160,0);} 100%{box-shadow:0 0 0 0 rgba(55,230,160,0);} }
.sac-header-actions { display: flex; gap: 4px; }
.sac-icon-btn { background: rgba(255,255,255,0.15); border: none; color: #fff; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.2s; }
.sac-icon-btn:hover { background: rgba(255,255,255,0.3); }
.sac-icon-btn svg { width: 16px; height: 16px; fill: #fff; }

/* ---- Avatars ---- */
.sac-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 15px; overflow: hidden;
}
.sac-avatar.sac-bot { background: linear-gradient(135deg, var(--sac-primary), var(--sac-accent)); }
.sac-avatar.sac-user { background: linear-gradient(135deg, #ff9a9e, #fad0c4); }
.sac-avatar svg { width: 18px; height: 18px; fill: #fff; }

/* ---- Messages area ---- */
.sac-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
.sac-messages::-webkit-scrollbar { width: 6px; }
.sac-messages::-webkit-scrollbar-thumb { background: var(--sac-muted); border-radius: 3px; opacity: 0.4; }

/* ---- Welcome screen ---- */
.sac-welcome { text-align: center; padding: 10px 6px 4px; }
.sac-welcome .sac-hi { font-size: 26px; margin: 6px 0 2px; }
.sac-welcome h3 { margin: 4px 0; color: var(--sac-text); font-size: 17px; }
.sac-welcome p { margin: 0 0 12px; color: var(--sac-muted); font-size: 13px; }
.sac-suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.sac-chip {
  background: var(--sac-bot-bubble);
  color: var(--sac-primary);
  border: 1px solid rgba(108, 92, 231, 0.25);
  padding: 8px 12px; border-radius: 14px;
  font-size: 12.5px; cursor: pointer;
  transition: transform 0.15s, background 0.2s;
}
.sac-dark .sac-chip { color: var(--sac-primary-2); }
.sac-chip:hover { transform: translateY(-2px); background: rgba(108, 92, 231, 0.18); }

/* ---- Message bubbles ---- */
.sac-msg { display: flex; gap: 9px; align-items: flex-end; animation: sac-in 0.3s ease; }
.sac-msg.sac-from-user { flex-direction: row-reverse; }
@keyframes sac-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.sac-bubble-wrap { max-width: 76%; display: flex; flex-direction: column; }
.sac-from-user .sac-bubble-wrap { align-items: flex-end; }
.sac-bubble {
  padding: 10px 13px; border-radius: 16px; font-size: 13.5px; line-height: 1.5;
  color: var(--sac-text); background: var(--sac-bot-bubble);
  border-bottom-left-radius: 5px; white-space: pre-wrap; word-wrap: break-word;
}
.sac-from-user .sac-bubble {
  background: var(--sac-user-bubble); color: #fff;
  border-bottom-left-radius: 16px; border-bottom-right-radius: 5px;
}
.sac-bubble a { color: var(--sac-accent); text-decoration: underline; }
.sac-from-user .sac-bubble a { color: #fff; }
.sac-time { font-size: 10.5px; color: var(--sac-muted); margin: 4px 4px 0; }

/* ---- Typing indicator ---- */
.sac-typing { display: flex; gap: 4px; padding: 12px 14px; }
.sac-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--sac-primary);
  opacity: 0.6; animation: sac-bounce 1.3s infinite;
}
.sac-typing span:nth-child(2) { animation-delay: 0.2s; }
.sac-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes sac-bounce { 0%,60%,100%{transform:translateY(0);} 30%{transform:translateY(-6px);} }

/* ---- Input area ---- */
.sac-input-area {
  padding: 12px; border-top: 1px solid var(--sac-border);
  display: flex; gap: 8px; align-items: center; background: var(--sac-bg);
}
.sac-input {
  flex: 1; border: 1px solid var(--sac-border); border-radius: 14px;
  padding: 11px 14px; font-size: 13.5px; resize: none; outline: none;
  background: var(--sac-bg-solid); color: var(--sac-text); max-height: 90px;
  font-family: inherit;
}
.sac-input:focus { border-color: var(--sac-primary); }
.sac-send {
  width: 42px; height: 42px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--sac-primary), var(--sac-accent));
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: transform 0.15s;
}
.sac-send:hover { transform: scale(1.08); }
.sac-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.sac-send svg { width: 18px; height: 18px; fill: #fff; }

.sac-footer { text-align: center; font-size: 10px; color: var(--sac-muted); padding: 4px 0 8px; }

/* ---- Responsive ---- */
@media (max-width: 480px) {
  .sac-root { bottom: 16px; right: 16px; }
  .sac-window { width: calc(100vw - 24px); height: calc(100vh - 100px); right: -4px; }
}

/* ---- Product gallery cards ---- */
.sac-products { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.sac-pcard {
  text-decoration: none; color: var(--sac-text); background: var(--sac-bg-solid);
  border: 1px solid var(--sac-border); border-radius: 14px; overflow: hidden;
  display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s;
}
.sac-pcard:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(31,35,51,.18); }
.sac-pcard-img {
  width: 100%; height: 110px; background-size: cover; background-position: center;
  background-color: #eef0f5; display: flex; align-items: center; justify-content: center; font-size: 30px;
}
.sac-pcard-noimg { color: var(--sac-muted); }
.sac-pcard-body { padding: 8px 10px; }
.sac-pcard-name {
  font-size: 12.5px; font-weight: 600; line-height: 1.3; margin-bottom: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.sac-pcard-price { font-size: 13px; font-weight: 700; color: var(--sac-primary); }
.sac-dark .sac-pcard-price { color: var(--sac-primary-2); }
.sac-pcard-oos { font-size: 10px; color: #ff6b6b; margin-top: 2px; }
