/* Shared shell, panel and control styles for every template editor. */

:root {
  --bg-app: #f6f5f2;
  --bg-header: #fffefb;
  --bg-canvas-area: #eceae5;
  --border: #e3e0d9;
  --border-soft: #efece6;
  --text-primary: #1a1a18;
  --text-secondary: #78766e;
  --text-tertiary: #8a887f;
  --text-quaternary: #a2a099;
  --on-dark: #fbfaf7;
  --chip-border: #e6e3dc;
  --chip-bg: #fafaf7;
  --input-border: #d7d3cb;
  --dropzone-border: #cfcbc2;
  --danger: #b3261e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg-canvas-area);
}

body {
  font-family: 'Be Vietnam Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  color: var(--text-primary);
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

.app {
  height: 100dvh;
  overflow: hidden;
  min-width: 1180px;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
}

/* Topbar */

.topbar {
  min-height: 56px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-header);
  white-space: nowrap;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-mark {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  background: var(--text-primary);
}

.app-name {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  text-decoration: none;
}

.divider {
  width: 1px;
  height: 20px;
  background: var(--border);
}

.breadcrumb {
  font-size: 13px;
  color: var(--text-secondary);
}

.breadcrumb .sep { color: #c3c0b8; }
.breadcrumb .current { color: var(--text-primary); font-weight: 700; }
.breadcrumb .breadcrumb-placeholder { color: var(--text-quaternary); }

.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
}

.breadcrumb a:hover { color: var(--text-primary); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.save-indicator {
  font-size: 12px;
  color: var(--text-tertiary);
  font-family: 'JetBrains Mono', monospace;
}

.link-btn {
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  background: #fff;
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
}

.link-btn:hover { background: #f7f6f3; }

/* Main grid */

.main-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 440px 1fr;
  min-height: 0;
}

/* Steps panel */

.panel-steps {
  border-right: 1px solid var(--border);
  background: var(--bg-header);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-steps-header {
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--border-soft);
}

.panel-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.panel-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  padding-top: 5px;
  line-height: 1.5;
}

.panel-steps-body {
  flex: 1;
  overflow: auto;
  padding: 22px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.step-sep {
  height: 1px;
  background: var(--border-soft);
}

.step {
  display: flex;
  gap: 14px;
}

.step-num {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--text-primary);
  color: var(--on-dark);
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.step-head-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.step-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.step-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  padding-top: 3px;
}

.step-counter {
  font-size: 11px;
  color: var(--text-quaternary);
  white-space: nowrap;
}

/* Generic segmented toggle — size mode, image version, image fit */

.segmented {
  display: flex;
  align-self: flex-start;
  border: 1px solid var(--chip-border);
  border-radius: 4px;
  overflow: hidden;
}

.segmented-btn {
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border: none;
  background: var(--chip-bg);
  color: #b3b0a8;
  cursor: pointer;
  font-family: inherit;
}

.segmented-btn + .segmented-btn {
  border-left: 1px solid var(--chip-border);
}

.segmented-btn.active {
  background: var(--text-primary);
  color: var(--on-dark);
}

.segmented-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Dropzones */

.dropzone {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1px dashed var(--dropzone-border);
  border-radius: 5px;
  background: repeating-linear-gradient(135deg, #f2f0ec 0 8px, #eae7e1 8px 16px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  text-align: center;
  padding: 0 12px;
  overflow: hidden;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.dropzone.dropzone-small {
  width: 140px;
  background: repeating-linear-gradient(135deg, #f7f6f3 0 8px, #efece6 8px 16px);
}

.detail-dropzones {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.dropzone.dropzone-detail {
  background: repeating-linear-gradient(135deg, #f7f6f3 0 8px, #efece6 8px 16px);
  padding: 0 4px;
  gap: 3px;
}

.dropzone.dropzone-detail .dropzone-icon {
  font-size: 13px;
}

.dropzone.dropzone-detail .dropzone-text {
  font-size: 9px;
}

.dropzone.dragover {
  border-color: var(--text-primary);
  background-color: #eceae4;
}

.dropzone-icon {
  font-size: 15px;
  color: var(--text-tertiary);
}

.dropzone-text {
  font-size: 11px;
  color: var(--text-secondary);
}

.file-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-secondary);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  font-size: 11px;
  color: var(--text-quaternary);
}

.dropzone-filled {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.dropzone-thumb {
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: contain;
  background-color: #fafaf7;
  background-image:
    linear-gradient(45deg, #e6e3dc 25%, transparent 25%),
    linear-gradient(-45deg, #e6e3dc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e6e3dc 75%),
    linear-gradient(-45deg, transparent 75%, #e6e3dc 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0px;
}

.dropzone-caption {
  flex: none;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  background: rgba(20, 20, 18, 0.72);
}

.dropzone-caption .file-name {
  color: #fff;
  flex: 1;
  min-width: 0;
}

.dropzone-caption .file-meta {
  color: rgba(255, 255, 255, 0.7);
  flex: none;
  white-space: nowrap;
}

/* One self-contained upload slot: dropzone + actions + AI background row */

.image-slot {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.image-slot-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

/* Inputs */

.text-input, .text-area {
  width: 100%;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  padding: 10px 12px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  background: #fff;
}

.text-area {
  resize: vertical;
  min-height: 68px;
  line-height: 1.5;
}

.text-input::placeholder, .text-area::placeholder {
  color: var(--text-quaternary);
}

.text-input:focus, .text-area:focus {
  outline: none;
  border-color: var(--text-primary);
}

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

.btn-secondary {
  flex: 1;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  padding: 9px 0;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-primary);
}

.btn-secondary:hover { background: #f7f6f3; }

.btn-ghost {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  padding: 9px 14px;
  border: 1px solid var(--chip-border);
  border-radius: 4px;
  color: var(--text-tertiary);
  background: var(--chip-bg);
  cursor: pointer;
  font-family: inherit;
}

.btn-ghost:hover { color: var(--text-primary); }

.btn-secondary:disabled, .btn-ghost:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Chips — product type and sizes */

.product-type-chips, .size-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-size: 13px;
  font-weight: 800;
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid var(--chip-border);
  color: #b3b0a8;
  background: var(--chip-bg);
  cursor: pointer;
  font-family: inherit;
  user-select: none;
  transition: transform 0.1s ease;
}

.chip:active { transform: scale(0.94); }

.chip.active {
  background: var(--text-primary);
  color: var(--on-dark);
  border-color: var(--text-primary);
}

/* Zoom + pan row */

.zoom-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-step {
  flex: none;
  width: 28px;
  height: 28px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  background: #fff;
  color: var(--text-primary);
  cursor: pointer;
  font-family: inherit;
}

.btn-step:hover { background: #f7f6f3; }

.zoom-slider {
  flex: 1;
  min-width: 0;
  accent-color: var(--text-primary);
}

.zoom-value {
  flex: none;
  width: 42px;
  text-align: right;
  font-size: 11px;
  color: var(--text-secondary);
}

.zoom-row .btn-ghost {
  flex: none;
  padding: 6px 10px;
}

.preview-canvas-wrap.pannable canvas { cursor: grab; }
.preview-canvas-wrap.panning canvas { cursor: grabbing; }

/* Background removal */

.bg-remove-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mono-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-quaternary);
}

.mono-hint-error {
  color: var(--danger);
}

/* Preview area */

.btn-export {
  flex: none;
  font-size: 14px;
  padding: 12px 26px;
  border-radius: 4px;
  border: none;
  background: var(--text-primary);
  color: var(--on-dark);
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s ease, background-color 0.15s ease;
}

.btn-export:hover { background: #333330; }
.btn-export:active { transform: scale(0.97); }

.preview-area {
  background: var(--bg-canvas-area);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px;
  position: relative;
  min-height: 0;
  overflow: auto;
}

.preview-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.preview-canvas-wrap {
  flex: none;
  height: min(540px, 100%);
  width: auto;
  max-width: 100%;
  background: #ffffff;
  border: 1px solid #dedbd4;
  box-shadow: 0 18px 40px rgba(26, 26, 24, 0.10);
  display: flex;
}

.preview-canvas-wrap canvas {
  display: block;
}
