/* =========================================================
   GORDON & SMITH — Estúdio de personalização (estilo Dimona)
   Layout: header claro · rail escuro de abas · painel de
   cards flutuantes · stage cinza com ferramentas flutuantes
   ========================================================= */

:root {
  --gold: #c9a84c;
  --gold-dark: #a8893a;
  --ink: #16171d;
  --ink-2: #23242c;
  --bg: #e9eaee;
  --card: #ffffff;
  --text: #1d1e24;
  --text-2: #6b6e78;
  --line: #e3e4e9;
  --shadow: 0 2px 10px rgba(20, 21, 28, 0.10);
  --shadow-lg: 0 10px 34px rgba(20, 21, 28, 0.22);
  --radius: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body.studio {
  height: 100%;
  overflow: hidden;
}

body.studio {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
.hidden { display: none !important; }

/* ══════════ HEADER ══════════ */
.st-header {
  height: 56px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 18px;
  position: relative;
  z-index: 60;
}

.st-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.15s;
}
.st-back:hover { background: #f2f3f6; }

.st-logo {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Montserrat', sans-serif;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 0.14em;
  color: var(--ink);
  user-select: none;
}
.st-logo em { font-style: normal; color: var(--gold); }

.st-actions { margin-left: auto; position: relative; }
.st-kebab {
  width: 38px; height: 38px;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--text);
  transition: background 0.15s;
}
.st-kebab:hover { background: #f2f3f6; }

.st-dropdown {
  position: absolute;
  top: 44px; right: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 230px;
  padding: 6px;
  z-index: 100;
}
.st-dropdown button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 10px 12px;
  font-size: 13.5px;
  border-radius: 7px;
  text-align: left;
  transition: background 0.12s;
}
.st-dropdown button:hover:not(:disabled) { background: #f2f3f6; }
.st-dropdown button:disabled { opacity: 0.4; cursor: default; }
.st-dropdown kbd {
  font-family: inherit;
  font-size: 11px;
  color: var(--text-2);
  background: #f2f3f6;
  border-radius: 4px;
  padding: 2px 6px;
}
.drop-danger { color: #c0392b; }

/* ══════════ BODY ══════════ */
.st-body {
  display: flex;
  height: calc(100% - 56px);
}

/* ── Rail de abas ── */
.st-rail {
  width: 78px;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 8px 0;
  z-index: 50;
  flex-shrink: 0;
}
.rail-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 4px;
  color: #9a9daa;
  transition: color 0.15s, background 0.15s;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
}
.rail-btn span {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.rail-btn:hover { color: #fff; }
.rail-btn.active {
  color: #fff;
  background: var(--ink-2);
  border-left-color: var(--gold);
}
.rail-spacer { flex: 1; }

/* ── Painel ── */
.st-panel {
  width: 356px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 18px 6px 18px 18px;
  position: relative;
  scrollbar-width: thin;
}
.panel-close { display: none; }

.panel-view { display: none; }
.panel-view.active { display: block; }
.panel-view > * + * { margin-top: 14px; }

.pv-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
}
.pv-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-2);
}
.pv-label strong { color: var(--text); }
.pv-hint { font-size: 12.5px; color: var(--text-2); line-height: 1.55; }

.pv-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.pv-card h4 {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 6px;
}
.pv-card p { font-size: 12.5px; color: var(--text-2); line-height: 1.6; }
.pv-card p + h4 { margin-top: 14px; }
.pv-card p + p { margin-top: 8px; }

/* Upload (aba Imagem) */
.upload-box {
  background: var(--card);
  border: 2px dashed var(--gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.upload-box:hover { border-color: var(--gold-dark); }
.upload-box.dragover { border-color: var(--gold-dark); transform: scale(1.015); background: #fffdf5; }
.upload-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gold-dark);
  margin-bottom: 10px;
}
.upload-icn { color: var(--text-2); margin-bottom: 10px; }
.upload-sub { font-size: 12px; color: var(--text-2); line-height: 1.7; }

.upload-progress {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-top: 12px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: #e3e4e9;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold-dark) 100%);
  border-radius: 3px;
  transition: width 0.2s ease;
  width: 0%;
}

.progress-text {
  font-size: 12px;
  color: var(--text-2);
  text-align: center;
  font-weight: 500;
}

/* Peças (aba Produto) */
.piece-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.piece-card {
  background: var(--card);
  border: 2px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s;
}
.piece-card img { width: 100%; height: 62px; object-fit: contain; }
.piece-card span { font-size: 11px; font-weight: 700; color: var(--text); }
.piece-card.active { border-color: var(--gold); }

.fit-row { display: flex; gap: 8px; }
.fit-btn {
  flex: 1;
  background: var(--card);
  border: 2px solid transparent;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 9px 4px;
  font-size: 12px;
  font-weight: 700;
}
.fit-btn.active { border-color: var(--gold); }

/* Grade de cores (painel + popover) */
.cores-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(30px, 1fr));
  gap: 8px;
}
.cor-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.12);
  position: relative;
  transition: transform 0.12s;
}
.cor-swatch:hover { transform: scale(1.12); }
.cor-swatch.active { outline: 2.5px solid var(--gold); outline-offset: 2px; }

/* Estampas */
.stamps-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.stamp-btn {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 12px;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.12s;
}
.stamp-btn:hover { border-color: var(--gold); transform: translateY(-2px); }
.stamp-btn svg { width: 100%; height: 100%; color: #3c3e48; }

/* Propriedades de objeto (aparecem quando selecionado) */
.obj-props { display: none; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.obj-props.visible { display: block; }
.obj-props > * + * { margin-top: 10px; }

.prop-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-2);
}
.prop-input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.prop-num { width: 72px; text-align: center; }
.prop-row { display: flex; gap: 8px; align-items: center; }
.prop-btn {
  min-width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 15px;
  display: grid;
  place-items: center;
  transition: background 0.12s, border-color 0.12s;
}
.prop-btn:hover { background: #f5f5f8; }
.prop-btn.active, .prop-btn.active-align { border-color: var(--gold); background: #fdf8ea; }

.range-input { width: 100%; accent-color: var(--gold); }

.tc-row { display: flex; align-items: center; gap: 10px; }
.color-native {
  width: 38px; height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
  background: #fff;
  cursor: pointer;
}
.tc-swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.tc-swatch {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.15);
}
.tc-swatch.active { outline: 2px solid var(--gold); outline-offset: 2px; }

.btn-primary {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  padding: 13px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--ink-2); }

/* Camadas */
.layers-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.layer-item {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  cursor: pointer;
}
.layer-item.selected { border-color: var(--gold); }
.layer-item.invisible { opacity: 0.5; }
.layer-icn { color: var(--text-2); flex-shrink: 0; display: grid; place-items: center; }
.layer-name {
  flex: 1;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.layer-act {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--text-2);
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.layer-act:hover { background: #f2f3f6; color: var(--text); }
.layer-act.del:hover { color: #c0392b; }

/* ══════════ STAGE ══════════ */
.st-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.stage-scale {
  position: absolute;
  top: 50%; left: 50%;
  width: 460px;
  height: 496px;
  transform: translate(-50%, -50%);
  transform-origin: center center;
}
.stage-inner { position: relative; width: 460px; height: 496px; }
.stage-inner img#shirtImg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}
.stage-inner .canvas-container { position: absolute !important; top: 0; left: 0; }

.st-stage.hand-mode, .st-stage.hand-mode canvas { cursor: grab !important; }
.st-stage.hand-mode.panning, .st-stage.hand-mode.panning canvas { cursor: grabbing !important; }

/* Ferramentas flutuantes */
.fl-tools {
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 30;
}
.fl-group {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.fl-mini {
  width: 52px; height: 38px;
  font-size: 17px;
  color: var(--text);
  display: grid;
  place-items: center;
  transition: background 0.12s;
}
.fl-mini:hover { background: #f2f3f6; }
.fl-mini + .fl-mini { border-top: 1px solid var(--line); }

.fl-btn {
  width: 52px;
  min-height: 52px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  color: var(--text);
  transition: background 0.12s, color 0.12s;
  border: 2px solid transparent;
}
.fl-btn span { font-size: 10px; font-weight: 700; }
.fl-btn:hover { background: #f7f7fa; }
.fl-btn.active { border-color: var(--gold); color: var(--gold-dark); }

.cores-dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.18);
  background: #fff;
}

/* Popover de cores */
.cores-pop {
  position: absolute;
  left: 88px;
  top: 50%;
  transform: translateY(-30%);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  width: 292px;
  z-index: 40;
}
.cores-title { font-size: 12.5px; color: var(--text-2); margin-bottom: 12px; }
.cores-title strong { color: var(--text); }
.cores-pop .cores-grid { grid-template-columns: repeat(7, 1fr); }

/* Baixar */
.btn-baixar {
  position: absolute;
  top: 20px;
  right: 22px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 14px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text);
  z-index: 30;
  transition: background 0.12s;
}
.btn-baixar:hover { background: #f7f7fa; }

/* Frente / Costas */
.side-toggle {
  position: absolute;
  right: 22px;
  bottom: 96px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 30;
}
.side-btn {
  width: 76px;
  background: var(--card);
  border: 2px solid transparent;
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}
.side-btn.active { border-color: var(--gold); color: var(--gold-dark); }

/* Miniaturas */
.prod-thumbs {
  position: absolute;
  left: 22px;
  bottom: 20px;
  display: flex;
  gap: 10px;
  z-index: 30;
}
.thumb {
  width: 64px; height: 64px;
  background: var(--card);
  border: 2px solid transparent;
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.thumb img { width: 88%; height: 88%; object-fit: contain; }
.thumb.active { border-color: var(--gold); }
.thumb-add {
  width: 64px; height: 64px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 26px;
  font-weight: 300;
  color: var(--text-2);
  transition: color 0.12s;
}
.thumb-add:hover { color: var(--text); }

/* Concluir */
.btn-concluir {
  position: absolute;
  right: 22px;
  bottom: 20px;
  background: var(--gold);
  color: #17130a;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 16px 42px;
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(201, 168, 76, 0.45);
  z-index: 30;
  transition: background 0.15s, transform 0.12s;
}
.btn-concluir:hover { background: #d7b75e; transform: translateY(-1px); }
.btn-concluir:disabled { opacity: 0.6; cursor: wait; transform: none; }

/* ══════════ MODAIS ══════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 19, 25, 0.66);
  display: grid;
  place-items: center;
  z-index: 200;
  padding: 18px;
}
.modal-box {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 26px;
  position: relative;
  width: min(520px, 100%);
  max-height: 92vh;
  overflow-y: auto;
}
.modal-box h3 {
  font-family: 'Montserrat', sans-serif;
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 16px;
}
.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 34px; height: 34px;
  border-radius: 8px;
  font-size: 22px;
  color: var(--text-2);
  display: grid;
  place-items: center;
  transition: background 0.12s;
}
.modal-close:hover { background: #f2f3f6; }

/* Modal 3D */
.v3d-box { width: min(560px, 100%); }
.v3d-stage {
  height: 430px;
  background: linear-gradient(180deg, #f2f3f6 0%, #dfe1e7 100%);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  perspective: 1100px;
  display: grid;
  place-items: center;
  cursor: grab;
  touch-action: none;
}
.v3d-stage.dragging { cursor: grabbing; }
.v3d-stage img {
  width: 78%;
  max-height: 92%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
  will-change: transform;
}
.v3d-shade {
  position: absolute;
  inset: 0;
  background: #10111a;
  opacity: 0;
  pointer-events: none;
}
.v3d-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
}
.v3d-hint { font-size: 12px; color: var(--text-2); }

/* Modal Concluir */
.prev-grid { display: flex; gap: 14px; justify-content: center; }
.prev-grid figure { flex: 1; max-width: 220px; text-align: center; }
.prev-grid img {
  width: 100%;
  aspect-ratio: 460 / 496;
  object-fit: contain;
  background: #f2f3f6;
  border-radius: 10px;
}
.prev-grid figcaption {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-top: 6px;
}
.modal-desc { font-size: 13px; color: var(--text-2); line-height: 1.6; margin: 14px 0; }
.modal-info {
  background: #f6f6f9;
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.modal-info-row { display: flex; justify-content: space-between; font-size: 13px; }
.modal-info-row span { color: var(--text-2); }
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-wpp {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #25d366;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 13px;
  border-radius: 10px;
  transition: background 0.15s;
}
.btn-wpp:hover { background: #1fb857; }
.btn-ghost {
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: #fff;
  transition: background 0.12s;
}
.btn-ghost:hover { background: #f5f5f8; }

/* ══════════ RESPONSIVO ══════════ */
@media (max-width: 940px) {
  .st-body { flex-direction: column-reverse; }

  .st-rail {
    width: 100%;
    height: 62px;
    flex-direction: row;
    padding: 0;
  }
  .rail-btn {
    flex: 1;
    padding: 8px 2px;
    border-left: none;
    border-right: none;
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
    gap: 4px;
  }
  .rail-btn.active { border-top-color: var(--gold); border-left-color: transparent; }
  .rail-spacer { display: none; }

  .st-panel {
    position: fixed;
    left: 0; right: 0;
    bottom: 62px;
    top: auto;
    width: 100%;
    max-height: 54vh;
    background: var(--bg);
    box-shadow: 0 -8px 30px rgba(20, 21, 28, 0.25);
    border-radius: 16px 16px 0 0;
    padding: 40px 16px 16px;
    z-index: 80;
    transform: translateY(calc(100% + 70px));
    transition: transform 0.22s ease;
  }
  .st-panel.open { transform: translateY(0); }
  .panel-close {
    display: grid;
    place-items: center;
    position: absolute;
    top: 6px; right: 10px;
    width: 34px; height: 34px;
    font-size: 22px;
    color: var(--text-2);
  }

  .st-logo { font-size: 15px; }
  .st-back span { display: none; }

  .fl-tools { left: 10px; gap: 7px; }
  .fl-btn, .fl-mini { width: 44px; }
  .fl-btn { min-height: 44px; }
  .fl-mini { height: 32px; }

  .btn-baixar { top: 12px; right: 12px; padding: 8px 10px; }
  .side-toggle { right: 12px; bottom: 84px; }
  .side-btn { width: 64px; }
  .prod-thumbs { display: none; }
  .btn-concluir {
    right: 12px;
    bottom: 14px;
    padding: 13px 26px;
    font-size: 12px;
  }
  .cores-pop { left: 64px; width: min(292px, calc(100vw - 80px)); }

  .prev-grid { flex-wrap: wrap; }
  .v3d-stage { height: 320px; }
}
