/* Commerce Brain — floating AI assistant (store home only) */
html {
  scrollbar-gutter: stable;
}

#sgCbFab {
  position: fixed;
  bottom: calc(1.35rem + env(safe-area-inset-bottom, 0px));
  right: max(1.35rem, env(safe-area-inset-right, 0px));
  z-index: 999999;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.85);
  background: #ffffff;
  color: #1d1d1f;
  font-size: 1.28rem;
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.04),
    0 8px 24px rgba(0, 0, 0, 0.12),
    0 0 32px rgba(192, 132, 151, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.22s cubic-bezier(0.34, 1.4, 0.64, 1), box-shadow 0.22s ease, opacity 0.2s ease;
  touch-action: manipulation;
}

#sgCbFab.sgcb-fab-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);
}

#sgCbFab i {
  background: linear-gradient(135deg, #c08497, #a86b7f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#sgCbFab:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.05),
    0 14px 36px rgba(0, 0, 0, 0.14),
    0 0 40px rgba(192, 132, 151, 0.32);
}

#sgCbFab:active {
  transform: scale(0.96);
}

#sgCbPanel {
  position: fixed;
  bottom: calc(1.35rem + env(safe-area-inset-bottom, 0px));
  right: max(1.25rem, env(safe-area-inset-right, 0px));
  z-index: 999998;
  width: 390px;
  max-width: calc(100% - 2.5rem);
  height: 520px;
  max-height: calc(100dvh - 2.75rem);
  border-radius: 24px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow:
    0 28px 72px rgba(31, 21, 32, 0.14),
    0 8px 28px rgba(192, 132, 151, 0.12);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', sans-serif;
  transform: none;
  touch-action: manipulation;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  contain: layout style paint;
}

#sgCbPanel.open { display: flex; }

#sgCbPanel.is-opening {
  animation: sgCbPanelIn 0.28s cubic-bezier(0.34, 1.2, 0.64, 1);
  transform-origin: bottom right;
}

@keyframes sgCbPanelIn {
  from { opacity: 0; transform: scale(0.97) translateY(4px); }
  to { opacity: 1; transform: none; }
}

.sgcb-head {
  padding: 0.95rem 1rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(250,250,252,0.95));
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  color: #1d1d1f;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-shrink: 0;
}

.sgcb-head strong { font-size: 0.92rem; font-weight: 650; letter-spacing: -0.01em; }
.sgcb-head-sub { font-size: 0.72rem; color: #86868b; font-weight: 500; display: block; margin-top: 2px; }

.sgcb-close {
  background: #f5f5f7;
  border: none;
  color: #6e6e73;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  touch-action: manipulation;
}

.sgcb-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: #f5f5f7;
  overscroll-behavior: contain;
}

.sgcb-msg {
  max-width: 88%;
  padding: 0.62rem 0.85rem;
  border-radius: 18px;
  font-size: 0.88rem;
  line-height: 1.48;
  word-break: break-word;
}

.sgcb-msg-bot {
  align-self: flex-start;
  background: #fff;
  color: #1d1d1f;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.sgcb-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #c08497, #a86b7f);
  color: #fff;
  box-shadow: 0 4px 14px rgba(192, 132, 151, 0.28);
}

.sgcb-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  color: #86868b;
}

.sgcb-typing-dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 2px;
  border-radius: 50%;
  background: #aeaeb2;
  animation: sgcbDot 1.2s infinite ease-in-out;
}
.sgcb-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.sgcb-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes sgcbDot {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-3px); opacity: 1; }
}

.sgcb-card {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 16px;
  overflow: hidden;
  flex: 0 0 min(82%, 260px);
  max-width: 260px;
  scroll-snap-align: start;
  align-self: flex-start;
  box-shadow: 0 4px 18px rgba(31, 21, 32, 0.07);
}

.sgcb-card-slider {
  align-self: stretch;
  max-width: 100%;
  margin: 0.15rem 0;
  overflow: hidden;
}

.sgcb-card-track {
  display: flex;
  gap: 0.65rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.15rem 0.1rem 0.35rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.sgcb-card-track::-webkit-scrollbar {
  height: 4px;
}
.sgcb-card-track::-webkit-scrollbar-thumb {
  background: rgba(192, 132, 151, 0.45);
  border-radius: 4px;
}

/* Commerce product cards inside the assistant (isolated from storefront .product-card) */
#sgCbPanel .sgcb-product-card {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(195, 108, 138, 0.12);
  min-width: 220px;
  max-width: 240px;
  flex: 0 0 220px;
  scroll-snap-align: start;
}

#sgCbPanel .sgcb-product-card .sgcb-img-wrap {
  aspect-ratio: 1;
  background: #faf5f7;
  overflow: hidden;
}

#sgCbPanel .sgcb-product-card .sgcb-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#sgCbPanel .sgcb-product-card .sgcb-card-body { padding: 0.75rem; display: block; }
#sgCbPanel .sgcb-product-card .sgcb-card-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: #1d1d1f;
  margin: 0 0 0.25rem;
  line-height: 1.3;
  display: block;
}
#sgCbPanel .sgcb-product-card .sgcb-card-price {
  font-weight: 700;
  color: #c08497;
  font-size: 0.9rem;
  margin: 0;
  display: block;
}
#sgCbPanel .sgcb-product-card .sgcb-card-old-price {
  color: #86868b;
  font-weight: 400;
  font-size: 0.78rem;
  text-decoration: line-through;
  margin-left: 0.35rem;
}
#sgCbPanel .sgcb-product-card .card-actions { margin-top: 0.5rem; }

.sgcb-card img { width: 100%; height: 120px; object-fit: cover; display: block; }
.sgcb-card-body { padding: 0.7rem 0.8rem 0.85rem; }
.sgcb-card-title { font-weight: 650; font-size: 0.88rem; margin: 0 0 0.2rem; color: #1d1d1f; letter-spacing: -0.01em; }
.sgcb-card-price { color: #c08497; font-weight: 700; font-size: 0.92rem; }
.sgcb-card-rating { font-size: 0.74rem; color: #86868b; margin: 0.15rem 0; }
.sgcb-card-actions { display: flex; gap: 0.35rem; margin-top: 0.55rem; flex-wrap: wrap; }

.sgcb-card-actions a,
.sgcb-card-actions button {
  font-size: 0.74rem;
  padding: 0.42rem 0.65rem;
  border-radius: 10px;
  text-decoration: none;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  color: #1d1d1f;
  cursor: pointer;
  font-weight: 600;
  touch-action: manipulation;
}

.sgcb-card-actions a.primary,
.sgcb-card-actions button.primary {
  background: linear-gradient(135deg, #c08497, #a86b7f);
  color: #fff;
  border-color: transparent;
}

.sgcb-form {
  display: flex;
  gap: 0.45rem;
  padding: 0.75rem;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  background: #ffffff;
  flex-shrink: 0;
}

.sgcb-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 14px;
  padding: 0.58rem 0.75rem;
  font-size: 16px;
  line-height: 1.3;
  background: #f5f5f7;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  transform: translateZ(0);
}

.sgcb-form button {
  border: none;
  background: linear-gradient(135deg, #c08497, #a86b7f);
  color: #fff;
  border-radius: 14px;
  padding: 0 1rem;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(192, 132, 151, 0.28);
  touch-action: manipulation;
  flex-shrink: 0;
}

.sgcb-card-ph { height: 128px; background: linear-gradient(135deg, #f5f5f7, #eee); }
.sgcb-meta { font-size: 0.74rem; color: #6e6e73; margin: 0.18rem 0; }
.sgcb-oos { display: inline-block; margin-left: 0.35rem; font-size: 0.72rem; color: #d97706; font-weight: 600; }
.sgcb-action-link {
  display: inline-block;
  align-self: flex-start;
  margin: 0.25rem 0;
  padding: 0.5rem 0.85rem;
  border-radius: 12px;
  background: linear-gradient(135deg, #c08497, #a86b7f);
  color: #fff !important;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
}

.sgcb-fullchat {
  font-size: 0.72rem;
  color: #c08497;
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

.sgcb-cart-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #faf5f7;
  border-bottom: 1px solid rgba(192, 132, 151, 0.15);
  font-size: 0.78rem;
  flex-shrink: 0;
}

.sgcb-cart-strip button {
  border: none;
  background: linear-gradient(135deg, #c08497, #a86b7f);
  color: #fff;
  border-radius: 10px;
  padding: 0.35rem 0.65rem;
  font-weight: 600;
  font-size: 0.74rem;
  cursor: pointer;
}

.sgcb-variant-select {
  width: 100%;
  margin: 0.35rem 0 0.5rem;
  padding: 0.45rem 0.55rem;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.1);
  font-size: 14px;
  background: #fff;
}

.sgcb-instock {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.72rem;
  color: #059669;
  font-weight: 600;
}

.sgcb-delivery { color: #6e6e73; }

.sgcb-order-card {
  align-self: flex-start;
  max-width: 94%;
  background: #fff;
  border: 1px solid rgba(192, 132, 151, 0.25);
  border-radius: 16px;
  padding: 0.85rem 1rem;
  box-shadow: 0 6px 24px rgba(192, 132, 151, 0.12);
}

.sgcb-order-title { font-weight: 700; margin: 0 0 0.25rem; color: #1d1d1f; }
.sgcb-order-num { font-size: 1.05rem; font-weight: 700; color: #c08497; margin: 0 0 0.35rem; }
.sgcb-order-total { font-weight: 650; margin: 0 0 0.25rem; }
.sgcb-order-status { font-size: 0.78rem; color: #6e6e73; margin: 0 0 0.5rem; }
.sgcb-order-items { margin: 0.35rem 0 0.65rem; padding-left: 1.1rem; font-size: 0.8rem; color: #444; }

.sgcb-receipt-btn, .sgcb-action-btn {
  display: inline-block;
  border: none;
  background: linear-gradient(135deg, #c08497, #a86b7f);
  color: #fff !important;
  border-radius: 12px;
  padding: 0.5rem 0.85rem;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: none;
}

.sgcb-choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.35rem 0 0.5rem;
  align-self: flex-start;
  max-width: 92%;
}

.sgcb-choice-btn {
  border: 1px solid rgba(192, 132, 151, 0.35);
  background: #fff;
  color: #7a3e4d;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.sgcb-choice-btn:hover {
  background: rgba(192, 132, 151, 0.1);
}

#sgCbPanel .sgcb-card-mode-intro {
  min-width: 260px;
  max-width: 280px;
  flex: 0 0 260px;
}

#sgCbPanel .sgcb-card-mode-intro .sgcb-img-wrap {
  aspect-ratio: 4/5;
}

#sgCbPanel .sgcb-card-mode-intro .sgcb-card-name {
  font-size: 1rem;
  font-weight: 700;
}

@media (max-width: 480px) {
  #sgCbPanel {
    right: max(0.75rem, env(safe-area-inset-right, 0px));
    width: auto;
    left: max(0.75rem, env(safe-area-inset-left, 0px));
    max-width: none;
    height: min(520px, calc(100dvh - 1.5rem));
    max-height: calc(100dvh - 1.5rem);
  }
}
