/* Silne nadpisanie stylów Woo dla formularza wariantów w modalu */
.modal-3d__wrap .cart.variations_form {
  margin: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
  border: none !important;
  background: none !important;
}
/* Pasek grup nad tkaninami */
.fabric-groups-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
  padding: 6px;
  background: #f7f7f7;
  border: 1px solid #eee;
  border-radius: 8px;
}

.fabric-groups-bar .fgb {
  appearance: none;
  border: 1px solid #ddd;
  background: #fff;
  padding: 6px 10px;
  border-radius: 9999px;
  cursor: pointer;
  font-size: 12px;
  color: black;
}

.fabric-groups-bar .fgb.is-active {
  border-color: #111;
  font-weight: 600;
}

/**
 * NOWA REGUŁA: Ukrywa elementy filtrowane przez groups.js
 */
.wcboost-variation-swatches__item.is-hidden-by-group {
  display: none !important;
}


/* MARTWY KOD CSS (usunięty)
.fabric-group .proxy-swatch-list { ... }
.proxy-swatch { ... }
.proxy-swatch.is-selected { ... }
.proxy-swatch img { ... }
.proxy-swatch .label { ... }
*/

/* MARTWY KOD CSS (usunięty)
.wcboost-variation-swatches[data-proxy-hidden="1"] > .wcboost-variation-swatches__wrapper[data-attribute_name="attribute_pa_tkanina"] { ... }
*/


/* === Modal baza === */
.modal-3d {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .8);
  z-index: 9999;
}

.modal-3d__wrap {
  box-sizing: border-box;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin: 4vh auto;
  width: min(1200px, 96vw);
  max-height: 92vh;
  overflow: hidden;
  position: relative;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
}

.modal-3d__close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: transparent;
  border: 0;
  font-size: 28px;
  cursor: pointer;
  color: #222;
  z-index: 10;
}

#mv-product {
  width: 100%;
  height: 520px;
  min-height: 320px;
  background: #f2f2f2;
  border-radius: 10px;
}

/* Loader styles */
.mv-loader {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  justify-content: center;
  align-items: center;
  background: rgba(242, 242, 242, 0.7);
  border-radius: 10px;
  z-index: 5;
}

.mv-loader__spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-left-color: #000;
  border-radius: 50%;
  animation: mv-loader-spin 1s linear infinite;
}

@keyframes mv-loader-spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* prawa kolumna (materiały) */
.modal-3d__controls {
  margin-top: 0;
  height: 100%;
  overflow: auto;
  padding-right: 4px;
}

.mctrl {
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 0px;
  background: #fff;
}

.mctrl h4 {
  margin: 0 0 8px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .04em;
  position: sticky;
  top: 0;
  background: #fff;
  padding-top: 8px;
  padding-bottom: 6px;
  z-index: 1;
}

/* MARTWY KOD CSS (usunięty) - klony WCBoost mają własne style
.mctrl .sw-list{ ... }
.mctrl .sw{ ... }
.mctrl .sw.is-active{ ... }
*/


/* kontener galerii, do którego wsadzamy przycisk */
.has-3d-btn {
  position: relative;
}

/* sam przycisk w prawym dolnym rogu obrazów produktu */
#btn-3d-viewer.btn-3d {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 50;
  /* ponad overlayami thumbs/zoom */
  background: #111;
  color: #fff;
  border: 0;
  border-radius: 9999px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .18);
  opacity: 0.98;
}

/* Ensure controls column stacks panels and the QR block stays pinned to bottom */
@media (min-width:769px) {
  .modal-3d__controls {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 12px;
    height: 100%;
  }

  /* push QR panel to bottom */
  .modal-3d__controls .mctrl--qr {
    margin-top: auto;
  }

  /* make sure QR panel is visible on desktop even if accordions are collapsed */
  /* hide QR block content when collapsed (except header) */
  .modal-3d__controls .mctrl--qr.is-collapsed .qr-wrap {
    display: none !important;
  }

  .modal-3d__controls .qr-wrap img {
    max-width: 160px;
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 6px;
    background: #fff;
  }

  .modal-3d__controls .qr-text {
    font-size: 14px;
    color: #222;
  }
}

#btn-3d-viewer.btn-3d:hover {
  background: #333;
}

/* na wszelki wypadek, jeżeli galeria by ukrywała overflow */
.has-3d-btn {
  overflow: visible;
}

/* responsywna korekta na małych ekranach (żeby nie nachodził na miniatury) */
@media (max-width: 480px) {
  #btn-3d-viewer.btn-3d {
    right: 8px;
    bottom: 8px;
    padding: 8px 12px;
    font-size: 12px;
  }
}

/* === DESKTOP: 2 kolumny === */
@media (min-width:769px) {
  .modal-3d__wrap {
    width: min(1200px, 96vw);
    height: min(86vh, 960px);
    max-height: none;
    margin: 4vh auto;
    padding: 18px;
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
    grid-template-rows: 1fr;
    gap: 18px;
    overflow: hidden;
  }

  .modal-3d__left {
    position: relative;
  }

  /* lewa kolumna (model) */
  #mv-product {
    height: 100%;
    min-height: 520px;
  }

  /* Na desktop przenieśmy przycisk zamykania na lewą stronę wewnątrz modala,
     żeby nie nachodził na prawą kolumnę z materiałami. Zadbajmy też, żeby był
     idealnym kołem i wyżej w z-index niż sticky nagłówki. */
  .modal-3d__close {
    left: 18px;
    right: auto;
    top: 18px;
    width: 44px;
    height: 44px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    color: #111;
    border: 0;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
    z-index: 10003;
    font-size: 26px;
  }
}

/* === OKRĄGŁY PLAY/PAUSE w lewym obszarze === */
.mv-play {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #000;
  border: 0;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .25);
  padding: 0px;
}

.mv-play::before {
  /* trójkąt play */
  content: "";
  position: absolute;
  left: 17px;
  top: 13px;
  border-style: solid;
  border-width: 9px 0 9px 12px;
  border-color: transparent transparent transparent #fff;
}

.mv-play.is-playing::before {
  /* pauza = dwie belki */
  content: "";
  left: 14px;
  top: 12px;
  border: none;
  width: 14px;
  height: 20px;
  background:
    linear-gradient(#fff, #fff) left/4px 100% no-repeat,
    linear-gradient(#fff, #fff) right/4px 100% no-repeat;
}

/* === MOBILE: tylko model; materiały chowamy === */
@media (max-width:768px) {

  /* Nie full-screen edge-to-edge — modal ma być widoczny z zaokrąglonymi rogami */
  .modal-3d__wrap {
    width: calc(100vw - 32px);
    max-width: 960px;
    height: calc(100vh - 12vh);
    margin: auto;
    top: 0; bottom: 0; left: 0; right: 0;
    position: absolute;
    border-radius: 30px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
  }
/* Zmniejsz marginesy/padding dla .cart.variations_form tylko w modalu */
.modal-3d__wrap .cart.variations_form {
  margin: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
  border: none !important;
}

  /* Lewa kolumna (obszar modelu) zajmuje większość miejsca i jest wycentrowana */
  .modal-3d__left {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    padding: 6px;
  }

  /* #mv-product (model-viewer) wypełnia dostępne miejsce i ma zaokrąglone rogi wewnątrz modala */
  #mv-product {
    width: 100%;
    height: 100%;
    min-height: 0;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f2f2f2;
    overflow: hidden;
  }

  /* wewnętrzne canvas/model powinny skalować się proporcjonalnie i nie wystawać poza zaokrąglone rogi */
  #mv-product>* {
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: inherit;
    overflow: hidden;
  }

  .modal-3d__controls {
    display: none !important;
  }

  .modal-3d__close {
    position: absolute;
    top: 12px;
    left: 16px;
    right: auto;
    background: rgba(255, 255, 255, .95);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 26px;
    color: #111;
    z-index: 10002;
    border: 0;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
  }

  /* Przyciski: close po lewej, play po prawej (konsekwentnie na mobile i desktop) */
  .mv-play {
    top: 16px;
    right: 16px;
    left: auto;
    z-index: 10001;
  }
}

/* zwijanie całych paneli w modalu */
.mctrl.is-collapsed .wcboost-variation-swatches,
.mctrl.is-collapsed .sw-list {
  display: none !important;
}

.mctrl h4 {
  cursor: pointer;
  user-select: none;
}

.mctrl h4::after {
  content: "▾";
  float: right;
  transition: transform .2s ease;
}

.mctrl.is-collapsed h4::after {
  transform: rotate(-90deg);
}