/* ==========================================================================
   BCO Product Card – Styles
   ========================================================================== */

.bco-card {
  --bco-text: #111827;
  --bco-muted: #6b7280;
  --bco-soft: #f9fafb;
  --bco-border: #e5e7eb;
  --bco-blue: #2563eb;
  --bco-blue-hover: #1d4ed8;
  --bco-green: #16a34a;
  --bco-orange: #f59e0b;
  --bco-red: #dc2626;
  --bco-shadow: 0 10px 22px -18px rgba(0, 0, 0, 0.28);

  font-family: inherit;
  color: var(--bco-text);
  background: #fff;
  border: 1px solid #eef0f3;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  will-change: box-shadow;
}

.bco-card:hover {
  border-color: #e6e8ee;
  box-shadow: var(--bco-shadow);
  transform: none;
}

/* ---------- Media ---------- */
.bco-card__media {
  position: relative;
  background: #ffffff;
  padding: 8px;
}

.bco-card__media-link {
  display: block;
  text-decoration: none;
  color: inherit;
  position: relative;
}

/* ---------- Gallery ---------- */
.bco-gallery {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  aspect-ratio: 1/1;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  cursor: grab;
  user-select: none;
  touch-action: pan-y pinch-zoom;
  border-radius: 12px;
  background: #ffffff;
}

.bco-gallery::-webkit-scrollbar {
  display: none;
}

.bco-gallery.is-dragging {
  cursor: grabbing;
}

.bco-gallery__slide {
  flex: 0 0 100%;
  scroll-snap-align: start;
  height: 100%;
  padding: 8px;
  background: #ffffff;
}

.bco-gallery__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #ffffff;
  pointer-events: none;
}

.bco-gallery.is-dragging .bco-gallery__img {
  pointer-events: none;
}

/* ---------- Segments ---------- */
.bco-segments {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  display: flex;
  gap: 4px;
  pointer-events: auto;
  z-index: 5;
}

.bco-segment {
  flex: 1 1 0;
  height: 4px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.16);
  opacity: 0.95;
  transition: background-color 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
}

.bco-segment.is-active {
  background: rgba(17, 24, 39, 0.72);
  transform: scaleY(1.2);
  opacity: 1;
}

/* ---------- Action buttons (wishlist / compare) ---------- */
.bco-card__actions {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bco-card__icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  color: #9ca3af;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease,
    opacity 0.15s ease;
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
  line-height: 1;
}

.bco-card__icon-btn:hover:not(.is-active) {
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  color: var(--bco-blue);
  transform: none;
}

.bco-card__icon-btn:focus,
.bco-card__icon-btn:focus-visible,
.bco-card__icon-btn:active {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  color: #9ca3af;
  outline: none;
}

.bco-card__icon-btn.is-active,
.bco-card__icon-btn.is-active:hover,
.bco-card__icon-btn.is-active:focus,
.bco-card__icon-btn.is-active:focus-visible,
.bco-card__icon-btn.is-active:active {
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  color: var(--bco-red);
}

.bco-card__icon {
  width: 18px;
  height: 18px;
  display: block;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bco-card__icon path {
  vector-effect: non-scaling-stroke;
}

/* ---------- Body ---------- */
.bco-card__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  flex: 1;
}

/* ---------- Status row ---------- */
.bco-status-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  width: max-content;
  background: transparent !important;
  padding: 0;
  border-radius: 0;
}

.bco-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  flex-shrink: 0;
}

.bco-status-row.in-stock {
  color: var(--bco-green);
}

.bco-status-row.pre-order {
  color: var(--bco-orange);
}

.bco-status-row.out-of-stock {
  color: var(--bco-red);
}

/* ---------- SKU ---------- */
.bco-sku {
  font-size: 12px;
  color: #9ca3af;
  line-height: 1.2;
  font-family: inherit;
}

/* ---------- Title ---------- */
.bco-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.28;
  font-weight: 700;
  letter-spacing: -0.02em;
  position: relative;
}

.bco-title a {
  text-decoration: none;
  color: inherit;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bco-title a:hover {
  color: #0f4c81;
}

/* ---------- Tooltip (rendered in <body>) ---------- */
.bco-title-tooltip {
  position: fixed;
  background: #e5e7eb;
  color: #222;
  font-size: 12px;
  line-height: 1.3;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: normal;
  max-width: 220px;
  word-break: break-word;
  z-index: 99990;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ---------- Excerpt ---------- */
.bco-excerpt {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: #333;
  max-height: calc(3 * 1.45em);
  overflow: hidden;
  position: relative;
}

.bco-excerpt::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 30%;
  height: 1.45em;
  background: linear-gradient(to right, rgba(255, 255, 255, 0), #fff 70%);
}

/* ---------- Footer ---------- */
.bco-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- Price ---------- */
.bco-price {
  font-size: 20px;
  line-height: 1.05;
  font-weight: 900;
  color: #111827;
}

.bco-price .woocommerce-Price-amount {
  font-size: inherit;
  font-weight: inherit;
}

.bco-price del {
  color: #9ca3af;
  font-weight: 500;
  font-size: 14px;
  margin-right: 6px;
}

/* ---------- Cart actions ---------- */
.bco-cart-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------- Buttons ---------- */
.bco-btn {
  width: 100%;
  height: 44px;
  min-height: 44px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #111827;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease,
    box-shadow 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}

.bco-btn--add:not(.is-in-cart) {
  color: var(--bco-blue);
  border-color: rgba(37, 99, 235, 0.5);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.11);
}

.bco-card:hover .bco-btn--add:not(.is-in-cart) {
  background: var(--bco-blue);
  border-color: var(--bco-blue);
  color: #fff;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.14);
}

.bco-btn:hover {
  background: var(--bco-blue);
  border-color: var(--bco-blue);
  color: #fff;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.14);
  transform: translateY(-1px);
}

.bco-btn:focus,
.bco-btn:focus-visible {
  background: #fff;
  color: inherit;
  outline: none;
}

.bco-btn.is-in-cart {
  background: var(--bco-green);
  border-color: var(--bco-green);
  color: #fff;
  box-shadow: none;
}

.bco-btn.is-in-cart:hover {
  background: var(--bco-green);
  border-color: var(--bco-green);
  color: #fff;
}

.bco-btn.is-loading {
  background: #f3f4f6 !important;
  border-color: #d1d5db !important;
  color: #9ca3af !important;
  box-shadow: none !important;
  transform: none !important;
}

.bco-btn__icon {
  width: 20px;
  height: 20px;
  display: block;
  flex-shrink: 0;
}

.bco-btn__spinner {
  width: 16px;
  height: 16px;
  display: inline-block;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: bco-spin 0.7s linear infinite;
}

@keyframes bco-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Quantity control ---------- */
.bco-qty-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #fff;
  min-width: 120px;
  height: 44px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}

.bco-qty-control.is-loading {
  pointer-events: none;
}

.bco-qty-control.is-loading .bco-qty-btn,
.bco-qty-control.is-loading .bco-qty-value {
  color: #9ca3af;
}

.bco-qty-btn {
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 18px;
  font-weight: 700;
  color: #374151;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, opacity 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

.bco-qty-btn:hover,
.bco-qty-btn:focus,
.bco-qty-btn:focus-visible,
.bco-qty-btn:active {
  background: transparent !important;
  box-shadow: none !important;
  outline: none;
}

.bco-qty-btn[data-qty-plus]:hover,
.bco-qty-btn[data-qty-plus]:active {
  color: var(--bco-green);
}

.bco-qty-btn[data-qty-minus]:hover,
.bco-qty-btn[data-qty-minus]:active {
  color: var(--bco-red);
}

.bco-qty-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.bco-qty-value {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
}

/* ---------- Toasts ---------- */
.bco-toast-root {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(92vw, 360px);
  pointer-events: none;
}

.bco-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

.bco-toast__icon {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  background: transparent;
  box-shadow: none;
  border: 0;
  transition: color 0.15s ease;
}

.bco-toast__icon svg {
  width: 24px;
  height: 24px;
  display: block;
}

.bco-toast--wishlist .bco-toast__icon {
  color: #41ad49;
}

.bco-toast--compare .bco-toast__icon {
  color: var(--bco-blue);
}

.bco-toast__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 38px;
}

.bco-toast--compare .bco-toast__body {
  cursor: pointer;
}

.bco-toast__title {
  font-size: 14px;
  line-height: 1.25;
  font-weight: 700;
  color: #111827;
  white-space: pre-line;
}

.bco-toast--wishlist .bco-toast__title a {
  text-decoration: none;
  color: inherit;
}

.bco-toast__subtitle {
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.35;
  color: #6b7280;
  white-space: pre-line;
}

.bco-toast__action {
  width: 26px;
  height: 26px;
  border: 0;
  background: transparent;
  color: #6b7280;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  align-self: flex-start;
  transition: color 0.15s;
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
  box-shadow: none;
}

.bco-toast__action:hover,
.bco-toast__action:focus,
.bco-toast__action:focus-visible {
  background: transparent;
  outline: none;
  color: #6b7280;
  transform: none;
  box-shadow: none;
}

.bco-toast__action svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* ---------- Mobile (≤768px) ---------- */
@media (max-width: 768px) {
  .bco-gallery {
    overflow-x: hidden;
    overflow-y: hidden;
    scroll-snap-type: none;
    touch-action: auto;
    cursor: default;
    user-select: auto;
  }

  .bco-gallery__slide {
    display: none;
  }

  .bco-gallery__slide:first-child {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  .bco-segments {
    display: none;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .bco-card,
  .bco-btn,
  .bco-card__icon-btn,
  .bco-segment,
  .bco-qty-btn,
  .bco-toast,
  .bco-toast__action {
    transition: none !important;
  }

  .bco-gallery {
    scroll-behavior: auto;
  }
}