/* Market-X Checkout Widget Styles
 * Minimal styles for widget buttons injected into YCode pages.
 * Inherits Tailwind utility classes from the YCode page.
 */

.checkout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  font-weight: 600;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
  font-size: 0.875rem;
  line-height: 1.5;
}

.checkout-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.checkout-btn-primary {
  background-color: var(--shop-btn-bg, #000);
  color: var(--shop-btn-text, #fff);
  border-radius: var(--shop-btn-radius, 0.5rem);
}

.checkout-btn-primary:hover:not(:disabled) {
  filter: brightness(0.92);
}

.checkout-btn-secondary {
  background-color: #f5f5f5;
  color: #171717;
  border: 1px solid #d4d4d4;
}

.checkout-btn-secondary:hover:not(:disabled) {
  background-color: #e5e5e5;
}

.checkout-btn-link {
  background: none;
  color: #737373;
  padding: 0.5rem 1rem;
}

.checkout-btn-link:hover {
  color: #171717;
  text-decoration: underline;
}

/* Product grid.
 * The `--shop-*` custom properties are set by the store's theme
 * (App\Support\ShopWidgetTheme -> the scoped <style> in shop-widget.blade.php);
 * the fallbacks here are the built-in defaults so the widget still renders
 * correctly if the theme block is ever missing. The container itself
 * deliberately has no background — the YCode Shop element's own background
 * shows through. */
.shop-container,
.shop-widget-root {
  background: var(--shop-section-bg, transparent);
  font-family: var(--shop-font, inherit);
  /* Centre the grid within the YCode Shop element (which is full-width) so
     the cards sit in a bounded column with a modest gutter, rather than
     hugging the left edge or getting boxed into a narrow strip. The
     .container class the partial also carries only sets a max-width — it
     never centres. */
  max-width: var(--shop-max-width, min(100% - 2rem, 1280px));
  margin-inline: auto;
}

/* Card-width-driven grid: fit as many columns as the row allows while
   keeping every card at least --shop-card-min wide, cards stretching to
   fill. Naturally responsive (≈4 up on desktop → 1 on mobile) and immune to
   a mis-set --shop-columns squeezing cards into slivers. Raise --shop-card-min
   for a sparser grid, lower it for a denser one.
   auto-fill (not auto-fit): auto-fit collapses empty tracks, so with only
   1-2 products the lone card's 1fr track expands to the full row width —
   auto-fill keeps the remaining tracks (empty, zero-width content but
   still occupying their minmax share) so a short catalog's cards stay
   card-sized instead of stretching edge-to-edge. */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--shop-card-min, 280px)), 1fr));
  gap: var(--shop-grid-gap, 1.25rem);
  padding: 0.5rem 0;
}

.shop-card {
  border: var(--shop-card-border, 1px solid #f0f0f0);
  border-radius: var(--shop-card-radius, 1rem);
  overflow: hidden;
  background: var(--shop-card-bg, #fff);
  box-shadow: var(--shop-card-shadow, none);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.shop-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.08);
}

.shop-card-image {
  width: 100%;
  aspect-ratio: var(--shop-image-ratio, 1);
  object-fit: cover;
  border-radius: var(--shop-image-radius, 0);
  background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
  flex-shrink: 0;
  transition: transform 0.4s ease;
}
.shop-card:hover .shop-card-image {
  transform: scale(1.04);
}

.shop-card-body {
  padding: var(--shop-card-padding, 0.875rem);
  display: flex;
  flex-direction: column;
  flex: 1;
}

.shop-card-title {
  font-size: 0.938rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  line-height: 1.3;
  color: var(--shop-title-color, inherit);
}

.shop-card-body > p {
  font-size: 0.813rem;
  color: var(--shop-body-color, #737373);
  line-height: 1.4;
  flex: 1;
  margin-bottom: 0.75rem;
}

.shop-card-price {
  font-size: 1.063rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--shop-price-color, inherit);
}

.shop-card-variants {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 0.75rem;
}

.variant-chip {
  padding: 0.25rem 0.625rem;
  border: 1px solid #d4d4d4;
  border-radius: 9999px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.1s ease;
  background: #fafafa;
}

.variant-chip:hover,
.variant-chip.selected {
  border-color: #000;
  background: #f5f5f5;
  color: #000;
}

/* Push the add-to-cart button to the bottom */
.shop-card-body > .checkout-btn {
  margin-top: auto;
  width: 100%;
}

/* ── Product Detail Modal ── */
.shop-modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.shop-modal-panel {
  background: #fff; border-radius: 1rem;
  max-width: 800px; width: 100%; max-height: 90vh;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  box-shadow: 0 20px 60px rgba(0,0,0,0.12);
}
@media (max-width: 640px) {
  .shop-modal-panel { grid-template-columns: 1fr; }
}
.shop-modal-gallery {
  background: #f5f5f5;
  display: flex; flex-direction: column;
  border-radius: 1rem 0 0 1rem;
  overflow: hidden;
}
.shop-modal-main-image {
  width: 100%; aspect-ratio: 1;
  object-fit: cover; flex-shrink: 0;
}
.shop-modal-thumbnails {
  display: flex; gap: 0.5rem; padding: 0.75rem;
  overflow-x: auto;
}
.shop-modal-thumb {
  width: 3.5rem; height: 3.5rem;
  border-radius: 0.5rem; object-fit: cover;
  cursor: pointer; border: 2px solid transparent;
  flex-shrink: 0; opacity: 0.7; transition: all 0.1s;
}
.shop-modal-thumb:hover { opacity: 0.9; }
.shop-modal-thumb.active { border-color: #000; opacity: 1; }
.shop-modal-body {
  padding: 1.5rem; display: flex; flex-direction: column;
}
.shop-modal-close {
  position: absolute; top: 0.75rem; right: 0.75rem;
  width: 2rem; height: 2rem; border-radius: 9999px;
  background: #fff; border: none; cursor: pointer;
  font-size: 1.25rem; box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  display: flex; align-items: center; justify-content: center;
  z-index: 1;
}
.shop-modal-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 0.25rem; }
.shop-modal-desc { font-size: 0.875rem; color: #737373; line-height: 1.5; margin-bottom: 1rem; }
.shop-modal-price { font-size: 1.5rem; font-weight: 700; margin-bottom: 1rem; }
.shop-modal-variant-label { font-size: 0.813rem; font-weight: 600; color: #737373; margin-bottom: 0.5rem; }
.shop-modal-variants { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 1rem; }
.shop-modal-variant {
  padding: 0.625rem 0.75rem; border: 2px solid #e5e5e5;
  border-radius: 0.5rem; cursor: pointer; font-size: 0.813rem;
  font-weight: 500; transition: all 0.1s;
}
.shop-modal-variant.selected { border-color: #000; background: #fafafa; }
.shop-modal-variant-price { font-size: 0.75rem; color: #737373; }
.shop-modal-qty {
  display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem;
}
.shop-modal-qty-label { font-size: 0.813rem; font-weight: 600; color: #737373; }
.shop-modal-qty-btn {
  width: 2rem; height: 2rem; border: 1px solid #e5e5e5;
  border-radius: 0.5rem; background: #fff; cursor: pointer;
  font-size: 1rem; display: flex; align-items: center; justify-content: center;
}
.shop-modal-qty-btn:hover { background: #f5f5f5; }
.shop-modal-qty-value { width: 2rem; text-align: center; font-weight: 600; }
.shop-modal-add-btn {
  margin-top: auto; width: 100%;
}

/* Floating cart. Position is configurable (Shop element settings → Cart →
   Position); ShopWidgetTheme::toCssVars() resolves it to exactly one
   corner's inset pair, the other two vars defaulting to auto here so an
   old cached page/theme with no --shop-cart-* vars still anchors
   bottom-right, matching this rule's pre-configurable behavior. */
.shop-floating-cart {
  position: fixed;
  top: var(--shop-cart-top, auto);
  right: var(--shop-cart-right, 1.5rem);
  bottom: var(--shop-cart-bottom, 1.5rem);
  left: var(--shop-cart-left, auto);
  z-index: 40;
}
.shop-floating-cart-btn {
  width: 3.5rem; height: 3.5rem; border-radius: 9999px;
  background: #000; color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2); transition: transform 0.15s;
  position: relative;
}
.shop-floating-cart-btn:hover { transform: scale(1.05); }
.shop-floating-cart-badge {
  position: absolute; top: -0.25rem; right: -0.25rem;
  min-width: 1.5rem; height: 1.5rem; border-radius: 9999px;
  background: #ef4444; color: #fff; font-size: 0.688rem;
  font-weight: 700; display: flex; align-items: center;
  justify-content: center; padding: 0 0.25rem;
}

/* Confirmation summary */
.confirmation-summary {
  text-align: center;
  padding: 2rem;
  background: #fafafa;
  border-radius: 0.75rem;
}
