/* =========================================
   COLOR PALETTE BUILDER — style.css
   Matches design system:
   white cards, #061d33 text, #ff9901 accent
   ========================================= */

:root {
  --primary:        #ff9901;
  --primary-hover:  #e68a00;
  --primary-light:  #fff7e6;
  --dark:           #061d33;
  --mid:            #4a5568;
  --muted:          #9ca3af;
  --border:         #e2e8f0;
  --bg:             #f7f8fa;
  --white:          #ffffff;
  --radius:         10px;
  --radius-sm:      6px;
  --shadow:         0 4px 10px rgba(0,0,0,0.1);
  --font-body:      'DM Sans', sans-serif;
  --font-mono:      'IBM Plex Mono', monospace;
}

/* ---- APP WRAPPER ---- */
.cp-app {
  width: 100%;
  margin-bottom: 40px;
}

.cp-app .app-container.cp-container {
  max-width: 820px;
  padding: 0;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: block;
  margin: auto;
}

/* ---- BUILDER ---- */
.cp-builder {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  border-bottom: 1px solid var(--border);
}

/* ---- WHEEL COLUMN ---- */
.cp-wheel-col {
  padding: 28px 24px 24px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: var(--bg);
}

.cp-wheel-wrap {
  position: relative;
  width: 260px;
  height: 260px;
  flex-shrink: 0;
}

#cpWheel {
  border-radius: 50%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.cp-wheel-dots {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.cp-wheel-dot {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 1.5px rgba(0,0,0,0.25), 0 2px 6px rgba(0,0,0,0.2);
  transform: translate(-50%, -50%);
  pointer-events: all;
  cursor: grab;
  transition: box-shadow 0.1s, transform 0.1s;
  box-sizing: border-box;
}

.cp-wheel-dot:hover {
  box-shadow: 0 0 0 2px rgba(0,0,0,0.35), 0 3px 10px rgba(0,0,0,0.25);
  transform: translate(-50%, -50%) scale(1.15);
}

.cp-wheel-dot.active {
  width: 22px;
  height: 22px;
  border-width: 3px;
  box-shadow: 0 0 0 2.5px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.3);
  transform: translate(-50%, -50%) scale(1.1);
  z-index: 10;
  cursor: grabbing;
}

.cp-wheel-dot.dragging {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.2);
}

/* ---- SLIDERS ---- */
.cp-brightness-wrap,
.cp-saturation-wrap {
  width: 100%;
}

.cp-slider-label {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 6px;
}

.cp-brightness-track,
.cp-saturation-track {
  position: relative;
  height: 18px;
  border-radius: 9px;
  overflow: hidden;
  cursor: pointer;
  touch-action: none;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.15);
}

.cp-brightness-track canvas,
.cp-saturation-track canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.cp-brightness-thumb,
.cp-saturation-thumb {
  position: absolute;
  top: 50%;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--white);
  border: 2.5px solid var(--white);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: box-shadow 0.1s;
}

/* ---- CONTROLS COLUMN ---- */
.cp-controls-col {
  padding: 28px 24px 24px;
  display: flex;
  flex-direction: column;
}

.cp-section-label {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* ---- HARMONY BUTTONS ---- */
.cp-harmony-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cp-harmony-btn {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  color: var(--mid);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 5px 11px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.cp-harmony-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.cp-harmony-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

/* ---- SWATCHES ---- */
.cp-swatches {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.cp-swatch {
  flex: 1;
  height: 52px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.cp-swatch:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}

.cp-swatch.active {
  transform: translateY(-3px);
  box-shadow: 0 0 0 2.5px var(--dark), 0 4px 12px rgba(0,0,0,0.2);
}

.cp-swatch-hex {
  position: absolute;
  bottom: 4px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.cp-swatch:hover .cp-swatch-hex,
.cp-swatch.active .cp-swatch-hex {
  opacity: 1;
}

/* ---- HEX INPUT ROW ---- */
.cp-hex-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
}

.cp-active-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.cp-hex-hash {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  flex-shrink: 0;
}

.cp-hex-input {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--dark);
  border: none;
  background: transparent;
  outline: none;
  flex: 1;
  min-width: 0;
  text-transform: uppercase;
}

.cp-copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 2px 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
  flex-shrink: 0;
}

.cp-copy-btn:hover { color: var(--dark); }

/* ---- SAVE ROW ---- */
.cp-save-row {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.cp-name-input {
  flex: 1;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--dark);
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s;
}

.cp-name-input:focus {
  border-color: var(--primary);
}

.cp-name-input::placeholder {
  color: var(--muted);
}

.cp-save-btn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  flex-shrink: 0;
}

.cp-save-btn:hover {
  background: var(--primary-hover);
}

/* ---- SAVED PALETTES SECTION ---- */
.cp-saved-section {
  padding: 24px;
}

.cp-saved-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.cp-palette-count {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.cp-palettes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

/* ---- EMPTY STATE ---- */
.cp-empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 20px;
  color: var(--muted);
  text-align: center;
}

.cp-empty-state p {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

/* ---- PALETTE CARD ---- */
.cp-palette-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.cp-palette-card:hover {
  box-shadow: var(--shadow);
  border-color: #d1d5db;
}

.cp-palette-strip {
  display: flex;
  height: 56px;
}

.cp-palette-strip-swatch {
  flex: 1;
  position: relative;
  cursor: pointer;
  transition: flex 0.2s;
}

.cp-palette-strip-swatch:hover {
  flex: 1.4;
}

.cp-palette-strip-swatch .cp-copy-tooltip {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
  white-space: nowrap;
}

.cp-palette-strip-swatch:hover .cp-copy-tooltip {
  opacity: 1;
}

.cp-palette-meta {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cp-palette-name {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  color: var(--dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.cp-palette-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.cp-palette-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 3px 5px;
  border-radius: 4px;
  font-size: 11px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}

.cp-palette-action-btn:hover {
  color: var(--dark);
  background: var(--bg);
}

.cp-palette-action-btn.delete:hover {
  color: #e53e3e;
  background: #fff5f5;
}

/* ---- TOAST ---- */
.cp-toast {
  position: fixed;
  bottom: 58px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--primary);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
}

.cp-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- RESPONSIVE ---- */
@media (max-width: 640px) {
  .cp-builder {
    grid-template-columns: 1fr;
  }

  .cp-wheel-col {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 20px 16px;
  }

  .cp-wheel-wrap {
    width: 220px;
    height: 220px;
  }

  #cpWheel {
    width: 220px;
    height: 220px;
  }

  .cp-controls-col {
    padding: 20px 16px;
  }

  .cp-saved-section {
    padding: 16px;
  }

  .cp-palettes-grid {
    grid-template-columns: 1fr;
  }

  .cp-save-row {
    flex-direction: column;
  }
}