/* ================================================================
   Product Configurator — Styles
   ================================================================
   Desktop layout  (> 900 px):
     2-column CSS grid, canvas left spanning both rows,
     heading top-right, options bottom-right.
     Logo is absolutely positioned over the canvas top-left.

   Mobile layout  (≤ 900 px):
     Flex column — heading → canvas → options (always visible)
   ================================================================ */

/* ----------------------------------------------------------------
   Reset / base
   ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ----------------------------------------------------------------
   Page wrapper
   ---------------------------------------------------------------- */
.conf-page {
  position: relative;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ----------------------------------------------------------------
   Logo  (absolute, floating over canvas top-left)
   ---------------------------------------------------------------- */
.conf-logo-link {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  background: #88cc00;
  border-radius: 50%;
  line-height: 0;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
  transition: opacity 0.15s;
}
.conf-logo-link:hover { opacity: 0.88; }
.conf-logo-link .icon {
  width: 32px;
  height: 32px;
  display: block;
}

/* ----------------------------------------------------------------
   Main layout  (2 × 2 grid on desktop)
   canvas  = left column, spans both rows
   heading = right column, top row
   sidebar = right column, bottom row
   ---------------------------------------------------------------- */
.conf-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 340px;
  grid-template-rows: auto 1fr;
}

/* ----------------------------------------------------------------
   Canvas  (left column, spans both rows)
   ---------------------------------------------------------------- */
#conf-canvas-wrapper {
  grid-column: 1;
  grid-row: 1 / span 2;
  position: relative;
  overflow: hidden;
  background: #f2f2f2;
}
#conf-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ----------------------------------------------------------------
   Heading area  (right column, top row)
   ---------------------------------------------------------------- */
.conf-heading-area {
  grid-column: 2;
  grid-row: 1;
  padding: 1.4rem 1.2rem 1rem;
  background: #fff;
  border-left: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
  overflow-y: auto;
}
.conf-heading-area h1 {
  font-size: 1.2rem;
  font-weight: 600;
  color: #336600;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}
.conf-heading-area p {
  font-size: 0.85rem;
  color: #555;
  line-height: 1.6;
  margin-bottom: 0.35rem;
}

/* ----------------------------------------------------------------
   Loading overlay (spinner)
   ---------------------------------------------------------------- */
#conf-loading {
  position: absolute;
  inset: 0;
  background: rgba(242,242,242,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
}
#conf-loading.active { opacity: 1; pointer-events: auto; }

.conf-spinner {
  width: 44px; height: 44px;
  border: 4px solid #ccc;
  border-top-color: #92c13e;
  border-radius: 50%;
  animation: conf-spin 0.7s linear infinite;
}
@keyframes conf-spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------------
   Hotspot buttons (positioned over canvas per-frame via JS)
   ---------------------------------------------------------------- */
#conf-hotspots { position: absolute; inset: 0; pointer-events: none; z-index: 10; }

.conf-hotspot {
  position: absolute;
  pointer-events: auto;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(146,193,62,0.85);
  border: 2px solid #fff;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transform: translate(-50%, -50%) scale(var(--hs-scale, 1));
  transition: transform 0.15s, background 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.conf-hotspot:hover { transform: translate(-50%, -50%) scale(calc(var(--hs-scale, 1) * 1.18)); }
.conf-hotspot.filled {
  background: rgba(51,102,0,0.9);
}

/* ----------------------------------------------------------------
   Option popup (floats inside canvas wrapper)
   ---------------------------------------------------------------- */
.conf-popup {
  position: fixed;
  z-index: 20;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 6px 28px rgba(0,0,0,0.22);
  min-width: 240px;
  max-width: 320px;
  overflow: hidden;
  animation: conf-pop-in 0.18s ease-out;
}
@keyframes conf-pop-in { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }

.conf-popup-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.9rem;
  background: #f8f8f8;
  border-bottom: 1px solid #e4e4e4;
  font-size: 0.9rem;
}
.conf-popup-close {
  background: none; border: none; font-size: 1.3rem; cursor: pointer;
  color: #888; line-height: 1;
}
.conf-popup-close:hover { color: #333; }

.conf-popup-list {
  list-style: none;
  max-height: 320px;
  overflow-y: auto;
}
.conf-pop-opt {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  transition: background 0.12s;
}
.conf-pop-opt:hover { background: #f4f9ec; }
.conf-pop-opt.selected { background: #eaf4d8; font-weight: 600; }
.conf-pop-opt.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.conf-pop-opt.disabled:hover { background: none; }
.conf-pop-constraint {
  display: block;
  font-size: 0.78em;
  color: #b55;
  font-style: italic;
  margin-top: 0.15em;
}

.conf-pop-swatch {
  width: 36px; height: 36px;
  border-radius: 6px;
  border: 1px solid #ddd;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.conf-pop-swatch.none-swatch {
  background: #eee;
  color: #aaa;
  font-size: 1.1rem;
}
.conf-pop-swatch.model-swatch {
  background: #f0f0f0;
  color: #999;
  font-size: 1.4rem;
}
.conf-pop-img {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  border: 1px solid #ddd;
  flex-shrink: 0;
  object-fit: cover;
  display: block;
}
.conf-pop-name {
  flex: 1;
  font-size: 0.88rem;
  color: #333;
}
.conf-pop-name em {
  font-style: italic;
  color: #999;
  font-weight: 400;
}
.conf-pop-price {
  font-size: 0.82rem;
  font-weight: 600;
  color: #336600;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: auto;
}
.conf-pop-oos {
  font-size: 0.75rem;
  font-weight: 600;
  color: #c0392b;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: 0.3rem;
}
.conf-pop-opt.out-of-stock { opacity: 0.75; }

/* ----------------------------------------------------------------
   Sidebar / options panel  (right column, bottom row)
   ---------------------------------------------------------------- */
#conf-sidebar-panel {
  grid-column: 2;
  grid-row: 2;
  background: #fff;
  border-left: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.conf-sidebar-inner {
  flex: 1;
  overflow-y: auto;
  padding: 0.8rem;
}

/* individual selection row */
.conf-sel {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #eee;
}
.conf-sel:last-child { border-bottom: none; }

/* Required / key selections (size, colour) — visually prioritised */
.conf-sel--key {
  border-left: 3px solid #92c13e;
  padding-left: 0.6rem;
  background: #fafff4;
  border-radius: 0 4px 4px 0;
  animation: conf-key-pulse 1.4s ease-out 0.6s 1 both;
}
@keyframes conf-key-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(146,193,62,0.55); }
  60%  { box-shadow: 0 0 0 7px rgba(146,193,62,0); }
  100% { box-shadow: none; }
}

/* Child selections spawned by an option's extraSelections — visually nested */
.conf-sel--child {
  margin-left: 1.25rem;
  border-left: 2px solid #ddd;
  padding-left: 0.5rem;
}
.conf-sel--child .conf-sel-label {
  font-size: 0.78rem;
  color: #557a20;
}

.conf-sel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}
.conf-sel-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #336600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.conf-sel-popup-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: #92c13e;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.conf-sel-popup-btn:hover { color: #336600; }

/* dropdown */
.conf-select {
  width: 100%;
  padding: 0.45rem 0.55rem;
  font-size: 0.88rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  color: #333;
  font-family: inherit;
}
.conf-select:focus { outline: none; border-color: #92c13e; box-shadow: 0 0 0 2px rgba(146,193,62,0.25); }

/* model-type selector button (replaces native <select> for non-material selections) */
.conf-sel-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  background: #f8f8f8;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 0.88rem;
  color: #333;
  transition: border-color 0.15s, background 0.12s;
}
.conf-sel-btn:hover { border-color: #92c13e; background: #f4f9ec; }
.conf-sel-btn-thumb {
  width: 48px;
  height: 36px;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
  background: #e8e8e8;
  display: flex;
  align-items: center;
  justify-content: center;
}
.conf-sel-btn-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.conf-sel-btn-thumb--empty::after {
  content: '\2B21';
  color: #bbb;
  font-size: 1.2rem;
}
.conf-sel-btn-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: normal;
  line-height: 1.3;
}
.conf-sel-btn-arrow {
  color: #92c13e;
  font-size: 1.2rem;
  line-height: 1;
  flex-shrink: 0;
}
.conf-sel-btn-price {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: #336600;
  line-height: 1.2;
}
.conf-sel-btn-oos {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: #c0392b;
  line-height: 1.2;
}

/* colour swatches below the dropdown (material type) */
.conf-swatches {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.45rem;
}
.conf-swatch {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
}
.conf-swatch:hover { transform: scale(1.12); }
.conf-swatch.active {
  border-color: #336600;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12), 0 0 0 2px #92c13e;
}

/* ----------------------------------------------------------------
   Basket area (bottom of sidebar)
   ---------------------------------------------------------------- */
.conf-basket {
  border-top: 2px solid #92c13e;
  padding: 0.8rem;
  background: #fafafa;
}
.conf-basket h3 {
  font-size: 0.85rem;
  color: #336600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.5rem;
}
#conf-basket-summary {
  list-style: none;
  font-size: 0.82rem;
  color: #444;
  margin-bottom: 0.7rem;
}
#conf-basket-summary li {
  padding: 0.15rem 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.4rem;
  flex-wrap: wrap;
}
#conf-basket-summary .basket-empty { color: #999; font-style: italic; }
.basket-price {
  font-weight: 600;
  color: #336600;
  white-space: nowrap;
  margin-left: auto;
}
.basket-oos {
  font-size: 0.72rem;
  font-weight: 600;
  color: #c0392b;
  white-space: nowrap;
}
.basket-total {
  border-top: 1px solid #d0d0d0;
  margin-top: 0.35rem;
  padding-top: 0.45rem;
}
.basket-total .basket-price {
  font-size: 1.05rem;
}

/* Grouped addons block inside the basket summary */
.basket-addons-wrapper {
  display: block;
  padding: 0.15rem 0;
}
.basket-addons-wrapper > strong {
  display: block;
  font-size: 0.78rem;
  color: #555;
  margin-bottom: 0.15rem;
}
.basket-addons {
  list-style: none;
  padding-left: 0.5rem;
  border-left: 2px solid #e8e8e8;
  margin: 0.1rem 0;
}
.basket-addons li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.08rem 0;
  font-size: 0.78rem;
  color: #555;
  flex-wrap: wrap;
}

.conf-basket-btn {
  display: block;
  width: 100%;
  padding: 0.7rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: #92c13e;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.conf-basket-btn:hover { background: #7daa2e; }
.conf-basket-btn:disabled {
  background: #c5c5c5;
  cursor: not-allowed;
}

/* ----------------------------------------------------------------
   Mobile  (≤ 900 px): flex column — heading → canvas → options
   Sidebar is always visible inline, no drawer needed.
   ---------------------------------------------------------------- */
@media (max-width: 900px) {

  .conf-page {
    height: auto;
    overflow: visible;
  }

  .conf-logo-link {
    top: 0.6rem;
    left: 0.6rem;
    width: 42px;
    height: 42px;
  }
  .conf-logo-link .icon { width: 26px; height: 26px; }

  .conf-layout {
    display: flex;
    flex-direction: column;
    height: auto;
  }

  /* heading first — top padding so logo doesn't overlap text */
  .conf-heading-area {
    order: 1;
    border-left: none;
    border-bottom: 1px solid #e0e0e0;
    padding-top: 3.8rem;
  }

  /* canvas second */
  #conf-canvas-wrapper {
    order: 2;
    height: 55vh;
    min-height: 280px;
  }

  /* options last — always visible, not a drawer */
  #conf-sidebar-panel {
    order: 3;
    position: static;
    transform: none;
    border-left: none;
    border-top: 1px solid #e0e0e0;
    box-shadow: none;
    max-height: none;
    overflow: visible;
    min-height: unset;
  }
  .conf-sidebar-inner { overflow: visible; }
}

/* ----------------------------------------------------------------
   Very small screens
   ---------------------------------------------------------------- */
@media (max-width: 480px) {
  .conf-heading-area h1 { font-size: 1rem; }
  .conf-heading-area { font-size: 0.82rem; }
  #conf-canvas-wrapper { height: 45vh; min-height: 240px; }
}
