/* ShopChat Widget Styles */
:root {
  --shopchat-color:      #1a1a1a;
  --shopchat-accent:     #2563eb;
  --shopchat-accent-2:   #0f172a;
  --shopchat-radius:     12px;
  --shopchat-shadow:     0 4px 24px rgba(0,0,0,.14);
  --shopchat-font:       -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --shopchat-bubble-sz:  54px;
}

/* ── Widget container ───────────────────────── */
.shopchat-widget {
  position: fixed;
  bottom: 24px;
  z-index: 2147483647;
  font-family: var(--shopchat-font);
}
.shopchat-widget--right { right: 24px; }
.shopchat-widget--left  { left: 24px; }

/* ── Bubble ─────────────────────────────────── */
.shopchat-bubble {
  width:  var(--shopchat-bubble-sz);
  height: var(--shopchat-bubble-sz);
  padding: 15px;
  box-sizing: border-box;
  border-radius: 50%;
  background: var(--shopchat-color);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shopchat-shadow);
  transition: transform .2s ease, box-shadow .2s ease, background-color .2s ease, filter .2s ease;
  outline: none;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.shopchat-bubble--icon svg {
  width: 24px;
  height: 24px;
  display: block;
}
.shopchat-bubble--image {
  padding: 0;
  overflow: hidden;
  position: relative;
}
.shopchat-bubble--image .shopchat-bubble__image,
.shopchat-bubble--image .shopchat-bubble__close {
  width: 100%;
  height: 100%;
  display: block;
}
.shopchat-bubble--image .shopchat-bubble__image {
  object-fit: cover;
}
.shopchat-bubble--image .shopchat-bubble__close {
  position: absolute;
  inset: 0;
  width: 28px;
  height: 28px;
  margin: auto;
  color: #fff;
}
.shopchat-bubble--image.is-open .shopchat-bubble__image {
  display: none;
}
.shopchat-bubble:hover  {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 10px 28px rgba(0,0,0,.18);
  filter: brightness(1.02);
}
.shopchat-bubble:active { transform: translateY(0) scale(.97); }
.shopchat-bubble:focus-visible { box-shadow: 0 0 0 3px rgba(37, 99, 235, .22), 0 10px 28px rgba(0,0,0,.18); }
.shopchat-bubble--image:hover .shopchat-bubble__image {
  transform: scale(1.04);
}
.shopchat-bubble--image .shopchat-bubble__image {
  transition: transform .2s ease;
}

/* ── Panel ──────────────────────────────────── */
.shopchat-panel {
  position: absolute;
  bottom: calc(var(--shopchat-bubble-sz) + 12px);
  width:  400px;
  max-height: 680px;
  background: linear-gradient(180deg, #ffffff 0%, #fcfcfd 100%);
  border-radius: var(--shopchat-radius);
  box-shadow: var(--shopchat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(.97);
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.shopchat-widget--right .shopchat-panel { right: 0; }
.shopchat-widget--left  .shopchat-panel { left: 0; }

.shopchat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Panel header ───────────────────────────── */
.shopchat-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--shopchat-color);
  color: #fff;
  padding: 14px 16px;
  flex-shrink: 0;
}
.shopchat-panel__title  { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.shopchat-panel__close  {
  background: none; border: none; color: rgba(255,255,255,.72);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  border-radius: 999px;
  flex-shrink: 0;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.shopchat-panel__close:hover { color: #fff; background: rgba(255,255,255,.1); }
.shopchat-panel__close:hover svg {
  transform: scale(1.08);
}
.shopchat-panel__close svg {
  width: 20px;
  height: 20px;
  display: block;
  transition: transform .15s ease;
}

/* ── Messages area ──────────────────────────── */
.shopchat-messages {
  flex: 1;
  min-height: 260px;
  overflow-y: auto;
  padding: 16px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  background: #fff;
}
.shopchat-messages::-webkit-scrollbar { width: 4px; }
.shopchat-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

/* ── Message bubbles ────────────────────────── */
.shopchat-msg {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 85%;
}
.shopchat-msg--bot  { align-self: flex-start; }
.shopchat-msg--user { align-self: flex-end; flex-direction: row-reverse; }

.shopchat-msg__bubble {
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  word-break: break-word;
  white-space: pre-line;
}
.shopchat-msg--bot  .shopchat-msg__bubble { background: #f4f5f7; color: #1a1a1a; border-bottom-left-radius: 4px; }
.shopchat-msg--user .shopchat-msg__bubble { background: var(--shopchat-color); color: #fff; border-bottom-right-radius: 4px; }

/* ── Typing indicator ───────────────────────── */
.shopchat-typing {
  display: flex;
  gap: 4px;
  padding: 11px 14px;
  background: #f4f5f7;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  width: fit-content;
}
.shopchat-typing span {
  width: 7px; height: 7px;
  background: #999;
  border-radius: 50%;
  animation: shopchat-bounce .9s ease-in-out infinite;
}
.shopchat-typing span:nth-child(2) { animation-delay: .15s; }
.shopchat-typing span:nth-child(3) { animation-delay: .30s; }

@keyframes shopchat-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-5px); }
}

/* ── Add to Cart button ───────────────── */
.shopchat-add-cart-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 16px;
  background: var(--shopchat-accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease, opacity .15s ease;
  box-shadow: 0 6px 16px rgba(37, 99, 235, .18);
}
.shopchat-add-cart-btn:hover {
  opacity: .96;
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(37, 99, 235, .22);
}

/* ── Input area ─────────────────────────────── */
.shopchat-panel__input {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #eceff3;
  background: #fff;
  flex-shrink: 0;
}
.shopchat-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #d8dbe2;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  outline: none;
  font-family: var(--shopchat-font);
  background: #fff;
  resize: none;
  overflow-y: auto;
  transition: border-color .15s, box-shadow .15s;
}
.shopchat-input:focus {
  border-color: var(--shopchat-accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

/* ── Actions row (below textarea) ───────────── */
.shopchat-panel__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shopchat-send-btn {
  min-width: 86px;
  height: 42px;
  padding: 0 14px;
  margin-left: auto;
  background: var(--shopchat-color);
  color: #fff;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
  transition: transform .15s ease, opacity .15s ease, box-shadow .15s ease;
  box-shadow: 0 6px 16px rgba(17, 24, 39, .16);
  font-size: 13px;
  font-weight: 600;
}
.shopchat-send-btn:hover   {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 10px 28px rgba(17, 24, 39, .18);
  filter: brightness(1.02);
}
.shopchat-send-btn:active   { transform: translateY(0) scale(.97); }
.shopchat-send-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.shopchat-send-btn svg {
  flex-shrink: 0;
  transition: transform .15s ease;
}
.shopchat-send-btn:hover svg {
  transform: translateX(1px) scale(1.03);
}

/* ── Footer ─────────────────────────────────── */
.shopchat-panel__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px 12px;
  font-size: 11px;
  color: #8b8f98;
  background: #fff;
}
.shopchat-msg-count { color: #f0a500; }
.shopchat-powered { font-weight: 500; }

.shopchat-send-btn__label {
  display: inline-block;
}

/* ── Responsive ─────────────────────────────── */
@media (max-width: 400px) {
  .shopchat-panel { width: calc(100vw - 32px); max-height: 70vh; }
  .shopchat-widget--right { right: 16px; }
  .shopchat-widget--left  { left: 16px; }
  .shopchat-bubble--icon svg { width: 24px; height: 24px; }
  .shopchat-bubble--image img { width: 100%; height: 100%; }
  .shopchat-send-btn { min-width: 64px; padding: 0 12px; }
  .shopchat-send-btn__label { font-size: 12px; }
}

/* ── Voice button ───────────────────────────── */
.shopchat-voice-btn {
  width: 38px; height: 38px;
  padding: 0;
  background: #f4f5f7;
  border: 1px solid #d8dbe2;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #555;
  transition: background .15s, color .15s;
}
.shopchat-voice-btn:hover { background: #e8eaf0; }
.shopchat-voice-btn--active {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
  animation: shopchat-pulse 1.2s ease-in-out infinite;
}

@keyframes shopchat-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.3); }
  50%       { box-shadow: 0 0 0 6px rgba(220,38,38,0); }
}

/* ── Image button ───────────────────────────── */
.shopchat-image-btn {
  width: 38px; height: 38px;
  padding: 0;
  background: #f4f5f7;
  border: 1px solid #d8dbe2;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #555;
  transition: background .15s, color .15s;
}
.shopchat-image-btn:hover { background: #e8eaf0; }

/* ── Image badge ────────────────────────────── */
.shopchat-image-badge {
  font-size: 11px;
  color: #555;
  background: #f0f0f5;
  border-top: 1px solid #eceff3;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.shopchat-image-badge__remove {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: #888;
  padding: 0 2px;
  line-height: 1;
}
.shopchat-image-badge__remove:hover { color: #dc2626; }

/* ── Inventory badge ────────────────────────── */
.shopchat-inventory-badge {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 4px;
  padding: 2px 7px;
}

/* ── Support / handoff button ───────────────── */
.shopchat-support-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 7px 14px;
  background: #6366f1;
  color: #fff;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: opacity .15s;
}
.shopchat-support-btn:hover { opacity: .88; }

/* ── Product cards ──────────────────────────── */
.shopchat-product-cards {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: #ddd transparent;
}
.shopchat-product-cards::-webkit-scrollbar { height: 4px; }
.shopchat-product-cards::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

.shopchat-product-card {
  min-width: 140px;
  max-width: 140px;
  border: 1px solid #e8eaf0;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  transition: box-shadow .15s;
}
.shopchat-product-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); }

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

.shopchat-product-card__body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.shopchat-product-card__name {
  font-size: 11.5px;
  font-weight: 600;
  color: #1a1a1a;
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}
.shopchat-product-card__name:hover { color: var(--shopchat-accent); }

.shopchat-product-card__price {
  font-size: 12px;
  font-weight: 700;
  color: #111;
}

.shopchat-product-card__stock {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 3px;
  width: fit-content;
}
.shopchat-product-card__stock--in  { background: #dcfce7; color: #15803d; }
.shopchat-product-card__stock--out { background: #fee2e2; color: #b91c1c; }

.shopchat-product-card__cart-btn {
  display: block;
  text-align: center;
  margin-top: auto;
  padding: 5px 8px;
  background: var(--shopchat-accent);
  color: #fff;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  transition: opacity .15s;
}
.shopchat-product-card__cart-btn:hover { opacity: .88; }
