/* ═══════════════════════════════════════════════════════════════════════════
   PrintCraft — designer.css  v1.0.0
   Designer layout, toolbar, canvas, properties panel, color picker
═══════════════════════════════════════════════════════════════════════════ */

/* ─── Designer Shell ─────────────────────────────────────────────────────── */
#pc-designer {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: var(--bg-base);
  overflow: hidden;
}

/* ─── Left Toolbar ───────────────────────────────────────────────────────── */
#pc-toolbar {
  width: var(--toolbar-w);
  flex-shrink: 0;
  background: var(--bg-nav);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 2px;
  overflow: hidden;
}

.tool-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding-bottom: 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
  width: 100%;
  padding-left: 4px;
  padding-right: 4px;
}
.tool-group:last-child { border-bottom: none; }
.tool-group-bottom { margin-top: auto; }

.tool-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background 0.1s, color 0.1s;
  flex-shrink: 0;
}
.tool-btn svg { width: 18px; height: 18px; }
.tool-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.tool-btn.active { background: var(--accent-dim); color: var(--accent); }

/* ─── Canvas Area ────────────────────────────────────────────────────────── */
#pc-canvas-area {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Context Bar */
#pc-context-bar {
  height: 40px;
  flex-shrink: 0;
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
}
#pc-context-bar::-webkit-scrollbar { height: 2px; }
#pc-context-bar::-webkit-scrollbar-thumb { background: var(--border-light); }

.ctx-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.ctx-group + .ctx-group { padding-left: 8px; border-left: 1px solid var(--border); }

#ctxFont {
  height: 28px;
  padding: 0 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  min-width: 130px;
  outline: none;
}
#ctxFont:focus { border-color: var(--accent); }

#ctxFontSize {
  width: 50px; height: 28px;
  padding: 0 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: center;
  outline: none;
}
#ctxFontSize:focus { border-color: var(--accent); }
#ctxFontSize::-webkit-inner-spin-button { display: none; }

.ctx-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  transition: background 0.1s, color 0.1s;
}
.ctx-btn svg { width: 14px; height: 14px; }
.ctx-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.ctx-btn.active { background: var(--accent-dim); color: var(--accent); }

.ctx-sep { width: 1px; height: 20px; background: var(--border); margin: 0 2px; }

.ctx-swatch-wrap { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-muted); }
.ctx-swatch {
  width: 22px; height: 22px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
}
.ctx-swatch .swatch-inner { width: 100%; height: 100%; }
.ctx-swatch:hover { border-color: var(--accent); }

#ctxStrokeW {
  width: 44px; height: 28px;
  padding: 0 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: center;
  outline: none;
}
#ctxStrokeW::-webkit-inner-spin-button { display: none; }

/* Canvas scroller */
#pc-canvas-wrap {
  flex: 1 1 0;
  overflow: hidden;
  position: relative;
  min-height: 0;
}
#pc-canvas-scroller {
  width: 100%;
  height: 100%;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  background: #111114;
  background-image:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 20px 20px;
}
#pc-canvas-scroller::-webkit-scrollbar { width: 6px; height: 6px; }
#pc-canvas-scroller::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

#pc-canvas-container {
  position: relative;
  flex-shrink: 0;
  margin: 40px;
}

#pc-canvas {
  display: block;
  box-shadow: 0 0 0 1px var(--border-light), 0 8px 40px rgba(0,0,0,0.6);
  background: #fff;
}

/* Status Bar */
#pc-status-bar {
  height: var(--status-h);
  flex-shrink: 0;
  background: var(--bg-nav);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.status-sep { color: var(--border-light); }
#statusProduct { color: var(--text-secondary); }

.status-zoom {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.status-zoom button {
  width: 20px; height: 20px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.1s;
}
.status-zoom button:hover { background: var(--bg-active); color: var(--text-primary); }
#zoomSlider {
  width: 90px;
  accent-color: var(--accent);
  cursor: pointer;
}
#zoomLabel { min-width: 36px; text-align: right; }

/* ─── Right Properties Panel ─────────────────────────────────────────────── */
#pc-props {
  flex-shrink: 0;
  width: var(--props-w);
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: row;
  overflow: hidden;
  position: relative;
  min-width: 180px;
  max-width: 480px;
}
.props-resize-handle {
  width: 5px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  transition: background 0.15s;
}
.props-resize-handle:hover { background: var(--accent); }

#pc-props-inner {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 0 20px 0;
}
#pc-props-inner::-webkit-scrollbar { width: 3px; }
#pc-props-inner::-webkit-scrollbar-thumb { background: var(--border); border-radius: 1px; }

.props-section {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.props-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.props-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.props-row label {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 56px;
  flex-shrink: 0;
}
.props-grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}
.props-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.props-field label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.props-field input {
  height: 30px;
  padding: 0 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: center;
  width: 100%;
  min-width: 0;
  outline: none;
  -moz-appearance: textfield;
}
.props-field input:focus { border-color: var(--accent); }
.props-field input::-webkit-inner-spin-button { display: none; }

.props-select-full {
  width: 100%;
  height: 30px;
  padding: 0 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  outline: none;
}
.props-select-full:focus { border-color: var(--accent); }

.props-hex {
  flex: 1;
  height: 30px;
  padding: 0 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  min-width: 0;
  outline: none;
}
.props-hex:focus { border-color: var(--accent); }

.props-unit { font-size: 11px; color: var(--text-muted); }

.props-style-row {
  display: flex;
  gap: 3px;
  margin-bottom: 8px;
}
.style-btn {
  width: 30px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.style-btn svg { width: 14px; height: 14px; }
.style-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.style-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* Fill tabs */
.props-fill-row { justify-content: space-between; }
.fill-toggle {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.fill-tab {
  height: 26px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background 0.1s, color 0.1s;
}
.fill-tab.active { background: var(--accent); color: #fff; }

/* Swatch */
.color-swatch-btn {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
  background-image: linear-gradient(45deg, #555 25%, transparent 25%),
                    linear-gradient(-45deg, #555 25%, transparent 25%),
                    linear-gradient(45deg, transparent 75%, #555 75%),
                    linear-gradient(-45deg, transparent 75%, #555 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
}
.color-swatch-btn:hover { border-color: var(--accent); }
.swatch-inner { width: 100%; height: 100%; }

/* Gradient editor */
.grad-bar-wrap {
  position: relative;
  margin-bottom: 4px;
}
#gradBar {
  width: 100%;
  height: 20px;
  border-radius: var(--radius-sm);
  cursor: crosshair;
  border: 1px solid var(--border-light);
  display: block;
}
#gradStops {
  position: absolute;
  top: 20px;
  left: 0; right: 0;
  height: 18px;
  pointer-events: none;
}
.grad-stop-handle {
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5);
  transform: translateX(-50%);
  cursor: pointer;
  pointer-events: all;
  transition: box-shadow 0.1s;
  top: 2px;
}
.grad-stop-handle.selected { box-shadow: 0 0 0 2px var(--accent); }
.grad-hint { font-size: 10px; color: var(--text-muted); margin-bottom: 8px; line-height: 1.4; }

.props-btn-full {
  width: 100%;
  height: 32px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  margin-top: 6px;
}
.props-btn-full:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ─── Custom Color Picker ─────────────────────────────────────────────────── */
#colorPickerPopover {
  position: fixed;
  width: 230px;
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  padding: 12px;
  user-select: none;
}

#cpField {
  position: relative;
  width: 100%;
  height: 150px;
  border-radius: var(--radius-sm);
  cursor: crosshair;
  margin-bottom: 10px;
  overflow: visible;
}
#cpFieldInner {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-sm);
}
#cpFieldHandle {
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

#cpHueTrack {
  position: relative;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(to right,
    #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000);
  margin-bottom: 8px;
  cursor: pointer;
}
#cpHueHandle {
  position: absolute;
  top: -2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
  transform: translateX(-50%);
  pointer-events: none;
}

#cpAlphaWrap { margin-bottom: 10px; }
#cpAlphaTrack {
  position: relative;
  height: 12px;
  border-radius: 6px;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, #888 25%, transparent 25%),
    linear-gradient(-45deg, #888 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #888 75%),
    linear-gradient(-45deg, transparent 75%, #888 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
}
#cpAlphaGrad {
  position: absolute;
  inset: 0;
  border-radius: 6px;
}
#cpAlphaHandle {
  position: absolute;
  top: -2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
  transform: translateX(-50%);
  pointer-events: none;
}

#cpInputRow {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 4px;
  margin-bottom: 2px;
}
#cpInputRow input {
  height: 26px;
  padding: 0 4px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: center;
  color: var(--text-primary);
  outline: none;
  width: 100%;
  -moz-appearance: textfield;
}
#cpInputRow input::-webkit-inner-spin-button { display: none; }
#cpInputRow input:focus { border-color: var(--accent); }

#cpInputLabels {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 4px;
  margin-bottom: 8px;
}
#cpInputLabels span {
  text-align: center;
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#cpRecent {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.cp-recent-swatch {
  width: 18px; height: 18px;
  border-radius: 3px;
  border: 1px solid var(--border-light);
  cursor: pointer;
  flex-shrink: 0;
}
.cp-recent-swatch:hover { border-color: var(--accent); transform: scale(1.1); }
