/* ==========================================================================
   Shared components: colour picker, combobox, quick search, list filters
   Builds on the tokens in styles.css.
   ========================================================================== */

/* ---------- Colour picker ---------- */
.color-picker {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.color-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.color-picker-label {
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
}

.color-picker-current {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 9px 3px 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.color-picker-current i {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.color-picker-current i.is-auto {
  background: conic-gradient(#f97316, #ec4899, #6366f1, #0ea5e9, #10b981, #eab308, #f97316) !important;
}

.color-picker-current code {
  color: var(--text);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.color-picker-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 8px;
}

.color-swatch {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  max-width: 34px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: var(--swatch);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.1);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.color-swatch:hover {
  transform: translateY(-1px) scale(1.06);
}

.color-swatch .icon-svg {
  width: 15px;
  height: 15px;
  stroke-width: 2.2 !important;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.color-swatch.is-active {
  box-shadow: 0 0 0 2px var(--surface-2), 0 0 0 4px var(--swatch);
}

.color-swatch.is-active .icon-svg {
  opacity: 1;
  transform: none;
}

/* Small dot = colour already used by another project */
.color-swatch.is-used::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 6px;
  height: 6px;
  border: 1.5px solid #ffffff;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.45);
}

.color-swatch.is-auto {
  grid-column: span 2;
  max-width: none;
  aspect-ratio: auto;
  min-height: 30px;
  border: 1px dashed var(--border);
  background: var(--surface);
  color: var(--muted);
  box-shadow: none;
  font-size: 12px;
  font-weight: 600;
}

.color-swatch.is-auto.is-active {
  border-style: solid;
  border-color: var(--text);
  color: var(--text);
  box-shadow: none;
}

.color-picker-custom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.color-picker-native {
  position: relative;
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  min-height: 34px;
  padding: 4px 12px 4px 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px !important;
  font-weight: 500 !important;
  cursor: pointer;
}

.color-picker-native:hover {
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
}

.color-picker-native input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.color-picker-native-dot {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: conic-gradient(#ef4444, #eab308, #22c55e, #06b6d4, #6366f1, #d946ef, #ef4444);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.color-picker-native.is-active {
  border-color: var(--swatch);
  box-shadow: 0 0 0 1px var(--swatch);
}

.color-picker-native.is-active .color-picker-native-dot {
  background: var(--swatch);
}

.modal .color-picker-hex,
.color-picker-hex {
  width: 104px;
  min-height: 34px !important;
  padding: 6px 10px !important;
  border-radius: 999px !important;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12.5px !important;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.color-picker-hex.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.color-picker-legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  color: var(--muted);
  font-size: 11.5px;
}

.color-picker-legend i {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.45);
}

.color-picker-hint {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

@media (max-width: 520px) {
  .color-picker-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .color-swatch {
    max-width: none;
  }

  .color-picker-legend {
    margin-left: 0;
  }
}

/* ---------- Combobox (searchable select) ---------- */
.combo {
  position: relative;
}

.combo-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 40px;
  padding: 7px 10px 7px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--input, var(--surface));
  color: var(--text);
  font-size: 14px;
  text-align: left;
}

.combo-trigger:hover {
  border-color: color-mix(in srgb, var(--text) 25%, var(--border));
}

.combo.is-open .combo-trigger,
.combo-trigger:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
  outline: none;
}

.combo-trigger-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.combo-trigger-text.is-placeholder {
  color: var(--muted);
}

.combo-chevron {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.combo-chevron .icon-svg {
  width: 15px;
  height: 15px;
}

.combo-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 3px;
}

.combo-plus {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary);
}

.combo-plus .icon-svg {
  width: 13px;
  height: 13px;
}

.combo-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  z-index: 80;
  display: grid;
  min-width: 260px;
  overflow: hidden;
  border: 1px solid var(--card-border, var(--border));
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 18px 44px -12px rgba(15, 23, 42, 0.35), 0 2px 6px rgba(15, 23, 42, 0.08);
  animation: popover-in 0.14s var(--ease-out, ease);
}

.combo.opens-up .combo-panel {
  top: auto;
  bottom: calc(100% + 6px);
}

.combo-panel[hidden] {
  display: none;
}

.combo-search-wrap {
  position: relative;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.combo-search-wrap .icon-svg {
  position: absolute;
  top: 50%;
  left: 19px;
  width: 15px;
  height: 15px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.combo .combo-search {
  min-height: 36px !important;
  padding: 7px 10px 7px 32px !important;
  border-radius: 8px !important;
  font-size: 14px;
}

.combo-list {
  max-height: 290px;
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.combo-group + .combo-group {
  margin-top: 4px;
}

.combo-group[hidden] {
  display: none;
}

.combo-group-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 8px 4px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.combo-group-label span {
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-2);
  letter-spacing: 0;
}

.combo-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.combo-option[hidden] {
  display: none;
}

.combo-option:hover,
.combo-option.is-active {
  background: var(--surface-2);
}

.combo-option-text {
  display: grid;
  flex: 1 1 auto;
  gap: 1px;
  min-width: 0;
  line-height: 1.25;
}

.combo-option-text b,
.combo-option-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.combo-option-text b {
  font-size: 13.5px;
  font-weight: 500;
}

.combo-option-text small {
  color: var(--muted);
  font-size: 11.5px;
}

.combo-option > .icon-svg {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  color: var(--primary);
  opacity: 0;
}

.combo-option.is-selected > .icon-svg {
  opacity: 1;
}

.combo-option.is-selected b {
  font-weight: 600;
}

.combo-empty {
  padding: 18px 10px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.combo-empty[hidden] {
  display: none;
}

.combo-create {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 8px 14px;
  border: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--primary-text);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}

.combo-create:hover,
.combo-create.is-active {
  background: var(--primary-soft);
}

/* ---------- Quick search (Ctrl/Cmd + K) ---------- */
.quick-search-backdrop {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: min(14vh, 120px) 16px 16px;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(6px);
  animation: modal-fade 0.14s ease;
}

.quick-search {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(640px, 100%);
  max-height: min(70vh, 620px);
  overflow: hidden;
  border: 1px solid var(--card-border, var(--border));
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 30px 80px -16px rgba(15, 23, 42, 0.45);
  animation: modal-in 0.18s var(--ease-out, ease);
}

.quick-search-input {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.quick-search-input > .icon-svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  color: var(--muted);
}

.quick-search-input input {
  flex: 1 1 auto;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 17px;
  box-shadow: none !important;
  outline: none;
}

.quick-search kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.quick-list {
  padding: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.quick-group {
  padding: 10px 10px 6px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.quick-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 7px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.quick-item:hover,
.quick-item.is-active {
  background: var(--surface-2);
}

.quick-item.is-active {
  box-shadow: inset 0 0 0 1px var(--border);
}

.quick-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--quick-color, var(--muted)) 14%, var(--surface));
  color: var(--quick-color, var(--muted));
}

.quick-icon .icon-svg {
  width: 16px;
  height: 16px;
}

.quick-text {
  display: grid;
  flex: 1 1 auto;
  gap: 1px;
  min-width: 0;
  line-height: 1.25;
}

.quick-text b,
.quick-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-text b {
  font-size: 14px;
  font-weight: 600;
}

.quick-text small {
  color: var(--muted);
  font-size: 12px;
}

.quick-enter {
  color: var(--muted);
  opacity: 0;
}

.quick-enter .icon-svg {
  width: 15px;
  height: 15px;
}

.quick-item.is-active .quick-enter {
  opacity: 1;
}

.quick-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 32px 16px;
  color: var(--muted);
  font-size: 13.5px;
}

.quick-empty .icon-svg {
  width: 24px;
  height: 24px;
}

.quick-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.quick-foot span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

@media (max-width: 640px) {
  .quick-search-backdrop {
    padding: 0;
    align-items: stretch;
  }

  .quick-search {
    max-height: none;
    border-radius: 0;
  }

  .quick-search-input input {
    font-size: 16px;
  }

  .quick-foot {
    display: none;
  }
}

/* ---------- Sidebar: search button + project filter ---------- */
.sidebar .sidebar-search {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 36px;
  margin-bottom: 10px;
  padding: 6px 8px 6px 10px;
  border: 1px solid var(--nav-border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--nav-faint);
  font-size: 13px;
  text-align: left;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.sidebar .sidebar-search:hover {
  border-color: color-mix(in srgb, var(--nav-muted) 35%, var(--nav-border));
  color: var(--nav-text);
}

.sidebar-search .icon-svg {
  width: 16px;
  height: 16px;
}

.sidebar-search-text {
  flex: 1 1 auto;
}

.sidebar-search kbd {
  padding: 0 5px;
  border: 1px solid var(--nav-border);
  border-radius: 5px;
  background: var(--nav-bg);
  color: var(--nav-faint);
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
}

.sidebar .sidebar-filter {
  position: relative;
  display: block;
  margin: 0 2px 6px 0;
}

.sidebar-filter .icon-svg {
  position: absolute;
  top: 50%;
  left: 9px;
  width: 14px;
  height: 14px;
  color: var(--nav-faint);
  transform: translateY(-50%);
  pointer-events: none;
}

.sidebar .sidebar-filter input {
  min-height: 32px;
  padding: 5px 9px 5px 29px;
  border: 1px solid var(--nav-border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 12.5px;
}

.sidebar-filter-empty {
  margin: 4px 8px;
  color: var(--nav-faint);
  font-size: 12px;
}

.sidebar .project-button[hidden],
.sidebar-filter-empty[hidden] {
  display: none !important;
}

@media (min-width: 761px) {
  .sidebar.is-rail .sidebar-search {
    justify-content: center;
    padding: 6px;
  }

  .sidebar.is-rail .sidebar-search-text,
  .sidebar.is-rail .sidebar-search kbd,
  .sidebar.is-rail .sidebar-filter,
  .sidebar.is-rail .sidebar-filter-empty {
    display: none;
  }
}

@media (max-width: 760px) {
  .sidebar-search kbd {
    display: none;
  }
}

/* ---------- Dashboard project filter ---------- */
.dashboard-projects-head {
  flex-wrap: wrap;
}

.dashboard-projects-head h2 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.panel-count {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.panel-filter {
  position: relative;
  display: block;
  width: min(260px, 100%);
}

.panel-filter .icon-svg {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 15px;
  height: 15px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.panel-filter input {
  min-height: 36px;
  padding: 7px 11px 7px 33px;
  border-radius: 9px;
  font-size: 13px;
}

.project-card[hidden],
[data-dashboard-filter-empty][hidden] {
  display: none !important;
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary-text);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

@media (max-width: 760px) {
  .panel-filter {
    width: 100%;
  }
}
