/* ═══════════════════════════════════════════════════════
   Bousba Deco — Color Picker & Pattern Builder
   ═══════════════════════════════════════════════════════ */

/* ── Layout ─── */
.cp-page { background: var(--bg); }

.cp-toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
.cp-toolbar__inner {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.cp-toolbar__inner::-webkit-scrollbar { display: none; }

/* ── Family Tabs ─── */
.cp-family-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border);
  background: var(--card);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-body-ar);
  white-space: nowrap;
}
.cp-family-btn:hover { border-color: var(--accent); }
.cp-family-btn.active {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}
.cp-family-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.08);
}

/* ── Selected Color Display ─── */
.cp-selected {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
  align-items: center;
}
.cp-selected__preview {
  aspect-ratio: 1;
  max-height: 280px;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 40px rgba(0,0,0,0.12);
  transition: background-color 0.3s ease;
  position: relative;
  overflow: hidden;
}
.cp-selected__preview::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(0,0,0,0.06);
  pointer-events: none;
}
.cp-selected__info { direction: rtl; }
.cp-selected__name {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
  font-family: var(--font-heading-ar);
}
.cp-selected__hex {
  font-size: 1.1rem;
  color: var(--muted-fg);
  font-family: 'Inter', monospace;
  direction: ltr;
  margin-bottom: var(--space-md);
}
.cp-selected__meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: var(--space-md);
}
.cp-selected__meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: var(--muted);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.cp-selected__meta-label { color: var(--muted-fg); }
.cp-selected__meta-value { font-weight: 600; font-family: 'Inter', monospace; direction: ltr; }

.cp-add-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-body-ar);
}
.cp-add-btn:hover { background: #b45309; transform: translateY(-1px); }
.cp-add-btn:active { transform: translateY(0); }

/* ── Swatch Grid ─── */
.cp-grid-section { margin-top: var(--space-lg); }
.cp-grid-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted-fg);
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cp-swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 4px;
}
.cp-swatch {
  aspect-ratio: 1;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s ease;
  position: relative;
}
.cp-swatch:hover {
  transform: scale(1.25);
  z-index: 10;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  border-color: #fff;
}
.cp-swatch.active {
  border-color: var(--primary);
  transform: scale(1.3);
  z-index: 11;
  box-shadow: 0 0 0 3px var(--primary), 0 4px 20px rgba(0,0,0,0.25);
}
.cp-swatch[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;
}

/* ── Brightness/Saturation Sliders ─── */
.cp-sliders {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: var(--space-md) 0;
}
.cp-slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cp-slider-row label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted-fg);
  min-width: 70px;
}
.cp-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 8px;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}
.cp-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  cursor: pointer;
}
.cp-slider-val {
  font-size: 0.8rem;
  font-weight: 600;
  font-family: 'Inter', monospace;
  min-width: 36px;
  text-align: center;
}

/* ── Palette Builder ─── */
.cp-palette-section {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: var(--space-lg);
  margin-top: var(--space-xl);
}
.cp-palette-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}
.cp-palette-header h3 {
  font-size: 1.2rem;
  font-family: var(--font-heading-ar);
}
.cp-palette-strip {
  display: flex;
  gap: 8px;
  min-height: 80px;
  align-items: stretch;
  flex-wrap: wrap;
}
.cp-palette-chip {
  flex: 1;
  min-width: 60px;
  max-width: 120px;
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 100px;
}
.cp-palette-chip:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,0.15); }
.cp-palette-chip__info {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  padding: 8px;
  color: #fff;
  font-size: 0.72rem;
  text-align: center;
}
.cp-palette-chip__remove {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}
.cp-palette-chip:hover .cp-palette-chip__remove { opacity: 1; }

.cp-palette-empty {
  width: 100%;
  text-align: center;
  padding: var(--space-lg);
  color: var(--muted-fg);
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
}
.cp-palette-actions {
  display: flex;
  gap: 10px;
  margin-top: var(--space-md);
  flex-wrap: wrap;
}

/* ── Room Preview ─── */
.cp-room-section {
  margin-top: var(--space-xl);
}
.cp-room-wrap {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: var(--space-lg);
  text-align: center;
}
.cp-room-svg {
  max-width: 600px;
  margin: 0 auto;
}
.cp-room-svg svg { width: 100%; height: auto; }
.cp-room-zone {
  cursor: pointer;
  transition: fill 0.3s ease;
  stroke: rgba(0,0,0,0.15);
  stroke-width: 1;
}
.cp-room-zone:hover {
  filter: brightness(0.92);
  stroke: var(--primary);
  stroke-width: 2;
}
.cp-room-labels {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  margin-top: var(--space-md);
  flex-wrap: wrap;
}
.cp-room-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  transition: all 0.2s;
}
.cp-room-label.active { border-color: var(--accent); background: rgba(217,119,6,0.06); }
.cp-room-label__dot {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.1);
}

/* ── Responsive ─── */
@media (max-width: 768px) {
  .cp-selected { grid-template-columns: 1fr; }
  .cp-selected__preview { max-height: 200px; aspect-ratio: 16/9; }
  .cp-swatch-grid { grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 3px; }
  .cp-palette-chip { min-width: 50px; min-height: 80px; }
  .cp-palette-strip { gap: 6px; }
}
@media (max-width: 480px) {
  .cp-swatch-grid { grid-template-columns: repeat(auto-fill, minmax(32px, 1fr)); gap: 2px; }
}
