/*!
 * 123PhotoTool — Color Picker (color-picker.php).
 *
 * The page uses the shared tool layout (pt-ui.css) and, on a phone, the
 * full-screen editor (pt-app.css). This file is only what the picker adds:
 * the colour and its codes, the palette, the photo with its loupe, and
 * Saved Colors.
 */

/* ── The colour ────────────────────────────────────────────────────────── */
.cp-current { display: flex; gap: 12px; align-items: stretch; }
/* The swatch is the system colour chooser: its <input type=color> lies over
   it, so the tap that opens the chooser is a real tap on the input (iOS
   opens nothing for a scripted click). */
.cp-swatch {
  position: relative;
  flex: 0 0 104px;
  min-height: 104px;
  margin: 0;
  border-radius: var(--pt-radius-sm, 12px);
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
  cursor: pointer;
  overflow: hidden;
  transition: box-shadow 0.15s;
}
.cp-swatch:hover { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35), 0 0 0 3px var(--pt-accent-soft, rgba(15, 112, 230, 0.15)); }
.cp-swatch:focus-within { outline: 3px solid var(--pt-accent, #0f70e6); outline-offset: 2px; }
.cp-native {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}
.cp-swatch-hex {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  font: 600 0.78rem/1.2 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace);
  color: rgba(0, 0, 0, 0.72);
  text-align: center;
  pointer-events: none;
}
.cp-swatch-hex.cp-on-dark { color: rgba(255, 255, 255, 0.9); }
.cp-swatch-edit {
  position: absolute;
  top: 6px;
  inset-inline-end: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--pt-ink, #343f52);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}
.cp-swatch-edit svg { width: 14px; height: 14px; }

.cp-values { flex: 1 1 auto; min-width: 0; display: grid; gap: 6px; }
.cp-value {
  display: flex;
  align-items: stretch;
  height: 38px;
  border: 1px solid var(--pt-line, #e3e7ee);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.cp-value:focus-within { border-color: var(--pt-accent, #0f70e6); }
.cp-value-name {
  flex: 0 0 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-inline-end: 1px solid var(--pt-line, #e3e7ee);
  background: var(--pt-surface, #f6f8fb);
  color: var(--pt-muted, #6c757d);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.cp-value input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  padding: 0 8px;
  background: transparent;
  color: var(--pt-ink, #343f52);
  font: 0.82rem/1 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace);
  text-overflow: ellipsis;
  cursor: copy;
  outline: none;
}
.cp-copy {
  flex: 0 0 40px;
  border: 0;
  border-inline-start: 1px solid var(--pt-line, #e3e7ee);
  background: transparent;
  color: var(--pt-muted, #6c757d);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.cp-copy:hover, .cp-copy:focus-visible { color: var(--pt-accent, #0f70e6); background: var(--pt-accent-soft, rgba(15, 112, 230, 0.06)); }
.cp-copy svg { width: 16px; height: 16px; }
/* Copied: the button turns into a tick for a moment. */
.cp-copy .cp-tick, .cp-bar-copy .cp-tick { display: none; }
.cp-done { color: #198754 !important; }
.cp-copy.cp-done .cp-clip { display: none; }
.cp-copy.cp-done .cp-tick { display: block; }
@media (min-width: 768px) and (max-width: 991.98px) {
  .cp-swatch { flex-basis: 84px; min-height: 84px; }
}
/* Phone (the editor's sheet) and the desktop's 360px panel: the swatch is a
   bar above the codes, which get the full width ("cmyk(0%, 0%, 0%, 0%)"
   was cut to "cmyk(0%, 0…" beside it). */
@media (max-width: 575.98px), (min-width: 992px) {
  .cp-current { flex-direction: column; }
  .cp-swatch { flex: none; min-height: 56px; height: 56px; }
  .cp-swatch-hex { left: 48px; right: 48px; bottom: auto; top: 50%; transform: translateY(-50%); }
  .cp-swatch-edit { top: 50%; transform: translateY(-50%); inset-inline-end: 12px; }
}

/* ── Palette ───────────────────────────────────────────────────────────── */
.cp-palette-controls { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.cp-palette-controls .form-select { flex: 1 1 55%; min-width: 0; }
.cp-count { flex: 1 1 45%; min-width: 0; display: flex; align-items: center; gap: 8px; }
.cp-count .form-label { margin: 0; white-space: nowrap; font-size: 0.875rem; }
/* The 360px panel left the count's slider about 50px beside the select:
   each takes its own row there. */
@media (min-width: 992px) {
  .cp-palette-controls { flex-wrap: wrap; gap: 8px; }
  .cp-palette-controls .form-select, .cp-count { flex: 1 1 100%; }
}
.cp-palette { display: grid; grid-template-columns: repeat(var(--cp-cols, 5), minmax(0, 1fr)); gap: 8px; }
.cp-pal-item { display: flex; flex-direction: column; align-items: stretch; gap: 3px; min-width: 0; }
.cp-pal-swatch {
  height: 48px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  cursor: copy;
  transition: transform 0.12s;
}
.cp-pal-swatch:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15); }
.cp-pal-swatch:focus-visible { outline: 3px solid var(--pt-accent, #0f70e6); outline-offset: 2px; }
.cp-pal-swatch.cp-done { outline: 3px solid #198754; outline-offset: 2px; }
.cp-pal-hex {
  font: 0.7rem/1.3 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace);
  color: var(--pt-muted, #6c757d);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cp-pal-save {
  height: 28px;
  padding: 0;
  border: 1px solid var(--pt-line, #e3e7ee);
  border-radius: 8px;
  background: #fff;
  color: var(--pt-muted, #6c757d);
  display: flex;
  align-items: center;
  justify-content: center;
}
.cp-pal-save:hover, .cp-pal-save:focus-visible { color: #d63384; border-color: currentColor; }
.cp-pal-save.cp-saved { color: #d63384; }
.cp-palette-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.cp-palette-actions .btn { flex: 1 1 auto; padding-left: 0.75rem; padding-right: 0.75rem; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 14px; white-space: nowrap; }
.cp-palette-actions .btn svg { width: 15px; height: 15px; flex: none; }

/* Save: Saved Colors, then Save Color. */
.cp-save .pt-tool-savebar { margin-top: 0; }
.cp-save #view-saved-colors-btn { display: inline-flex; align-items: center; gap: 8px; }
.cp-save .badge { font-variant-numeric: tabular-nums; }

/* ── The photo box ─────────────────────────────────────────────────────── */
#eyedropper-canvas-container { overflow: hidden; }
#sample-thumbnails-container {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
}
.cp-has-photo #sample-thumbnails-container { display: none; }
#sample-thumbnails-container .sample-thumbnails { display: flex; justify-content: center; gap: 12px; margin: 10px 0; flex-wrap: wrap; }
#sample-thumbnails-container .sample-thumbnail {
  cursor: pointer;
  border: 2px solid #dee2e6;
  border-radius: 10px;
  overflow: hidden;
  width: 110px;
  height: 110px;
  padding: 0;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
#sample-thumbnails-container .sample-thumbnail:hover { border-color: var(--pt-accent, #0f70e6); box-shadow: 0 4px 12px rgba(15, 112, 230, 0.25); }
#sample-thumbnails-container .sample-thumbnail img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 0 !important; }
@media (max-width: 768px) { #sample-thumbnails-container .sample-thumbnail { width: 90px; height: 90px; } }
@media (max-width: 576px) { #sample-thumbnails-container .sample-thumbnail { width: 72px; height: 72px; } }

/* The photo, fitted and centred by color-picker.js. */
#cp-image-box {
  position: absolute;
  display: none;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  outline: none;
  border-radius: 4px;
}
.cp-has-photo #cp-image-box { display: block; }
#cp-image-box:focus-visible { box-shadow: 0 0 0 3px var(--pt-accent, #0f70e6); }
#eyedropper-editor-canvas { display: block; width: 100%; height: 100%; }
/* The pick: a ring round the pixel, readable on light and dark. */
#cp-marker {
  position: absolute;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.7), inset 0 0 0 1.5px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}
#cp-marker::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7);
}
#cp-marker[hidden], #cp-image-box.cp-picking #cp-marker { display: none; }

/* The loupe: the pixels round the pointer, enlarged, ringed in their colour. */
#cp-loupe {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 7;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  will-change: transform;
}
#cp-loupe.show { display: flex; }
#cp-loupe-canvas {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 7px solid var(--cp-ring, #fff);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.95), 0 0 0 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  background: #9aa1ab;
}
#cp-loupe-hex {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 4px;
  border-radius: 999px;
  background: rgba(17, 19, 23, 0.86);
  color: #fff;
  font: 600 0.78rem/1.4 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace);
}
#cp-loupe-hex > i { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.7); }

/* ── Saved Colors ──────────────────────────────────────────────────────── */
/* [dir="rtl"] too: style.css gives RTL lists padding-right: 2rem at (0,1,1), above a class. */
.cp-saved-list, [dir="rtl"] .cp-saved-list { margin: 0; padding: 0; list-style: none; }
.cp-saved-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--pt-line, #e3e7ee);
  border-radius: 12px;
  background: var(--pt-surface, #f6f8fb);
}
.cp-saved-item + .cp-saved-item { margin-top: 8px; }
.cp-saved-swatch {
  flex: 0 0 44px;
  height: 44px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
  cursor: pointer;
}
.cp-saved-swatch:hover, .cp-saved-swatch:focus-visible { box-shadow: 0 0 0 2px var(--pt-accent, #0f70e6); }
.cp-saved-meta { flex: 1 1 auto; min-width: 0; }
.cp-saved-hex { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font: 600 0.95rem/1.3 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace); color: var(--pt-ink, #343f52); }
.cp-saved-rgb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font: 0.8rem/1.3 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace); color: var(--pt-muted, #6c757d); }
.cp-saved-tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(15, 112, 230, 0.12);
  color: #2f5fb8;
  font: 600 0.68rem/1.5 var(--bs-body-font-family, system-ui, sans-serif);
}
.cp-saved-tag.cp-tag-palette { background: rgba(255, 193, 7, 0.22); color: #7a5a00; }
.cp-saved-btn { flex: none; width: 40px; height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
#saved-colors-modal .modal-header { padding: 20px 24px 12px; border-bottom: 1px solid var(--pt-line, #e3e7ee); }
#saved-colors-modal .modal-header .btn-close { position: static; margin: 0 0 0 auto; }
#saved-colors-modal .modal-body { min-height: 160px; padding: 16px 24px; }
#saved-colors-modal .modal-footer { padding: 12px 24px 20px; border-top: 1px solid var(--pt-line, #e3e7ee); gap: 8px; }
#saved-colors-modal .modal-footer > .btn { margin: 0; }
@media (max-width: 575.98px) {
  #saved-colors-modal .modal-header, #saved-colors-modal .modal-body, #saved-colors-modal .modal-footer { padding-left: 16px; padding-right: 16px; }
  #saved-colors-modal .modal-footer > .btn { flex: 1 1 0; }
}

/* ── In the phone editor ───────────────────────────────────────────────── */
/* Color: swatch (the system chooser), the code, Copy. */
.cp-bar { display: flex; align-items: center; gap: 12px; padding: 4px 8px; }
.pt-app-panels > #cp-color-bar.pt-app-panel-on { display: flex !important; }
.cp-bar-swatch {
  position: relative;
  flex: 0 0 48px;
  height: 48px;
  margin: 0;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  overflow: hidden;
}
.cp-bar-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.cp-bar-hex { font: 700 1.05rem/1.3 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace); color: var(--pt-app-fg, #fff); }
.cp-bar-rgb { font: 0.8rem/1.3 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace); color: var(--pt-app-muted, #c2c8d0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-bar-copy {
  flex: none;
  min-width: 44px;
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--pt-app-line, rgba(255, 255, 255, 0.1));
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--pt-app-fg, #fff);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
}
.cp-bar-copy .uil { font-size: 1.1rem; line-height: 1; }
.cp-bar-copy.cp-done { border-color: #198754; }

/* Palette: the types (a sideways row of chips), then the colours. */
.cp-pal-panel { padding: 2px 4px; }
.cp-pal-panel > .cp-type-strip {
  display: flex !important;
  gap: 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.cp-pal-panel > .cp-type-strip::-webkit-scrollbar { display: none; }
.cp-pal-strip { display: flex; gap: 6px; margin-top: 10px; }
.cp-pal-strip > button {
  flex: 1 1 0;
  min-width: 0;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
}
.cp-pal-strip > button.cp-done { outline: 2px solid #fff; outline-offset: 2px; }

/* In the sheet the save section is the top bar's Save and the Saved Colors
   tool, so it is not repeated there. */
.pt-app-sheet .cp-palette-field { margin-bottom: 0 !important; }
