/* =========================================================
   SiteBridge Sidebar Widget
   Lives in: public/css/widget.css
   Does: All styles for the #sb-widget sidebar UI.
         Does NOT style the host page product cards — those
         are the host page's responsibility.
   ========================================================= */

/* ── Design tokens (mirrors host app) ── */
:root {
  --sb-bg:        #0D0D0D;
  --sb-surface:   #141414;
  --sb-surface2:  #1A1A1A;
  --sb-border:    #252525;
  --sb-text:      #F5F4F0;
  --sb-muted:     #7A7A7A;
  --sb-accent:    #CAFF00;
  --sb-accent-dim:rgba(202,255,0,0.08);
  --sb-radius:    10px;
  --sb-shadow:    0 8px 40px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.04);
  --sb-font:      'DM Sans', sans-serif;
  --sb-font-head: 'Syne', sans-serif;
}

/* ── Demo page overrides (not part of widget) ── */
.demo-nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(13,13,13,0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--sb-border);
  padding: 1rem 0;
}
.demo-nav .container { display: flex; align-items: center; gap: 1rem; }
.demo-logo {
  font-family: var(--sb-font-head);
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}
.demo-logo span { color: var(--sb-accent); }
.demo-tag {
  font-size: 0.75rem;
  color: var(--sb-muted);
  background: var(--sb-surface);
  border: 1px solid var(--sb-border);
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
}

.demo-main { padding: 3rem 0 6rem; }

.demo-header { margin-bottom: 2rem; }
.demo-header h1 { margin-bottom: 0.5rem; }

.demo-intro {
  background: var(--sb-accent-dim);
  border: 1px solid rgba(202,255,0,0.15);
  border-radius: var(--sb-radius);
  padding: 1.2rem 1.5rem;
  margin-bottom: 2.5rem;
  max-width: 680px;
}
.demo-intro-inner p { font-size: 0.9rem; color: var(--sb-med); margin-bottom: 0.8rem; }
.demo-example-row { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.demo-example { font-size: 0.8rem; color: var(--sb-muted); font-weight: 600; }
.demo-chip {
  background: var(--sb-surface);
  border: 1px solid var(--sb-border);
  color: var(--sb-text);
  font-size: 0.78rem;
  font-family: var(--sb-font);
  border-radius: 6px;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.demo-chip:hover {
  border-color: rgba(202,255,0,0.3);
  background: var(--sb-accent-dim);
}

/* Product cards — demo page styling */
.demo-catalog { display: flex; flex-direction: column; gap: 0.75rem; }

.product-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--sb-surface);
  border: 1px solid var(--sb-border);
  border-radius: var(--sb-radius);
  padding: 1rem 1.2rem;
  transition: border-color 0.25s, background 0.25s, opacity 0.25s, transform 0.25s;
}
.product-card:hover { border-color: rgba(202,255,0,0.15); }
.product-card.sb-highlight {
  border-color: var(--sb-accent);
  background: rgba(202,255,0,0.05);
  transform: translateX(4px);
  box-shadow: 0 0 0 1px var(--sb-accent), 0 4px 20px rgba(202,255,0,0.08);
}
.product-card.sb-dim { opacity: 0.3; }

/* Product visual block (demo graphic) */
.product-img {
  width: 52px; height: 52px;
  background: var(--sb-bg);
  border: 1px solid var(--sb-border);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--sb-muted);
  flex-shrink: 0;
}
.product-info { flex: 1; min-width: 0; }
.product-name { font-weight: 700; font-size: 0.9rem; margin-bottom: 0.2rem; font-family: var(--sb-font-head); }
.product-desc { font-size: 0.78rem; color: var(--sb-muted); margin-bottom: 0.4rem; }
.product-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.p-tag {
  font-size: 0.65rem;
  color: var(--sb-muted);
  background: var(--sb-bg);
  border: 1px solid var(--sb-border);
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
}
.product-right { text-align: right; flex-shrink: 0; }
.product-price { font-weight: 800; font-size: 1rem; font-family: var(--sb-font-head); }
.product-rating { font-size: 0.75rem; color: var(--sb-accent); margin-top: 0.2rem; }

/* =============================================
   SITE BRIDGE WIDGET (self-contained panel)
   ============================================= */

/* Floating toggle button */
#sb-widget {
  font-family: var(--sb-font);
  font-size: 14px;
  line-height: 1.4;
  color: var(--sb-text);
  box-sizing: border-box;
}
#sb-widget *, #sb-widget *::before, #sb-widget *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* The toggle FAB */
#sb-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--sb-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0D0D0D;
  box-shadow: 0 4px 20px rgba(202,255,0,0.35), 0 0 0 1px rgba(255,255,255,0.1);
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.2s;
  z-index: 9999;
}
#sb-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(202,255,0,0.45);
}
#sb-toggle svg { flex-shrink: 0; }

/* Slide-in panel */
#sb-panel {
  position: fixed;
  bottom: 88px;
  right: 24px;
  width: 320px;
  height: 460px;
  background: var(--sb-surface);
  border: 1px solid var(--sb-border);
  border-radius: 16px;
  box-shadow: var(--sb-shadow);
  display: none;          /* starts hidden */
  flex-direction: column;
  overflow: hidden;
  z-index: 9998;
  animation: sb-slidein 0.25s cubic-bezier(0.34,1.2,0.64,1);
}
@keyframes sb-slidein {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header bar */
.sb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: var(--sb-surface2);
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.sb-header-left { display: flex; align-items: center; gap: 0.5rem; }
.sb-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--sb-accent);
  box-shadow: 0 0 6px rgba(202,255,0,0.6);
}
.sb-title {
  font-family: var(--sb-font-head);
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: -0.01em;
}
.sb-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sb-muted);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.sb-close:hover { color: var(--sb-text); }

/* Scrollable body */
.sb-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.sb-body::-webkit-scrollbar { width: 4px; }
.sb-body::-webkit-scrollbar-track { background: transparent; }
.sb-body::-webkit-scrollbar-thumb { background: var(--sb-border); border-radius: 2px; }

/* Empty state */
.sb-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; text-align: center; padding: 1rem; }
.sb-empty-title { font-weight: 700; font-size: 0.85rem; margin-bottom: 0.4rem; color: var(--sb-text); }
.sb-empty-hint { font-size: 0.75rem; color: var(--sb-muted); line-height: 1.5; max-width: 22ch; }

/* Match list */
.sb-matches { display: flex; flex-direction: column; gap: 0.5rem; }
.sb-matches-header {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--sb-accent);
  background: var(--sb-accent-dim);
  border: 1px solid rgba(202,255,0,0.15);
  border-radius: 6px;
  padding: 0.35rem 0.7rem;
  margin-bottom: 0.2rem;
}
.sb-match-list { list-style: none; display: flex; flex-direction: column; gap: 0.4rem; }
.sb-match-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--sb-bg);
  border: 1px solid var(--sb-border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.sb-match-item:hover {
  border-color: rgba(202,255,0,0.25);
  background: var(--sb-accent-dim);
}
.sb-match-icon {
  width: 28px; height: 28px;
  background: var(--sb-surface);
  border: 1px solid var(--sb-border);
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  color: var(--sb-muted);
  flex-shrink: 0;
}
.sb-match-name { font-size: 0.78rem; font-weight: 600; line-height: 1.3; }
.sb-match-reason { font-size: 0.68rem; color: var(--sb-muted); margin-top: 0.15rem; line-height: 1.3; }
.sb-match-price { margin-left: auto; font-size: 0.78rem; font-weight: 700; color: var(--sb-accent); flex-shrink: 0; }
.sb-match-score {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--sb-muted);
  flex-shrink: 0;
  background: var(--sb-surface);
  border: 1px solid var(--sb-border);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

/* Loading spinner */
.sb-loading {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--sb-muted);
  font-size: 0.78rem;
  justify-content: center;
  padding: 1.5rem 0;
}
@keyframes sb-spin {
  to { transform: rotate(360deg); }
}
.sb-spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--sb-border);
  border-top-color: var(--sb-accent);
  border-radius: 50%;
  animation: sb-spin 0.7s linear infinite;
}

/* Error state */
.sb-error {
  background: rgba(255, 95, 87, 0.08);
  border: 1px solid rgba(255, 95, 87, 0.2);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  font-size: 0.78rem;
  color: #FF5F57;
}

/* Input footer */
.sb-footer {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem;
  border-top: 1px solid var(--sb-border);
  background: var(--sb-surface2);
  flex-shrink: 0;
}
.sb-input {
  flex: 1;
  background: var(--sb-bg);
  border: 1px solid var(--sb-border);
  border-radius: 8px;
  color: var(--sb-text);
  font-family: var(--sb-font);
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
  outline: none;
  transition: border-color 0.15s;
}
.sb-input::placeholder { color: var(--sb-muted); }
.sb-input:focus { border-color: rgba(202,255,0,0.35); }
.sb-send {
  width: 36px; height: 36px;
  background: var(--sb-accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #0D0D0D;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.sb-send:hover { opacity: 0.88; }
.sb-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Mobile ── */
@media (max-width: 480px) {
  #sb-panel { width: calc(100vw - 32px); right: 16px; }
  #sb-toggle { bottom: 20px; right: 20px; }
}
