/* Bear Lab Shop: on top of base.css (the tools portal's styles.css, same tokens).
   Palettes (themes.js) override these tokens on <html> while inside a shop. */

:root {
  --sale: var(--orange);      /* sale price and "-X%" badge */
  --sale-ink: #1A0D00;        /* text on --sale */
}
/* base.css draws spinners in white; on light palettes that only works on the accent. */
[data-mode="light"] .btn-secondary .spinner, [data-mode="light"] .btn-text .spinner {
  border-color: rgba(0, 0, 0, 0.18); border-top-color: var(--text);
}
[data-mode="light"] .modal::backdrop { background: rgba(20, 10, 15, 0.45); }

.logo-accent { color: var(--sale); }
.small { font-size: 13px; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.btn-sm { display: inline-flex; }
.btn-sm svg { flex-shrink: 0; }
.danger-text { color: var(--danger-text); }
.card.empty-hero, .card.form-card-wide, .card.danger-zone { max-width: none; }
.empty-hero { align-items: center; text-align: center; padding: 48px 32px; gap: 14px; }
.empty-hero p { color: var(--muted); max-width: 460px; line-height: 1.6; }
.empty-hero .btn { align-self: center; }
.empty-hero h1 { font-size: 28px; }
.hint.ok { color: var(--ok-text); }
.hint.bad { color: var(--danger-text); }
.alert-slot:empty { display: none; }
.spinner-overlay { display: none; }
.uploading > .spinner-overlay { display: grid; place-items: center; position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5); border-radius: inherit; z-index: 3; }

/* ---------- my shops */
.shop-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.shop-card { display: flex; flex-direction: column; height: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; color: var(--text); font-weight: 400; box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
a.shop-card:hover { border-color: var(--line-strong); color: var(--text); transform: translateY(-2px); }
.shop-card-cover { aspect-ratio: 3 / 1; background: var(--surface); position: relative; }
.shop-card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shop-card-body { display: flex; align-items: flex-start; gap: 12px; padding: 10px 18px 0; position: relative; }
.shop-card-body .shop-logo { margin-top: -42px; } /* only the logo overlaps the cover */
.shop-card-text { display: flex; flex-direction: column; min-width: 0; }
.shop-card-text h2 { font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.handle { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-card-foot { display: flex; justify-content: space-between; gap: 12px; padding: 14px 18px 18px; margin-top: auto; font-size: 13px; color: var(--muted); }
.shop-card.add { align-items: center; justify-content: center; gap: 10px; min-height: 220px; border: 1.5px dashed var(--line-strong); background: transparent; box-shadow: none; color: var(--muted); font-weight: 500; }
.shop-card.add:hover { color: var(--text); border-color: var(--muted); }

/* ---------- shop header (page + editable preview) */
.shop-logo { position: relative; flex-shrink: 0; border-radius: 50%; border: 4px solid var(--panel); background: var(--surface); overflow: visible; }
.shop-logo img, .shop-logo .logo-initials { width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; object-fit: cover; }
.logo-initials { color: #fff; font-family: var(--display); font-weight: 700; }
.shop-logo.sm { width: 64px; height: 64px; }
.shop-logo.sm .logo-initials { font-size: 22px; }
.shop-logo.lg { width: 128px; height: 128px; }
.shop-logo.lg .logo-initials { font-size: 44px; }

.shop-hero { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding-bottom: 24px; display: flex; flex-direction: column; gap: 14px; }
.shop-cover { position: relative; aspect-ratio: 3 / 1; border-radius: 14px 14px 0 0; background: var(--surface); overflow: hidden; }
.shop-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shop-identity { display: flex; align-items: flex-start; gap: 20px; padding: 14px 28px 0; position: relative; z-index: 1; }
.shop-identity .shop-logo.lg { margin-top: -78px; } /* only the logo overlaps the cover */
.shop-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex-grow: 1; }
.shop-title h1, .shop-title strong { font-family: var(--display); font-size: 34px; font-weight: 700; color: var(--text-strong); line-height: 1.15; overflow-wrap: anywhere; }
.shop-title .btn-text { align-self: flex-start; min-height: 32px; padding: 0; }
.shop-actions { flex-shrink: 0; padding-top: 4px; }
.shop-bio { padding: 0 28px; color: var(--label); line-height: 1.6; max-width: 760px; white-space: pre-line; }
.shop-contacts { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 28px; }
.contact-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--label); font-size: 13px; font-weight: 500; }
a.contact-chip:hover { color: var(--text); border-color: var(--line-strong); }
.shop-hero .hint-line { padding: 0 28px; }

/* editable preview */
.shop-hero.editable { padding-bottom: 20px; }
.cover-actions { position: absolute; right: 16px; bottom: 16px; display: flex; gap: 8px; z-index: 2; }
.btn-overlay { background: rgba(0, 0, 0, 0.62); color: #fff; border-color: rgba(255, 255, 255, 0.18); backdrop-filter: blur(4px); cursor: pointer; }
.btn-overlay:hover { background: rgba(0, 0, 0, 0.78); }
.btn-overlay.icon-only { padding: 0 12px; }
.btn-overlay:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.logo-edit { position: absolute; right: 2px; bottom: 2px; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; border: 3px solid var(--panel); cursor: pointer; z-index: 2; }
.logo-edit:hover { background: var(--accent-hover); }
.logo-edit:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- shop form */
.shop-form { display: flex; flex-direction: column; gap: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 24px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.textarea { height: auto; min-height: 88px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
.counter { align-self: flex-end; font-variant-numeric: tabular-nums; }
.prefix-input { position: relative; display: flex; }
.prefix-input > span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 16px; pointer-events: none; }
.prefix-input .input { padding-left: 32px; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; padding-top: 4px; }
.danger-zone { border-color: var(--danger-line); gap: 12px; }
.danger-zone .btn { align-self: flex-start; }
fieldset.field.plain { border: none; margin: 0; padding: 0; min-width: 0; }
fieldset.field.plain legend { font-size: 14px; font-weight: 500; color: var(--label); padding: 0; margin-bottom: 8px; }

/* ---------- catalog */
.catalog { display: flex; flex-direction: column; gap: 18px; }
.catalog-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.catalog-head h2 { font-size: 26px; }
.catalog-tools { display: flex; gap: 10px; flex-wrap: wrap; }
.search-input { position: relative; flex: 1 1 260px; display: flex; }
.search-input svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-input .input { width: 100%; padding-left: 38px; }
.catalog-tools select.input { flex: 0 0 auto; }
.category-chips { flex-wrap: wrap; }
.chip-count { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 2px; }
.chip[aria-pressed="true"] .chip-count { color: var(--tint-text); }

.product-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 20px; }
.product-card { width: 100%; height: 100%; display: flex; flex-direction: column; padding: 0; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; color: var(--text); cursor: pointer; transition: border-color .15s, transform .15s; }
.product-card:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.product-media { position: relative; aspect-ratio: 1; background: var(--surface); display: grid; place-items: center; overflow: hidden; }
.product-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.product-card.is-hidden .product-media img, .product-card.is-hidden .no-image { opacity: 0.45; }
.no-image { color: var(--placeholder); }
.badges { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: rgba(0, 0, 0, 0.7); color: #fff; }
.badge.sale { background: var(--sale); color: var(--sale-ink); }
.product-info { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px 14px; }
.product-name { font-weight: 600; color: var(--text-strong); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-price { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.product-price strong { font-size: 17px; color: var(--text-strong); }
.product-price strong.on-sale { color: var(--sale); }
.product-price s { font-size: 13px; color: var(--muted); }
.product-meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- product dialog */
.modal.modal-wide { width: min(880px, calc(100vw - 32px)); }
.product-form-grid { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 24px; align-items: start; }
.product-image-col { display: flex; flex-direction: column; gap: 12px; }
.product-fields { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.product-fields > .hint { font-size: 13px; color: var(--muted); margin-top: -8px; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.image-drop { position: relative; aspect-ratio: 1; border: 1.5px dashed var(--line-strong); border-radius: 12px; background: var(--field); overflow: hidden; }
.image-drop img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-drop.dragging { border-color: var(--accent); background: var(--tint); }
.image-drop-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 16px; text-align: center; color: var(--muted); cursor: pointer; }
.image-drop-empty strong { color: var(--text); }
.image-drop-empty span { font-size: 13px; }
.image-drop-empty:hover { color: var(--text); }
.image-drop-empty:focus-within { outline: 3px solid var(--accent); outline-offset: -3px; border-radius: 12px; }
.image-drop.has-image { border-style: solid; border-color: var(--line); }
.image-drop.has-image .image-drop-empty { opacity: 0; }
.image-drop.has-image.dragging .image-drop-empty { opacity: 1; background: rgba(0, 0, 0, 0.6); }
.image-actions { display: flex; gap: 8px; }
.image-actions .btn { flex: 1; cursor: pointer; }
.image-actions .btn:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.product-actions { justify-content: space-between; align-items: center; flex-wrap: wrap; }
.product-actions .modal-actions .btn { min-width: 120px; }
.btn.btn-text { width: auto; height: 44px; display: inline-flex; padding: 0 10px; }
.btn-text.danger-text { color: var(--danger-text); }
.btn-text.danger-text:hover { color: var(--danger); }

.switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--field); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { flex-shrink: 0; width: 40px; height: 24px; border-radius: 12px; background: var(--line-strong); position: relative; transition: background .15s; margin-top: 1px; }
.switch-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--good); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--accent); outline-offset: 2px; }
.switch strong { display: block; font-size: 14px; font-weight: 600; color: var(--text); }
.switch .hint { font-size: 13px; color: var(--muted); }

/* ---------- appearance (palette picker) */
.card-lead { margin-top: 6px; line-height: 1.6; max-width: 640px; }
.palette-grid { border: none; margin: 0; padding: 0; min-width: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.palette-option { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--field); cursor: pointer; transition: border-color .15s; }
.palette-option:hover { border-color: var(--line-strong); }
.palette-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.palette-option:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--tint); }
.palette-option:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.palette-swatch { display: flex; height: 56px; border-radius: 8px; overflow: hidden; border: 1px solid rgba(127, 127, 127, 0.25); }
.palette-swatch i { flex: 1; }
.palette-swatch i:first-child { flex: 1.6; }
.palette-text { display: flex; flex-direction: column; }
.palette-text strong { color: var(--text-strong); font-size: 15px; }
.palette-text span { font-size: 13px; color: var(--muted); }
.palette-check { position: absolute; top: 18px; right: 18px; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: none; place-items: center; box-shadow: 0 0 0 2px var(--panel); }
.palette-option:has(input:checked) .palette-check { display: grid; }
.theme-preview { display: flex; flex-direction: column; gap: 16px; }
.theme-preview > div { display: flex; flex-direction: column; gap: 20px; }
.preview-label { font-family: var(--body); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }

/* ---------- responsive */
@media (max-width: 960px) {
  .shop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .product-form-grid { grid-template-columns: minmax(0, 1fr); }
  .product-image-col { max-width: 320px; width: 100%; align-self: center; }
}
@media (max-width: 640px) {
  .shop-grid { grid-template-columns: minmax(0, 1fr); }
  .shop-cover { aspect-ratio: 2 / 1; }
  .shop-identity { flex-wrap: wrap; padding: 12px 18px 0; gap: 12px; }
  .shop-logo.lg { width: 96px; height: 96px; }
  .shop-identity .shop-logo.lg { margin-top: -60px; }
  .shop-logo.lg .logo-initials { font-size: 34px; }
  .shop-title { flex-basis: 100%; }
  .shop-title h1, .shop-title strong { font-size: 26px; }
  .shop-actions { padding-top: 0; }
  .shop-bio, .shop-contacts, .shop-hero .hint-line { padding: 0 18px; }
  .form-grid, .field-row { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .product-info { padding: 10px; }
  .product-price strong { font-size: 15px; }
  .cover-actions { right: 10px; bottom: 10px; }
  .cover-actions .btn span { display: none; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
  .modal-body { padding: 20px; }
}
