/* ── Mockup Tool · Tool-specific styles ─────────────────
   Loads after tc-core.css which provides:
   reset, typography, buttons, modals, inputs, badges,
   toolbar, spinner, skeleton, empty-state, scrollbar
   ─────────────────────────────────────────────────────── */

/* ── Bridge: old var names → tc-core tokens ──────────── */
:root {
  --border-color: var(--tc-border-light);
  --border-radius: var(--tc-radius);
  --text-primary: var(--tc-text);
  --text-secondary: var(--tc-text-secondary);
  --bg-primary: var(--tc-bg-card);
  --bg-secondary: var(--tc-bg-subtle);
  --accent: var(--tc-text);
  --spacing-xs: var(--tc-space-xs);
  --spacing-sm: var(--tc-space-sm);
  --spacing-md: var(--tc-space-md);
  --spacing-lg: var(--tc-space-lg);
  --spacing-xl: var(--tc-space-xl);
}

/* ── App Layout ────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header (tool-specific parts) ──────────────────────── */
.header-left {
  display: flex;
  align-items: center;
  gap: var(--tc-space-sm);
}

.colorway-badge {
  display: none;
  background: var(--tc-bg-subtle);
  color: var(--tc-text);
  font-size: 13px;
  font-weight: 600;
  font-family: 'SF Mono', 'Menlo', monospace;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--tc-border-light);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--tc-space-sm);
}

/* ── Export Button (tool-specific CTA) ─────────────────── */
.btn-export {
  background: var(--tc-accent);
  color: var(--tc-accent-text);
  font-weight: 600;
  padding: 10px 20px;
  font-size: 14px;
}
.btn-export:hover:not(:disabled) { background: var(--tc-accent-hover); }
.btn-export:disabled { opacity: 0.5; }

/* ── Product Toolbar ───────────────────────────────────── */
.product-toolbar {
  background: var(--tc-bg-card);
  border-bottom: 1px solid var(--tc-border-light);
  padding: var(--tc-space-sm) var(--tc-space-lg);
  display: flex;
  align-items: flex-end;
  gap: var(--tc-space-md);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.product-mode-tabs {
  display: flex;
  background: var(--tc-bg-subtle);
  border-radius: 10px;
  padding: 4px;
  flex-shrink: 0;
  align-self: center;
}

.mode-tab {
  background: transparent;
  border: none;
  padding: 7px 14px;
  cursor: pointer;
  color: var(--tc-text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--tc-radius-sm);
  transition: all var(--tc-transition-slow);
}

.mode-tab.active {
  background: var(--tc-accent);
  color: var(--tc-accent-text);
  box-shadow: var(--tc-shadow-sm);
}

.mode-tab:hover:not(.active) {
  color: var(--tc-text);
}

.product-pick-controls {
  display: flex;
  gap: var(--tc-space-sm);
  flex: 1;
  align-items: flex-end;
  flex-wrap: wrap;
}

.product-upload-controls {
  display: flex;
  align-items: center;
  gap: var(--tc-space-sm);
  flex: 1;
}

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

/* ── Filter Fields ─────────────────────────────────────── */
.filter-field {
  min-width: 140px;
}

.filter-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--tc-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-field input,
.filter-field select {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid var(--tc-border);
  border-radius: var(--tc-radius-sm);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--tc-transition-slow), box-shadow var(--tc-transition-slow);
  background: var(--tc-bg-card);
}

.filter-field input:focus,
.filter-field select:focus {
  border-color: var(--tc-text-secondary);
  box-shadow: 0 0 0 3px var(--tc-focus-ring);
}

.filter-field select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.filter-field-product {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.filter-field-color {
  min-width: 160px;
}

/* ── Product Dropdown ──────────────────────────────────── */
.dropdown-search {
  position: relative;
}

.dropdown-search input {
  width: 100%;
  padding-right: 32px;
}

.dropdown-search input.has-selection {
  background: var(--tc-bg-subtle);
  border-color: var(--tc-text-secondary);
  font-weight: 600;
}

.dropdown-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 18px;
  color: var(--tc-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
}
.dropdown-clear:hover {
  background: var(--tc-border-light);
  color: var(--tc-text);
}

.dropdown-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 300px;
  overflow-y: auto;
  background: var(--tc-bg-card);
  border: 1px solid var(--tc-border-light);
  border-top: none;
  border-radius: 0 0 var(--tc-radius-sm) var(--tc-radius-sm);
  box-shadow: var(--tc-shadow-md);
  z-index: 100;
}

.dropdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--tc-bg-subtle);
  transition: background .1s;
}
.dropdown-item:hover { background: var(--tc-bg-subtle); }
.dropdown-item:last-child { border-bottom: none; }

.dropdown-item-title {
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 8px;
}
.dropdown-item-sku {
  font-size: 11px;
  color: var(--tc-text-secondary);
  flex-shrink: 0;
  font-family: 'SF Mono', 'Menlo', monospace;
}
.dropdown-empty {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--tc-text-secondary);
  text-align: center;
}

/* ── Main Content ──────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ── Empty / Loading States ────────────────────────────── */
.empty-state {
  min-height: 50vh;
}

.empty-state-icon { margin-bottom: var(--tc-space-md); }

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  gap: var(--tc-space-md);
  color: var(--tc-text-secondary);
  font-size: 14px;
}

/* ── Workspace ─────────────────────────────────────────── */
.workspace {
  display: flex;
  gap: 0;
  flex: 1;
  min-height: 0;
}

.workspace-preview {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--tc-space-lg);
  overflow: auto;
}

.preview-container {
  position: relative;
  display: inline-block;
  max-width: 100%;
  background: var(--tc-bg-subtle);
  border-radius: var(--tc-radius);
  overflow: visible;
}

.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--tc-space-sm);
  padding: 80px 40px;
  color: var(--tc-text-secondary);
  font-size: 14px;
  min-width: 400px;
  min-height: 300px;
}

.preview-product-image {
  max-width: 100%;
  max-height: calc(100vh - 260px);
  display: block;
  object-fit: contain;
  border-radius: var(--tc-radius);
}

/* ── Logo Overlay ──────────────────────────────────────── */
.logo-overlay {
  position: absolute;
  cursor: move;
  z-index: 10;
  outline: 1px dashed rgba(26, 46, 26, 0.2);
  transition: outline-color .15s;
}
.logo-overlay:hover {
  outline: 2px dashed rgba(26, 46, 26, 0.45);
}

.logo-overlay svg {
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.logo-resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--tc-bg-card);
  border: 2px solid var(--tc-text);
  border-radius: 50%;
  z-index: 11;
  opacity: 0;
  transition: opacity .15s;
}
.logo-overlay:hover .logo-resize-handle { opacity: 1; }

.logo-resize-tl { top: -5px; left: -5px; cursor: nwse-resize; }
.logo-resize-tr { top: -5px; right: -5px; cursor: nesw-resize; }
.logo-resize-bl { bottom: -5px; left: -5px; cursor: nesw-resize; }
.logo-resize-br { bottom: -5px; right: -5px; cursor: nwse-resize; }

.logo-resize-handle:hover {
  transform: scale(1.3);
  opacity: 1;
}

/* ── Sidebar ───────────────────────────────────────────── */
.workspace-sidebar {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  border-left: 1px solid var(--tc-border-light);
  background: var(--tc-bg-card);
  max-height: calc(100vh - 180px);
  overflow-y: auto;
}

.sidebar-section {
  padding: var(--tc-space-md);
  border-bottom: 1px solid var(--tc-border-light);
}

.sidebar-section:last-child { border-bottom: none; }

.section-heading {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--tc-text-secondary);
  margin-bottom: var(--tc-space-sm);
}

/* ── Logo Info ─────────────────────────────────────────── */
.logo-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--tc-space-xs) var(--tc-space-md);
}

.logo-info-field {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.logo-info-field.full { grid-column: 1 / -1; }

.logo-info-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--tc-text-secondary);
}

.logo-info-value {
  font-size: 13px;
  font-weight: 500;
  color: var(--tc-text);
}

.logo-info-value.mono {
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 12px;
}

/* ── Thread Layers ─────────────────────────────────────── */
.thread-layers {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--tc-bg-subtle);
  border-radius: 8px;
  padding: var(--tc-space-xs) var(--tc-space-sm);
}

.thread-layer {
  display: flex;
  align-items: center;
  gap: var(--tc-space-sm);
  padding: var(--tc-space-xs) 0;
  border-bottom: 1px solid var(--tc-border-light);
  cursor: pointer;
  position: relative;
}

.thread-layer:first-child { padding-top: 0; }
.thread-layer:last-child { border-bottom: none; padding-bottom: 0; }

.thread-layer:hover .thread-swatch {
  border-color: var(--tc-text);
}

.thread-swatch {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 4px;
  border: 2px solid var(--tc-border-light);
  flex-shrink: 0;
  transition: border-color var(--tc-transition-slow);
}

.thread-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--tc-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.thread-code {
  font-size: 11px;
  color: var(--tc-text-secondary);
  font-family: 'SF Mono', 'Menlo', monospace;
  flex-shrink: 0;
  text-align: right;
}

/* ── Thread Picker (inline dropdown) ───────────────────── */
.thread-picker {
  position: absolute;
  top: 100%;
  left: -12px;
  right: -12px;
  min-width: 260px;
  max-height: 320px;
  overflow: hidden;
  margin-top: 4px;
  background: var(--tc-bg-card);
  border: 1px solid var(--tc-border-light);
  border-radius: var(--tc-radius);
  box-shadow: var(--tc-shadow-md);
  z-index: 200;
  display: flex;
  flex-direction: column;
}

.thread-picker-search {
  padding: var(--tc-space-xs);
  border-bottom: 1px solid var(--tc-border-light);
  flex-shrink: 0;
}

.thread-picker-search input {
  width: 100%;
  border: 1px solid var(--tc-border);
  border-radius: var(--tc-radius-xs);
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
}

.thread-picker-list {
  overflow-y: auto;
  flex: 1;
  padding: 4px 0;
}

.thread-picker-section-label {
  padding: var(--tc-space-xs) var(--tc-space-sm);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--tc-text-secondary);
}

.thread-picker-item {
  display: flex;
  align-items: center;
  gap: var(--tc-space-xs);
  padding: 6px var(--tc-space-sm);
  cursor: pointer;
  border-radius: 4px;
  margin: 0 4px;
  transition: background .1s;
}
.thread-picker-item:hover { background: var(--tc-bg-subtle); }

.thread-picker-swatch {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  border: 1px solid var(--tc-border-light);
  flex-shrink: 0;
}

.thread-picker-name {
  font-size: 12px;
  color: var(--tc-text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-picker-code {
  font-size: 10px;
  color: var(--tc-text-secondary);
  flex-shrink: 0;
}

.thread-picker-empty,
.thread-picker-loading {
  padding: var(--tc-space-md);
  text-align: center;
  color: var(--tc-text-secondary);
  font-size: 13px;
}

/* ── Placement Controls ────────────────────────────────── */
.placement-controls {
  display: flex;
  flex-direction: column;
  gap: var(--tc-space-sm);
}

.placement-row {
  display: flex;
  align-items: center;
  gap: var(--tc-space-xs);
}

.placement-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--tc-text-secondary);
  min-width: 50px;
}

.placement-input {
  width: 70px;
  padding: 5px 8px;
  border: 1px solid var(--tc-border);
  border-radius: var(--tc-radius-xs);
  font-size: 13px;
  font-family: 'SF Mono', 'Menlo', monospace;
}

.placement-unit {
  font-size: 12px;
  color: var(--tc-text-secondary);
}

.placement-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--tc-border-light);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.placement-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--tc-bg-card);
  border: 2px solid var(--tc-text);
  border-radius: 50%;
  cursor: pointer;
}
.placement-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--tc-bg-card);
  border: 2px solid var(--tc-text);
  border-radius: 50%;
  cursor: pointer;
}

.placement-value {
  font-size: 11px;
  font-family: 'SF Mono', 'Menlo', monospace;
  color: var(--tc-text);
  min-width: 36px;
  text-align: right;
}

.placement-coords {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px var(--tc-space-md);
  padding: var(--tc-space-xs) 0;
  margin-top: var(--tc-space-xs);
  border-top: 1px solid var(--tc-border-light);
}

.coord-item {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}
.coord-key {
  font-weight: 600;
  color: var(--tc-text-secondary);
}
.coord-val {
  font-family: 'SF Mono', 'Menlo', monospace;
  color: var(--tc-text);
}

/* ── Action Bar ────────────────────────────────────────── */
.action-bar {
  background: var(--tc-bg-card);
  border-top: 1px solid var(--tc-border-light);
  padding: var(--tc-space-sm) var(--tc-space-lg);
  display: flex;
  align-items: center;
  gap: var(--tc-space-md);
  flex-shrink: 0;
}

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

/* ── Type Badge ────────────────────────────────────────── */
.type-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.type-embroidery { background: #dbeafe; color: #1d4ed8; }
.type-printing   { background: #dcfce7; color: #16a34a; }
.type-laser      { background: #ffedd5; color: #ea580c; }
.type-uv         { background: #ede9fe; color: #7c3aed; }
.type-heat       { background: #fee2e2; color: #dc2626; }
.type-default    { background: var(--tc-bg-subtle); color: var(--tc-text-secondary); }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 900px) {
  .workspace {
    flex-direction: column;
  }

  .workspace-sidebar {
    width: 100%;
    max-height: none;
    border-left: none;
    border-top: 1px solid var(--tc-border-light);
  }

  .preview-placeholder {
    min-width: 250px;
    min-height: 200px;
    padding: 40px 20px;
  }
}

@media (max-width: 700px) {
  .product-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .product-pick-controls {
    flex-direction: column;
  }

  .filter-field { min-width: 100%; }
}
