/* Design studio: the customer page (/design), the owner's studio, tech packs and design thumbnails.
   Drawings come from wwwroot/js/designer.js. */

/* ---------- Drawings ---------- */

.dz-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.dz-view {
  font: 700 11px var(--font-body);
  letter-spacing: 0.18em;
  fill: var(--muted);
}

.dz-pom {
  font: 700 8.5px var(--font-body);
  fill: #fff;
}

.design-mini {
  width: 72px;
  height: 92px;
  flex: none;
  padding: 4px;
  border-radius: var(--radius-sm);
  /* Atelier paper in both themes, like the main canvas. */
  background: #f1ebe1;
}

.design-preview {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
}

/* ---------- Studio layout (customer) ---------- */

.studio-header {
  max-width: 760px;
}

.studio {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, 1fr);
  gap: clamp(20px, 3vw, 44px);
  align-items: start;
}

.studio > *,
.owner-studio > * {
  min-width: 0;
}

.studio-stage {
  position: sticky;
  top: 88px;
  display: grid;
  gap: 14px;
}

.studio-canvas {
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: clamp(14px, 3vw, 32px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  /* Atelier paper in both themes, so dark fabrics stay readable. */
  background: radial-gradient(120% 80% at 50% 0%, #fffdf9 0%, #efe8dc 100%);
  box-shadow: var(--shadow-sm);
  --muted: #6c635a;
}

.studio-canvas .dz-svg {
  max-height: min(68vh, 640px);
}

.studio-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.segmented button,
.toggle-chip {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font: 700 0.82rem var(--font-body);
  cursor: pointer;
}

.toggle-chip {
  border: 1px solid var(--line);
  background: var(--surface);
}

.segmented button[aria-pressed="true"],
.toggle-chip[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
}

.studio-meta {
  display: grid;
  gap: 10px;
}

.studio-price {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}

.studio-price span {
  color: var(--muted);
  font-size: 0.85rem;
}

.studio-price strong {
  font-size: 1.6rem;
  color: var(--ink);
}

.studio-price small {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 0.78rem;
}

.studio-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.design-summary {
  color: var(--ink-soft);
  line-height: 1.8;
}

.studio-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.studio-looks h2,
.my-designs h2 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.look-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x mandatory;
}

.look-card {
  display: grid;
  justify-items: center;
  gap: 6px;
  flex: none;
  width: 96px;
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: 700 0.76rem var(--font-body);
  cursor: pointer;
  scroll-snap-align: start;
  transition: border-color 0.2s ease, transform 0.2s var(--ease);
}

.look-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
}

.look-card .design-mini {
  width: 76px;
  height: 92px;
}

.studio-ai {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--gold-soft);
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--gold-soft), var(--surface));
}

.studio-ai label {
  font-weight: 800;
}

.ai-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.ai-row textarea {
  flex: 1;
  min-width: 0;
  resize: vertical;
}

.studio-steps {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.studio-steps button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: 700 0.82rem var(--font-body);
  white-space: nowrap;
  cursor: pointer;
}

.studio-steps button span {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.72rem;
}

.studio-steps button.done span {
  background: var(--gold-soft);
  color: var(--gold-strong);
}

.studio-steps button[aria-current="step"] {
  border-bottom-color: var(--ink);
  color: var(--ink);
}

.studio-steps button[aria-current="step"] span {
  background: var(--ink);
  color: var(--bg);
}

.studio-form,
.studio-form > section {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.studio-form > section[hidden] {
  display: none;
}

.studio-form fieldset {
  display: grid;
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.studio-form legend {
  margin-bottom: 8px;
  font-weight: 800;
}

fieldset[disabled] {
  opacity: 0.45;
}

.field-hint {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}

.thumb-option {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.thumb-option input {
  position: absolute;
  opacity: 0;
}

.thumb-option:has(input:checked) {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}

.thumb-option:has(input:focus-visible) {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.thumb-art {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 5;
  border-radius: 8px;
  background: #f1ebe1;
}

.thumb-art .design-mini {
  width: 100%;
  height: 100%;
  background: none;
}

.thumb-label {
  display: grid;
  gap: 2px;
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}

.option-price {
  color: var(--gold-strong);
  font-size: 0.7rem;
  font-weight: 700;
}

.option-chips,
.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option-chip input,
.swatch input {
  position: absolute;
  opacity: 0;
}

.option-chip span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.option-chip input:checked + span {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.option-chip input:checked + span .option-price {
  color: var(--gold-soft);
}

.option-chip input:focus-visible + span,
.swatch input:focus-visible + span {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.fabric-dot {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: #3a3632;
}

.fabric-dot[data-fabric="satin"] { background: linear-gradient(135deg, #1d1b19 20%, #8f8780 45%, #1d1b19 70%); }
.fabric-dot[data-fabric="velvet"] { background: radial-gradient(circle at 35% 30%, #4a4440, #0d0c0b 70%); }
.fabric-dot[data-fabric="linen"] { background: repeating-linear-gradient(0deg, #8d8277 0 1px, #a69b8f 1px 3px); }
.fabric-dot[data-fabric="chiffon"] { background: linear-gradient(135deg, rgba(60, 55, 50, 0.45), rgba(60, 55, 50, 0.15)); }
.fabric-dot[data-fabric="jacquard"] { background: radial-gradient(circle, #6b625a 1.5px, #2a2623 2px) 0 0 / 6px 6px; }
.fabric-dot[data-fabric="nada"] { background: linear-gradient(160deg, #2c2926, #1a1816); }

.swatch {
  display: grid;
  justify-items: center;
  gap: 4px;
  width: 64px;
  cursor: pointer;
}

.swatch span {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 3px var(--surface);
  transition: transform 0.2s ease;
}

.color-swatches.small .swatch {
  width: 54px;
}

.color-swatches.small .swatch span {
  width: 30px;
  height: 30px;
}

.swatch input:checked + span {
  border: 2px solid var(--gold);
  transform: scale(1.08);
}

.swatch small {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 400;
  text-align: center;
}

.range-field span {
  display: flex;
  justify-content: space-between;
}

.range-field output {
  color: var(--gold-strong);
  font-weight: 800;
}

.measure-guide {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.88rem;
  line-height: 1.8;
}

.measure-guide summary {
  font-weight: 700;
  cursor: pointer;
}

.review-title {
  margin: 0;
  font-size: 1.1rem;
}

.spec-list {
  display: grid;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.spec-list > div {
  display: grid;
  grid-template-columns: 9.5em 1fr;
  gap: 12px;
  padding: 9px 14px;
}

.spec-list > div:nth-child(odd) {
  background: var(--surface-2);
}

.spec-list dt {
  color: var(--muted);
  font-size: 0.85rem;
}

.spec-list dd {
  margin: 0;
  font-weight: 700;
}

.design-send {
  padding-top: 18px;
  border-top: 1px dashed var(--line);
}

.step-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.step-count {
  color: var(--muted);
  font-size: 0.82rem;
}

.saved-grid {
  display: grid;
  gap: 10px;
}

.saved-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.saved-card small {
  display: block;
  color: var(--muted);
}

.saved-open {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.saved-open .design-mini {
  width: 56px;
  height: 70px;
}

@media (max-width: 960px) {
  .studio {
    grid-template-columns: minmax(0, 1fr);
  }

  .studio-stage {
    position: static;
  }

  .studio-canvas {
    min-height: 0;
  }

  .studio-canvas .dz-svg {
    max-height: 56vh;
  }
}

@media (max-width: 520px) {
  .ai-row {
    flex-direction: column;
  }

  .spec-list > div {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

/* ---------- Owner studio ---------- */

.studio-brief {
  display: grid;
  gap: 10px;
}

.studio-brief .ai-row textarea {
  min-height: 64px;
}

.engine-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.engine-badge.on {
  background: var(--gold-soft);
  color: var(--gold-strong);
}

.owner-studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 18px;
  align-items: start;
}

.studio-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.ai-measure-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.studio-editor .style-no {
  color: var(--gold-strong);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.studio-editor details {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.studio-editor summary {
  font-weight: 800;
  cursor: pointer;
  padding: 4px 0;
}

.studio-editor details[open] summary {
  margin-bottom: 10px;
}

.studio-editor .thumb-grid {
  grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
}

.studio-preview {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 12px;
}

.studio-preview .studio-canvas {
  min-height: 360px;
}

.studio-figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
}

.studio-figures div {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.studio-figures span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.studio-figures strong {
  font-size: 1.05rem;
}

.design-library {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.library-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: start;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.library-card:hover,
.library-card[aria-current="true"] {
  border-color: var(--gold);
  box-shadow: var(--shadow-sm);
}

.library-card .design-mini {
  width: 100%;
  height: 170px;
}

.library-card small {
  color: var(--muted);
}

.library-card .style-no {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--gold-strong);
  font-weight: 800;
}

.design-status {
  justify-self: start;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  background: var(--surface-2);
}

.design-status[data-status="sampling"] { background: #fff1d6; color: #8a5a00; }
.design-status[data-status="approved"] { background: #e2f1e6; color: #2f6b41; }
.design-status[data-status="archived"] { background: #ececec; color: #666; }

:root[data-theme="dark"] .design-status[data-status="sampling"] { background: #3a2e14; color: #f0c36b; }
:root[data-theme="dark"] .design-status[data-status="approved"] { background: #1d3324; color: #8fd2a3; }
:root[data-theme="dark"] .design-status[data-status="archived"] { background: #2b2b2b; color: #aaa; }

.library-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

@media (max-width: 1100px) {
  .owner-studio {
    grid-template-columns: minmax(0, 1fr);
  }

  .studio-preview {
    position: static;
    order: -1;
  }
}
