/*
 * BRT Swatches — Standalone CSS
 * Identical to the bricks-theme plugin's Swatches.css.
 * Customise sizes and colours via CSS variables or override these rules.
 *
 * CSS variable quick-reference (add to your theme's :root block):
 *   --brt-swatch-size:             40px
 *   --brt-swatch-gap:              10px
 *   --brt-swatch-border-radius:    50%   (colors) / 7px (buttons)
 *   --brt-swatch-selected-color:   #000000
 *   --brt-swatch-disabled-color:   red
 */

/* ── Base ─────────────────────────────────────────────────────────────────── */

.brt-swatches-wrapper input[type="radio"] {
  display: none;
}

.brt-swatch-label {
  outline: 2px solid transparent;
  position: relative;
  cursor: pointer;
}

.brt-swatch-label.selected {
  outline-color: var(--brt-swatch-selected-color, #000000);
}

/* ── Tooltip ──────────────────────────────────────────────────────────────── */

.brt-swatch-label:hover .brt-swatch-tooltip-name {
  visibility: visible;
  opacity: 1;
}

.brt-swatch-tooltip-name {
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
  z-index: 10;
  pointer-events: none;
}

/* ── Hidden / disabled states ─────────────────────────────────────────────── */

.brt-swatch-hidden {
  display: none !important;
}

.brt-swatch-label.disable {
  position: relative;
  opacity: 0.3;
  pointer-events: none;
}

.brt-swatch-label.disable::before,
.brt-swatch-label.disable::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--brt-swatch-disabled-color, red);
  transform-origin: center;
}

.brt-swatch-label.disable::before {
  transform: rotate(45deg);
}

.brt-swatch-label.disable::after {
  transform: rotate(-45deg);
}

/* ── Color swatches ───────────────────────────────────────────────────────── */

.brt-swatches-color-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: var(--brt-swatch-gap, 10px);
}

.brt-swatches-color-wrapper .brt-swatch-color-box {
  width: var(--brt-swatch-size, 40px);
  height: var(--brt-swatch-size, 40px);
  border-radius: 50%;
}

/* ── Image swatches ───────────────────────────────────────────────────────── */

.brt-swatches-image-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: var(--brt-swatch-gap, 10px);
}

.brt-swatches-image-wrapper .brt-swatch-image-box {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: auto;
  height: auto;
  padding: 8px 12px;
  border: 2px solid transparent;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.2s;
}

.brt-swatches-image-wrapper .brt-swatch-image-box img {
  width: var(--brt-swatch-size, 48px);
  height: var(--brt-swatch-size, 48px);
  object-fit: contain;
  display: block;
}

.brt-swatches-image-wrapper .brt-swatch-image-box .brt-swatch-image-label {
  font-size: 0.75rem;
  text-align: center;
  line-height: 1.2;
}

.brt-swatches-image-wrapper .brt-swatch-image-box.selected {
  border-color: var(--brt-swatch-selected-color, #000000);
  outline: none;
}

.brt-swatches-image-wrapper .brt-swatch-image-box.disable {
  opacity: 0.35;
  pointer-events: none;
}

/* Override the base diagonal-cross disable style for image swatches
   since the box uses border instead of outline for selection state */
.brt-swatches-image-wrapper .brt-swatch-image-box.disable::before,
.brt-swatches-image-wrapper .brt-swatch-image-box.disable::after {
  display: none;
}

/* ── Button swatches ──────────────────────────────────────────────────────── */

.brt-swatches-button-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: var(--brt-swatch-gap, 10px);
}

.brt-swatches-button-wrapper .brt-swatch-button-box {
  min-width: 60px;
  height: 40px;
  padding: 0 12px;
  border-radius: 7px;
  border: 1px solid #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.brt-swatches-button-wrapper .brt-swatch-button-box.selected {
  background-color: var(--brt-swatch-selected-color, #000000);
  color: #ffffff;
  border-color: var(--brt-swatch-selected-color, #000000);
}

/* ── Select swatches ──────────────────────────────────────────────────────── */

/* 2-column grid: each attribute gets its own column (label on top, select below).
   Scoped to containers that have a select-type swatch so button/color layouts
   are not affected. Uses :has() — supported in all modern browsers. */
.brtheme-swatches:has(.brt-swatches-select-wrapper) {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  align-items: end;
}

/* The hidden data div, inline script and the reset link span full width */
.brtheme-swatches:has(.brt-swatches-select-wrapper) > .brt-swatches-data,
.brtheme-swatches:has(.brt-swatches-select-wrapper) > .swatches_reset_variations {
  grid-column: 1 / -1;
  display: none!important;
}

/* Label above the select */
.brt-swatches-container .brt-swatches-label {
    font-size: 12px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
    color: #999;
}

/* Select styling */
.brt-swatches-select-wrapper select {
  width: 100%;
  padding: 0 32px 0 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background-color: #fff;
  font-size: 15px;
  color: #999;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='currentColor' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.brt-swatches-select-wrapper select:focus {
  /*outline: 2px solid currentColor;
  outline-offset: 2px;*/
  border: 1px solid currentColor;
}

/* ── Reorganised product layout ──────────────────────────────────────────── */

/* Once reorganizeProductLayout() / reorganizeSimpleProductLayout() runs */
.brxe-brt-swatches-single.brt-layout-done,
.brt-simple-product-block.brt-layout-done {
  display: flex !important;
  flex-direction: row;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

/* Variation image — left column, fixed width. Change 120px to resize. */
.brt-variation-preview-img {
    display: block;
    flex-shrink: 0;
    width: 30%;
    height: 140px;
    aspect-ratio: 2 / 3;
    object-fit: contain;
    border-radius: var(--bt-radius);
    background-color: #fff;
    border: 1px solid #f0f0f0;
    padding: 10px;
}

/* Right column — price/avail full width on top, selects side-by-side below */
.brt-product-right-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  column-gap: 12px;
  row-gap: 8px;
  align-items: start;
  flex: 1;
  min-width: 0;
  height: 120px;
}

/* Price/availability shell and reset link span the full width */
.brt-product-right-col > .brt-variation-info-shell,
.brt-product-right-col > .swatches_reset_variations {
  grid-column: 1 / -1;
}

/* Hide the original p.stock inside the ATC form — it's shown in the block above */
.brt-simple-product-block ~ .brxe-product-add-to-cart p.stock {
  display: none !important;
}

/* Simple product right column — no selects, so drop the grid/fixed height */
.brt-product-right-col--simple {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  height: auto;
  min-height: 0;
}

/* ── Full-width stretch for swatches element and add-to-cart area ────────── */

/* The Bricks element and its parent flex/grid cell should fill the full row */
.brxe-brt-swatches-single {
  width: 100%;
  min-width: 100%;
  margin-bottom: 20px;
}

/* Quantity + add-to-cart wrapper */
.woocommerce-variation-add-to-cart,
form.cart .cart,
form.variations_form .cart {
  width: 100%;
  min-width: 100%;
}

/* ── Single variation — price + availability layout ──────────────────────── */

.woocommerce-variation.single_variation {
  display: flex;
  flex-direction: row;
  gap: 16px;
}

/* ── Bricks loop — hide native WC variation form ─────────────────────────── */

[data-query-element-id] .brxe-brt-swatches-loop .variations_form {
  display: none;
}

[data-query-element-id] .brt-swatches-simple-add-to-cart {
  display: none;
}

.swatches_reset_variations{display:none!important;}

.brt-product-right-col p.stock.in-stock {
    color: var(--bricks-text-success);
    display: flex;
    align-items: center;
    position: relative;
    padding-left: var(--bt-space-s);
}
.brt-product-right-col p.stock.out-of-stock {
    color: var(--bricks-text-danger);
    display: flex;
    align-items: center;
    position: relative;
    padding-left: var(--bt-space-s);
}

.brt-product-right-col p.stock:before {
    width: 0.625rem;
    height: 0.625rem;
    background: var(--bricks-text-danger);
    border-radius: 50%;
    content: "";
    position: absolute;
    left: 0;
}

.brt-product-right-col p.stock:after {
    position: absolute;
    left: 0;
    width: 0.625rem;
    height: 0.625rem;
    content: "";
    background: var(--bricks-text-danger);
    border-radius: 50%;
    animation: inventory-pulse 2s linear infinite;
}

.brt-product-right-col p.stock.in-stock:before, .brt-product-right-col p.stock.in-stock:after {
    background: var(--bricks-text-success);
}


.brt-product-right-col .woocommerce-variation-price bdi, .brt-product-right-col .woocommerce-variation-price .price {
  font-weight: 600;
  color: var(--my-color, var(--bt-brand-9));
  text-align: right;
  font-size: var(--bt-text-l);
  line-height: 1.3;
}

/* ── Sticky bottom add-to-cart bar ──────────────────────────────────────── */

.brt-sticky-atc {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 997;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px;
  background: #fff;
  box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.10);
  /* Slide-in / slide-out transition */
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.brt-sticky-atc.is-visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Variation image — fixed small thumbnail */
.brt-sticky-atc__img {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 4px;
  background: #fff;
  border: 1px solid #f0f0f0;
}

/* Product title — desktop only */
.brt-sticky-atc__title {
  flex-shrink: 1;  /* allow shrinking */
  min-width: 0;    /* lets flex item shrink below its content size */
  font-weight: 600;
  font-size: 22px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 767px) {
  .brt-sticky-atc__title {
    display: none;
  }
}

/* Price + availability */
.brt-sticky-atc__info {
    flex-shrink: 0;
    display: flex;
    flex-direction: row;
    gap: 20px;
    min-width: 20%;
    align-items: center;
}

.brt-sticky-atc__info .woocommerce-variation-price bdi, .brt-sticky-atc__info .woocommerce-variation-price .price {
  font-weight: 600;
  font-size: 22px;
  white-space: nowrap;
  color: var(--my-color, var(--bt-brand-9));
}

.brt-sticky-atc__info .woocommerce-variation-availability p {
  font-size: 0.75rem;
  margin: 0;
}

/* Selects area — flex row, takes all available space */
.brt-sticky-atc__selects {
  display: flex;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.brt-sticky-atc__selects .brt-swatches-container {
  flex: 1;
  min-width: 0;
}

/* Hide the label text to keep the bar compact */
.brt-sticky-atc__selects .brt-swatches-label {
  display: none;
}

/* Select inherits the same styling as the main block */
.brt-sticky-atc__selects select {
  width: 100%;
  height: 100%;
}

/* Button */
.brt-sticky-atc__actions {
  flex-shrink: 0;
  margin-left: auto;
}

.brt-sticky-atc__btn {
  white-space: nowrap;
}

.brt-sticky-atc p.stock.in-stock {
    color: var(--bricks-text-success);
    display: flex;
    align-items: center;
    position: relative;
    padding-left: var(--bt-space-s);
}

.brt-sticky-atc p.stock:before {
    width: 0.625rem;
    height: 0.625rem;
    background: var(--bricks-text-danger);
    border-radius: 50%;
    content: "";
    position: absolute;
    left: 0;
}

.brt-sticky-atc p.stock:after {
    position: absolute;
    left: 0;
    width: 0.625rem;
    height: 0.625rem;
    content: "";
    background: var(--bricks-text-danger);
    border-radius: 50%;
    animation: inventory-pulse 2s linear infinite;
}

.brt-sticky-atc p.stock.in-stock:before, .brt-sticky-atc p.stock.in-stock:after {
    background: var(--bricks-text-success);
}

.brt-sticky-atc .single_add_to_cart_button{
  padding-top: 12px!important;
  padding-bottom: 12px!important;
  border-radius: 4px!important;
  background-color: var(--my-color, var(--bt-brand-9))!important;
  border: 1px solid var(--my-color, var(--bt-brand-9))!important;
}
/* ── Single-option attribute — hide the no-choice dropdown ──────────────────── */
/* A product with only one option for an attribute (e.g. a single-variation
   product) offers no real choice; hide that dropdown so the card/quick view
   looks like a simple product. It's still pre-selected in the background so
   the price / image / add-to-cart resolve correctly. */
.brt-swatches-container--single {
  display: none;
}
