/* ==========================================================================
   CONFIGURATOR.CSS — Product Configurator Layout & Sidebar
   toilet-cubicle.co.uk
   ========================================================================== */

/* =========================================================================
   PAGE WRAPPER
   ========================================================================= */

.configurator-page {
  min-height: calc(100vh - var(--header-height));
  min-height: calc(100dvh - var(--header-height));
  background-color: var(--color-off-white);
  overflow: hidden;
}

@media (min-width: 1024px) {
  .configurator-page {
    height: calc(100vh - var(--header-height));
    height: calc(100dvh - var(--header-height));
    overflow: hidden;
  }
}

/* =========================================================================
   TWO-COLUMN LAYOUT
   Viewport (drawing/SVG) on left, sidebar on right
   ========================================================================= */

.configurator {
  display: grid;
  grid-template-columns: 1fr;
  min-height: calc(100vh - var(--header-height));
  min-height: calc(100dvh - var(--header-height));
}

@media (min-width: 1024px) {
  .configurator {
    grid-template-columns: 1fr var(--sidebar-width);
    height: 100%;
    overflow: hidden;
  }
}

/* =========================================================================
   VIEWPORT — Drawing / SVG area
   ========================================================================= */

.configurator__viewport {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  background-color: var(--color-off-white);
  overflow: hidden;

  /* Subtle architectural grid background */
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.025) 1px, transparent 1px);
  background-size: 40px 40px;
}

@media (min-width: 1024px) {
  .configurator__viewport {
    padding: var(--sp-6);
  }
}

/* SVG drawing scales responsively */
.configurator__viewport svg {
  max-width: 100%;
  height: auto;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.06));
  transition: opacity var(--transition-base);
}

/* Loading state */
.configurator__viewport--loading svg {
  opacity: 0.4;
}

/* -- Compass / Orientation indicator -------------------------------------- */

.configurator__compass {
  position: absolute;
  bottom: var(--sp-3);
  left: var(--sp-3);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
  color: var(--color-grey-600);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  font-weight: var(--weight-medium);
  user-select: none;
  border: 1px solid var(--color-grey-200);
}

.configurator__compass::after {
  content: "N";
  position: absolute;
  top: -2px;
  font-size: 9px;
  font-weight: var(--weight-bold);
  color: var(--color-red);
}

/* -- Dimensions Readout --------------------------------------------------- */

.configurator__dimensions-readout {
  position: absolute;
  bottom: var(--sp-3);
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0.375rem 0.75rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-grey-200);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-charcoal);
  white-space: nowrap;
}

.configurator__dimensions-readout span {
  color: var(--color-grey-400);
}

@media (max-width: 480px) {
  .configurator__dimensions-readout {
    font-size: 0.625rem;
    padding: 0.25rem 0.5rem;
  }

  .configurator__view-toggle .btn {
    font-size: 0.625rem;
    min-height: 30px;
    padding: 0.25rem 0.5rem;
  }
}

/* Highlight dimension that just changed */
.configurator__dim-value {
  transition: color var(--transition-fast);
}

.configurator__dim-value--changed {
  color: var(--color-green);
}

/* -- Viewport toolbar (zoom, reset, etc.) --------------------------------- */

.configurator__toolbar {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-grey-200);
  overflow: hidden;
}

.configurator__toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  color: var(--color-grey-600);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.configurator__toolbar-btn:hover {
  background-color: var(--color-grey-100);
  color: var(--color-charcoal);
}

.configurator__toolbar-btn + .configurator__toolbar-btn {
  border-top: 1px solid var(--color-grey-200);
}

.configurator__toolbar-btn svg {
  width: 18px;
  height: 18px;
}

/* -- View Toggle (Plan / Elevation) --------------------------------------- */

.configurator__view-toggle {
  position: absolute;
  top: var(--sp-3);
  left: var(--sp-3);
  display: flex;
  gap: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-grey-200);
  overflow: hidden;
  z-index: 2;
}

.configurator__view-toggle .btn {
  border-radius: 0;
  border: none;
  border-right: 1px solid var(--color-grey-200);
  min-height: 36px;
  text-transform: none;
  letter-spacing: var(--tracking-normal);
  font-weight: var(--weight-medium);
  font-size: var(--text-xs);
  color: var(--color-grey-600);
  background: transparent;
}

.configurator__view-toggle .btn:last-child {
  border-right: none;
}

.configurator__view-toggle .btn.active {
  background-color: var(--color-green);
  color: var(--color-white);
  font-weight: var(--weight-semibold);
}

.configurator__view-toggle .btn:hover:not(.active) {
  background-color: var(--color-grey-100);
  color: var(--color-grey-900);
}

/* =========================================================================
   SIDEBAR
   ========================================================================= */

.configurator__sidebar {
  background-color: var(--color-white);
  border-left: 1px solid var(--color-grey-100);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (min-width: 1024px) {
  .configurator__sidebar {
    position: sticky;
    top: var(--header-height);
    max-height: calc(100vh - var(--header-height));
    max-height: calc(100dvh - var(--header-height));
  }
}

/* -- Sidebar Header ------------------------------------------------------- */

.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3);
  border-bottom: 1px solid var(--color-grey-100);
  flex-shrink: 0;
}

.sidebar__header h1 {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-normal);
  line-height: 1.4;
  margin-bottom: 0;
}

/* Close button — visible only on mobile */
.sidebar__close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: var(--color-grey-600);
  background: var(--color-grey-100);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.sidebar__close:hover {
  background-color: var(--color-grey-200);
  color: var(--color-grey-900);
}

.sidebar__close svg {
  width: 18px;
  height: 18px;
}

/* =========================================================================
   TABS — Within sidebar
   ========================================================================= */

.tabs {
  display: flex;
  border-bottom: 1px solid var(--color-grey-100);
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

[role="tab"] {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.875rem var(--sp-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-grey-600);
  white-space: nowrap;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  cursor: pointer;
  transition:
    color var(--transition-fast),
    border-color var(--transition-fast),
    background-color var(--transition-fast);
}

[role="tab"]:hover {
  color: var(--color-grey-900);
  background-color: var(--color-grey-50);
}

[role="tab"][aria-selected="true"] {
  color: var(--color-green);
  border-bottom-color: var(--color-green);
  font-weight: var(--weight-semibold);
}

[role="tab"]:focus-visible {
  outline: 2px solid var(--color-green);
  outline-offset: -2px;
}

[role="tab"] svg {
  width: 16px;
  height: 16px;
  opacity: 0.7;
}

[role="tab"][aria-selected="true"] svg {
  opacity: 1;
}

/* -- Sidebar scrollable content wrapper ------------------------------------ */

.sidebar__content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* -- Fieldsets & Legends in sidebar ---------------------------------------- */

.configurator__sidebar fieldset {
  border: none;
  margin-bottom: var(--sp-3);
}

.configurator__sidebar fieldset:last-child {
  margin-bottom: 0;
}

.configurator__sidebar legend {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--color-grey-600);
  margin-bottom: var(--sp-2);
  padding-bottom: var(--sp-1);
  border-bottom: 1px solid var(--color-grey-100);
  width: 100%;
}

/* -- Tab panels ----------------------------------------------------------- */

[role="tabpanel"] {
  padding: var(--sp-3);
}

[role="tabpanel"][hidden] {
  display: none;
}

/* Section dividers within panels */
.panel-section {
  margin-bottom: var(--sp-4);
}

.panel-section:last-child {
  margin-bottom: 0;
}

.panel-section__title {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--color-grey-600);
  margin-bottom: var(--sp-2);
  padding-bottom: var(--sp-1);
  border-bottom: 1px solid var(--color-grey-100);
}

/* =========================================================================
   CONFIG OVERVIEW — Step progress in sidebar
   ========================================================================= */

.config-overview {
  padding: var(--sp-3);
  border-top: 1px solid var(--color-grey-100);
}

.config-overview h2 {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--color-grey-600);
  line-height: 1.4;
  margin-bottom: var(--sp-2);
}

.config-overview__title {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--color-grey-600);
  margin-bottom: var(--sp-2);
}

/* -- Steps list ----------------------------------------------------------- */

.config-overview__steps {
  position: relative;
  padding-left: var(--sp-4);
}

/* Connecting vertical line */
.config-overview__steps::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 11px;
  width: 2px;
  bottom: 8px;
  background-color: var(--color-grey-200);
  border-radius: 2px;
}

.config-overview__step {
  position: relative;
  padding-bottom: var(--sp-2);
  padding-left: var(--sp-1);
}

.config-overview__step:last-child {
  padding-bottom: 0;
}

/* Step marker (circle) */
.config-overview__step::before {
  content: attr(data-step);
  position: absolute;
  left: calc(-1 * var(--sp-4) + 2px);
  top: 2px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: var(--weight-bold);
  font-family: var(--font-mono);
  color: var(--color-grey-400);
  background-color: var(--color-white);
  border: 2px solid var(--color-grey-300);
  border-radius: var(--radius-full);
  z-index: 1;
  transition:
    background-color var(--transition-base),
    border-color var(--transition-base),
    color var(--transition-base);
}

.config-overview__label {
  display: block;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-grey-600);
  transition: color var(--transition-fast);
}

.config-overview__value {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-grey-400);
  margin-top: 1px;
}

/* -- Active step ---------------------------------------------------------- */

.config-overview__step--active::before {
  border-color: var(--color-green);
  color: var(--color-green);
  box-shadow: 0 0 0 3px var(--color-green-muted);
}

.config-overview__step--active .config-overview__label {
  color: var(--color-grey-900);
  font-weight: var(--weight-semibold);
}

/* -- Completed step ------------------------------------------------------- */

.config-overview__step--complete::before {
  content: "";
  background-color: var(--color-green);
  border-color: var(--color-green);
  color: var(--color-white);
  /* Checkmark via background image */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none'%3E%3Cpath d='M2.5 6.5L5 9l4.5-5' stroke='%23fff' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

.config-overview__step--complete .config-overview__label {
  color: var(--color-grey-900);
}

/* =========================================================================
   SIDEBAR ACTIONS — Sticky bottom strip
   ========================================================================= */

.sidebar__actions {
  padding: var(--sp-3);
  border-top: 1px solid var(--color-grey-100);
  background-color: var(--color-white);
  flex-shrink: 0;
}

/* Actions button area stays pinned at bottom via flexbox — no sticky needed */

.sidebar__actions .btn {
  width: 100%;
}

.sidebar__actions .btn + .btn {
  margin-top: var(--sp-1);
}

/* Trade / Pro link */
.sidebar__trade-link {
  display: block;
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-grey-600);
  margin-top: var(--sp-2);
}

.sidebar__trade-link a {
  color: var(--color-green);
  font-weight: var(--weight-medium);
}

.sidebar__trade-link a:hover {
  color: var(--color-green-dark);
}

/* =========================================================================
   MOBILE / TABLET — Below 1024px
   Stacked layout: viewport on top, sidebar below, page scrolls
   ========================================================================= */

@media (max-width: 1023px) {
  .configurator-page {
    height: auto;
    min-height: auto;
    overflow: visible;
  }

  .configurator {
    grid-template-columns: 1fr;
    height: auto;
    min-height: auto;
    overflow: visible;
  }

  .configurator__viewport {
    min-height: 280px;
    max-height: 50vh;
  }

  .configurator__sidebar {
    position: relative;
    transform: none;
    border-left: none;
    border-top: 1px solid var(--color-grey-100);
    max-height: none;
    overflow: visible;
  }

  .sidebar__content {
    overflow: visible;
  }

  /* Hide close button — sidebar is inline, not overlay */
  .sidebar__close {
    display: none;
  }

  /* Backdrop not needed in stacked mode */
  .configurator__sidebar-backdrop {
    display: none !important;
  }
}

/* Desktop — always hide backdrop */
@media (min-width: 1024px) {
  .configurator__sidebar-backdrop {
    display: none !important;
  }
}

/* =========================================================================
   FLOATING "OPEN SIDEBAR" BUTTON — Mobile only
   ========================================================================= */

/* Floating configure button — no longer needed since sidebar is inline on mobile */
.configurator__open-sidebar {
  display: none;
}

/* =========================================================================
   CUBICLE WIDTHS — Per-cubicle width inputs
   ========================================================================= */

.cubicle-width-row {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  margin-bottom: 6px;
}

.cubicle-width-row__label {
  min-width: 24px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-grey-600);
  font-family: var(--font-mono);
  text-align: right;
}

.cubicle-width-row .input-with-unit {
  flex: 1;
}

.cubicle-width-row input[type="number"] {
  width: 100%;
  font-size: var(--text-sm);
  padding: 0.35rem 0.5rem;
}

/* =========================================================================
   RANGE SLIDER — Custom for dimension inputs
   ========================================================================= */

.range-slider {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.range-slider input[type="range"] {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--color-grey-200);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.range-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--color-green);
  border: 3px solid var(--color-white);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.range-slider input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: var(--shadow-green);
}

.range-slider input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--color-green);
  border: 3px solid var(--color-white);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.range-slider__value {
  min-width: 60px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-charcoal);
}
