/* ==========================================================================
   Interactive Studio Designer Layout & Controls
   ========================================================================== */

.designer-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  overflow: hidden;
}

.designer-header {
  height: 56px;
  flex-shrink: 0;
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 16px;
  z-index: 10;
}

.designer-progress {
  display: flex;
  align-items: center;
  gap: 4px;
}

.designer-step {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 11px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition-fast);
  font-size: 13px;
}

.step-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 3-Column Studio Workspace */
.designer-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr) 344px;
}

/* Left Panel: Garment Config */
.designer-sidebar-left {
  background: #fff;
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  padding: 16px;
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
}

.garment-type-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
  background: #F0F2F5;
  padding: 4px;
  border-radius: 10px;
}

.garment-switch-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

.garment-switch-btn:hover {
  background: rgba(255, 255, 255, 0.6);
}

.garment-switch-btn.active {
  background: #fff;
  border-color: var(--color-border);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.1);
}

.switch-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--color-text-main);
}

.switch-sub {
  font-size: 10.5px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.garment-switch-btn.active .switch-title {
  color: var(--color-brand);
}

.product-summary-card {
  margin-top: 10px;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
}

.product-summary-thumb {
  width: 48px;
  height: 58px;
  background: var(--color-bg);
  border-radius: 7px;
  flex-shrink: 0;
  padding: 2px;
}

.color-chips-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 8px;
}

.color-chip {
  aspect-ratio: 1;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow var(--transition-fast);
}

.color-chip-inner {
  width: 78%;
  height: 78%;
  border-radius: 6px;
  border: 1px solid rgba(16, 24, 40, 0.18);
}

.fit-selector {
  margin-top: 10px;
  display: flex;
  background: #F0F2F5;
  border-radius: 9px;
  padding: 3px;
  gap: 3px;
}

.fit-option-btn {
  flex: 1;
  height: 32px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  color: var(--color-text-muted);
  transition: all var(--transition-fast);
}

.fit-option-btn.active {
  background: #fff;
  color: var(--color-text-main);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12);
}

/* Center: Garment Stage */
.designer-stage-area {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: radial-gradient(120% 90% at 50% 20%, #FFFFFF 0%, #F0F2F5 100%);
  user-select: none;
}

.stage-view-tabs {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
  box-shadow: var(--shadow-sm);
}

.view-tab-btn {
  height: 30px;
  padding: 0 13px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  color: #3D4650;
  transition: all var(--transition-fast);
}

.view-tab-btn.active {
  background: var(--color-brand);
  color: #fff;
  font-weight: 600;
}

.stage-zoom-controls {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stage-viewport {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 24px 24px;
  cursor: default;
}

.stage-canvas {
  position: relative;
  height: 100%;
  max-height: 100%;
  aspect-ratio: 400 / 480;
  max-width: 100%;
  transition: transform 180ms ease;
  transform-origin: center center;
}

/* Zone Overlays */
.placement-zone-box {
  position: absolute;
  box-sizing: border-box;
  cursor: pointer;
  border-radius: 3px;
  border: 1px dashed rgba(18, 50, 77, 0.35);
  background: rgba(18, 50, 77, 0.02);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.placement-zone-box.active {
  border: 1.5px solid rgba(18, 50, 77, 0.85);
  background: rgba(18, 50, 77, 0.06);
}

.zone-label-tag {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 9.5px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--color-brand);
  color: #fff;
}

/* Interactive Layer Element */
.designer-layer {
  position: absolute;
  user-select: none;
  touch-action: none;
  cursor: move;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%);
}

.designer-layer.selected {
  outline: 1.5px solid var(--color-brand);
  outline-offset: 3px;
}

/* Resize and Rotate Handles */
.layer-handle-resize {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: #fff;
  border: 1.5px solid var(--color-brand);
  cursor: nwse-resize;
  z-index: 20;
}

.layer-handle-rotate {
  position: absolute;
  left: 50%;
  top: -26px;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid var(--color-brand);
  cursor: grab;
  z-index: 20;
}

/* Embroidery Stitch Simulation Filter */
.embroidery-logo-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.embroidery-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 1px 0.5px rgba(0,0,0,0.45)) drop-shadow(0 -0.5px 0 rgba(255,255,255,0.3)) saturate(1.04);
}

.embroidery-thread-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: overlay;
  opacity: 0.75;
  background-image: repeating-linear-gradient(
    52deg,
    rgba(255, 255, 255, 0.55) 0px,
    rgba(255, 255, 255, 0.55) 0.7px,
    rgba(0, 0, 0, 0.42) 0.7px,
    rgba(0, 0, 0, 0.42) 1.9px
  );
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

.embroidery-text {
  white-space: nowrap;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 0.4px rgba(0,0,0,0.42), 0 -0.5px 0 rgba(255,255,255,0.28);
  -webkit-text-stroke: 0.35px rgba(0,0,0,0.16);
}

/* Warnings Banner on Stage */
.stage-warning-banner {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  max-width: min(520px, 92%);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--color-warning-bg);
  border: 1px solid var(--color-warning-border);
  border-radius: 10px;
  padding: 10px 13px;
  z-index: 10;
}

/* Right Panel: Controls & Tabs */
.designer-sidebar-right {
  background: #fff;
  border-left: 1px solid var(--color-border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-tab-header {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 5;
  padding: 12px 14px 0;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-tabs {
  display: flex;
  gap: 2px;
}

.sidebar-tab-btn {
  flex: 1;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--color-text-subtle);
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
}

.sidebar-tab-btn.active {
  color: var(--color-brand);
  font-weight: 600;
  border-bottom-color: var(--color-brand);
}

.tab-pane {
  padding: 16px 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Bottom Bar */
.designer-bottom-bar {
  flex-shrink: 0;
  background: #fff;
  border-top: 1px solid var(--color-border);
  position: relative;
  z-index: 20;
}

.designer-bottom-bar-inner {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.sizes-grid {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.size-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.size-cell-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--color-text-subtle);
}

.price-breakdown-popover {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 16px;
  width: 320px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  z-index: 30;
  animation: slideUp var(--transition-fast);
}

/* Comprehensive Studio Mobile & Responsive Adjustments */
@media (max-width: 1120px) {
  .designer-container {
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
  }
  .designer-body {
    grid-template-columns: 1fr;
    display: flex;
    flex-direction: column;
  }
  .designer-stage-area {
    min-height: clamp(380px, 52vh, 480px);
    order: -1; /* Keep live stage on top on mobile/tablet so user sees their design immediately */
  }
  .designer-sidebar-left {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }
  .designer-sidebar-right {
    border-left: none;
  }
  .designer-bottom-bar-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }
  .sizes-grid {
    justify-content: space-between;
  }
  .stepper {
    height: 36px;
  }
  .stepper-btn {
    width: 28px;
  }
}

@media (max-width: 640px) {
  .designer-header {
    padding: 0 12px;
    gap: 8px;
  }
  .designer-progress {
    display: none; /* Hide progress steps on small mobile phones to prevent clutter */
  }
  .stage-view-tabs {
    top: 8px;
    padding: 2px;
  }
  .view-tab-btn {
    height: 28px;
    padding: 0 9px;
    font-size: 11.5px;
  }
  .stage-zoom-controls {
    top: 8px;
    right: 8px;
  }
  .sizes-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .size-cell {
    width: 100%;
  }
  .stepper {
    width: 100%;
  }
  .stepper-input {
    flex: 1;
    width: unset;
  }
  .stepper-btn {
    flex: 1;
  }
  .designer-bottom-bar-inner {
    padding: 12px;
  }
  #btn-add-to-cart {
    width: 100%;
  }
}
