/* Claude Shop Assistant - Chat Widget */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700&family=DM+Sans:wght@300;400;500&display=swap');

:root {
  --csa-primary: #1a1a2e;
  --csa-accent: #e94560;
  --csa-surface: #16213e;
  --csa-surface-2: #0f3460;
  --csa-text: #eaeaea;
  --csa-text-muted: #94a3b8;
  --csa-user-bubble: #e94560;
  --csa-bot-bubble: #1e293b;
  --csa-border: rgba(255,255,255,0.08);
  --csa-shadow: 0 25px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05);
  --csa-radius: 20px;
  --csa-radius-msg: 18px;
  --csa-font: 'DM Sans', system-ui, sans-serif;
  --csa-font-display: 'Syne', system-ui, sans-serif;
  --csa-transition: cubic-bezier(0.34, 1.56, 0.64, 1);
  --csa-z: 999999;
}

/* ── Launcher Button ── */
#csa-launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: var(--csa-z);
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--csa-accent), #c0392b);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(233,69,96,0.5), 0 0 0 0 rgba(233,69,96,0.4);
  transition: transform 0.3s var(--csa-transition), box-shadow 0.3s ease;
  animation: csa-pulse 3s ease-in-out infinite;
  outline: none;
}

#csa-launcher:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 40px rgba(233,69,96,0.6), 0 0 0 8px rgba(233,69,96,0.15);
  animation: none;
}

#csa-launcher.csa-open {
  animation: none;
  transform: rotate(45deg) scale(0.95);
  background: linear-gradient(135deg, #475569, #334155);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

#csa-launcher svg {
  width: 26px;
  height: 26px;
  fill: white;
  transition: opacity 0.2s ease;
}

#csa-launcher .csa-icon-chat { display: block; }
#csa-launcher .csa-icon-close { display: none; }
#csa-launcher.csa-open .csa-icon-chat { display: none; }
#csa-launcher.csa-open .csa-icon-close { display: block; }

/* Notification badge */
#csa-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 18px;
  height: 18px;
  background: #10b981;
  border-radius: 50%;
  border: 2px solid white;
  display: none;
}
#csa-badge.visible { display: block; }

@keyframes csa-pulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(233,69,96,0.5), 0 0 0 0 rgba(233,69,96,0.4); }
  50% { box-shadow: 0 8px 32px rgba(233,69,96,0.5), 0 0 0 14px rgba(233,69,96,0); }
}

/* Position variants */
#csa-launcher.pos-bottom-left,
#csa-chat-window.pos-bottom-left {
  right: auto;
  left: 28px;
}

/* ── Chat Window ── */
#csa-chat-window {
  position: fixed;
  bottom: 104px;
  right: 28px;
  z-index: var(--csa-z);
  width: 390px;
  max-height: 620px;
  min-height: 480px;
  display: flex;
  flex-direction: column;
  background: var(--csa-primary);
  border-radius: var(--csa-radius);
  box-shadow: var(--csa-shadow);
  border: 1px solid var(--csa-border);
  font-family: var(--csa-font);
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s var(--csa-transition);
  transform-origin: bottom right;
}

#csa-chat-window.csa-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ── */
#csa-header {
  background: linear-gradient(135deg, var(--csa-surface-2) 0%, var(--csa-surface) 100%);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--csa-border);
  position: relative;
  flex-shrink: 0;
}

#csa-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--csa-accent), transparent);
  opacity: 0.6;
}

.csa-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--csa-accent), #c0392b);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(233,69,96,0.4);
}

.csa-avatar svg {
  width: 22px;
  height: 22px;
  fill: white;
}

.csa-header-info {
  flex: 1;
}

.csa-title {
  font-family: var(--csa-font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--csa-text);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.csa-subtitle {
  font-size: 12px;
  color: #10b981;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.csa-subtitle::before {
  content: '';
  width: 7px;
  height: 7px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 6px #10b981;
  display: inline-block;
  animation: csa-blink 2s ease-in-out infinite;
}

@keyframes csa-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.csa-header-actions {
  display: flex;
  gap: 8px;
}

.csa-btn-icon {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--csa-text-muted);
  transition: background 0.2s, color 0.2s;
}

.csa-btn-icon:hover {
  background: rgba(255,255,255,0.15);
  color: var(--csa-text);
}

.csa-btn-icon svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* ── Email Gate ── */
#csa-email-gate {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 28px;
  gap: 20px;
  background: var(--csa-primary);
}

#csa-email-gate h3 {
  font-family: var(--csa-font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--csa-text);
  text-align: center;
  margin: 0;
}

#csa-email-gate p {
  font-size: 14px;
  color: var(--csa-text-muted);
  text-align: center;
  margin: 0;
  line-height: 1.5;
}

.csa-email-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.csa-email-form input {
  width: 100%;
  padding: 13px 16px;
  background: var(--csa-surface);
  border: 1px solid var(--csa-border);
  border-radius: 12px;
  color: var(--csa-text);
  font-family: var(--csa-font);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.csa-email-form input:focus {
  border-color: var(--csa-accent);
}

.csa-email-form input::placeholder { color: var(--csa-text-muted); }

/* ── Messages Area ── */
#csa-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

#csa-messages::-webkit-scrollbar { width: 4px; }
#csa-messages::-webkit-scrollbar-track { background: transparent; }
#csa-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* Messages */
.csa-msg {
  display: flex;
  gap: 10px;
  animation: csa-msg-in 0.3s var(--csa-transition) both;
  max-width: 100%;
}

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

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

.csa-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--csa-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
}

.csa-msg-avatar svg {
  width: 16px;
  height: 16px;
  fill: var(--csa-text-muted);
}

.csa-msg.user .csa-msg-avatar {
  background: linear-gradient(135deg, var(--csa-accent), #c0392b);
}

.csa-msg.user .csa-msg-avatar svg {
  fill: white;
}

.csa-msg-content {
  max-width: 78%;
}

.csa-bubble {
  padding: 11px 15px;
  border-radius: var(--csa-radius-msg);
  font-size: 14px;
  line-height: 1.55;
  color: var(--csa-text);
  word-wrap: break-word;
}

.csa-msg.bot .csa-bubble {
  background: var(--csa-bot-bubble);
  border: 1px solid var(--csa-border);
  border-bottom-left-radius: 5px;
}

.csa-msg.user .csa-bubble {
  background: var(--csa-user-bubble);
  border-bottom-right-radius: 5px;
  color: white;
}

.csa-bubble a {
  color: #60a5fa;
  text-decoration: underline;
}

.csa-bubble strong { font-weight: 600; }
.csa-bubble ul, .csa-bubble ol { margin: 8px 0 0 16px; padding: 0; }
.csa-bubble li { margin-bottom: 3px; }
.csa-bubble p { margin: 0 0 6px; }
.csa-bubble p:last-child { margin-bottom: 0; }

.csa-msg-time {
  font-size: 10px;
  color: var(--csa-text-muted);
  margin-top: 4px;
  padding: 0 2px;
}

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

/* Success banners */
.csa-success-banner {
  padding: 10px 14px;
  background: rgba(16,185,129,0.15);
  border: 1px solid rgba(16,185,129,0.3);
  border-radius: 12px;
  font-size: 13px;
  color: #34d399;
  margin-top: 4px;
  animation: csa-msg-in 0.3s var(--csa-transition) both;
}

/* Typing indicator */
#csa-typing {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  display: none;
}

#csa-typing.visible { display: flex; }

.csa-typing-dots {
  background: var(--csa-bot-bubble);
  border: 1px solid var(--csa-border);
  border-radius: var(--csa-radius-msg);
  border-bottom-left-radius: 5px;
  padding: 13px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.csa-dot {
  width: 7px;
  height: 7px;
  background: var(--csa-text-muted);
  border-radius: 50%;
  animation: csa-bounce 1.2s ease-in-out infinite;
}

.csa-dot:nth-child(2) { animation-delay: 0.15s; }
.csa-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes csa-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Quick replies */
#csa-quick-replies {
  padding: 0 16px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.csa-quick-reply {
  padding: 7px 14px;
  background: rgba(233,69,96,0.12);
  border: 1px solid rgba(233,69,96,0.3);
  border-radius: 20px;
  font-size: 13px;
  color: #f87171;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  font-family: var(--csa-font);
  white-space: nowrap;
}

.csa-quick-reply:hover {
  background: rgba(233,69,96,0.25);
  border-color: rgba(233,69,96,0.6);
  color: white;
}

/* ── Input Area ── */
#csa-input-area {
  padding: 14px 16px;
  border-top: 1px solid var(--csa-border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--csa-surface);
  flex-shrink: 0;
}

#csa-input {
  flex: 1;
  background: var(--csa-primary);
  border: 1px solid var(--csa-border);
  border-radius: 14px;
  padding: 11px 14px;
  color: var(--csa-text);
  font-family: var(--csa-font);
  font-size: 14px;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 44px;
  transition: border-color 0.2s;
  line-height: 1.4;
}

#csa-input:focus {
  border-color: var(--csa-accent);
}

#csa-input::placeholder { color: var(--csa-text-muted); }

#csa-send {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--csa-accent), #c0392b);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s var(--csa-transition), opacity 0.2s;
  box-shadow: 0 4px 12px rgba(233,69,96,0.4);
}

#csa-send:hover { transform: scale(1.08); }
#csa-send:active { transform: scale(0.95); }
#csa-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

#csa-send svg {
  width: 18px;
  height: 18px;
  fill: white;
}

/* Powered by */
.csa-powered {
  text-align: center;
  padding: 6px 0;
  font-size: 11px;
  color: rgba(255,255,255,0.2);
  flex-shrink: 0;
  background: var(--csa-surface);
}

/* ── Responsive ── */
@media (max-width: 480px) {
  #csa-chat-window {
    width: calc(100vw - 20px);
    right: 10px;
    bottom: 90px;
    max-height: calc(100vh - 120px);
    border-radius: 16px;
  }
  #csa-launcher {
    right: 16px;
    bottom: 16px;
  }
}
