/* Phosphor icon picker — admin widget. Espelha o design do habits picker
 * (DS canônico: roxo brand-primary, duotone default, weight toggle). */

:root {
  --pi-brand: rgb(145 44 238);
  --pi-brand-soft: rgba(145, 44, 238, 0.10);
  --pi-brand-border: rgba(145, 44, 238, 0.30);
  --pi-text: rgb(15 23 42);
  --pi-text-muted: rgb(100 116 139);
  --pi-text-faint: rgb(148 163 184);
  --pi-bg: #ffffff;
  --pi-bg-soft: rgb(248 250 252);
  --pi-border: rgb(226 232 240);
}

.dark, html[data-theme="dark"] {
  --pi-text: rgb(241 245 249);
  --pi-text-muted: rgb(148 163 184);
  --pi-text-faint: rgb(100 116 139);
  --pi-bg: rgb(15 23 42);
  --pi-bg-soft: rgb(30 41 59);
  --pi-border: rgb(51 65 85);
}

.phosphor-picker {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.phosphor-picker__row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.phosphor-picker__preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  flex: 0 0 2.5rem;
  border: 1px solid var(--pi-border);
  border-radius: 0.5rem;
  background: var(--pi-bg-soft);
  color: var(--pi-brand);
  font-size: 1.5rem;
}

.phosphor-picker__input {
  flex: 1 1 auto;
  min-width: 0;
}

.phosphor-picker__btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border-radius: 0.5rem;
  border: 1px solid var(--pi-border);
  background: var(--pi-bg);
  color: var(--pi-text);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms, border-color 120ms;
}

.phosphor-picker__btn:hover {
  background: var(--pi-brand-soft);
  border-color: var(--pi-brand-border);
  color: var(--pi-brand);
}

.phosphor-picker__btn i {
  font-size: 1rem;
  color: var(--pi-brand);
}

.phosphor-picker__btn--clear {
  font-size: 1.1rem;
  line-height: 1;
  width: 2rem;
  padding: 0;
  color: rgb(220 38 38);
}
.phosphor-picker__btn--clear:hover {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.30);
  color: rgb(220 38 38);
}

.phosphor-picker__hint {
  font-size: 0.75rem;
  color: var(--pi-text-muted);
}

.phosphor-picker__hint a {
  color: var(--pi-brand);
  text-decoration: underline;
}

/* Modal */
.phosphor-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.phosphor-modal[hidden] { display: none; }

.phosphor-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
}

.phosphor-modal__panel {
  position: relative;
  width: min(720px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--pi-bg);
  color: var(--pi-text);
  border: 1px solid var(--pi-border);
  border-radius: 0.75rem;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.4);
  overflow: hidden;
}

.phosphor-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--pi-border);
}

.phosphor-modal__header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.phosphor-modal__header h3 i {
  color: var(--pi-brand);
  font-size: 1.25rem;
}

.phosphor-modal__close {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: var(--pi-text-muted);
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  transition: background-color 120ms;
}

.phosphor-modal__close:hover {
  background: var(--pi-bg-soft);
  color: var(--pi-text);
}

.phosphor-modal__toolbar {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--pi-border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.phosphor-modal__search {
  width: 100%;
  padding: 0.55rem 0.85rem;
  border-radius: 0.5rem;
  border: 1px solid var(--pi-border);
  font-size: 0.9rem;
  background: var(--pi-bg);
  color: var(--pi-text);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}

.phosphor-modal__search:focus {
  border-color: var(--pi-brand);
  box-shadow: 0 0 0 3px var(--pi-brand-soft);
}

.phosphor-modal__weights {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--pi-text-muted);
}

.phosphor-modal__weights-label {
  margin-right: 0.25rem;
}

.phosphor-weight-btn {
  font-size: 0.75rem;
  padding: 0.15rem 0.6rem;
  border-radius: 0.375rem;
  border: none;
  background: transparent;
  color: var(--pi-text-muted);
  cursor: pointer;
  transition: background-color 150ms, color 150ms;
}

.phosphor-weight-btn:hover {
  background: var(--pi-brand-soft);
  color: var(--pi-text);
}

.phosphor-weight-btn.is-active {
  background: var(--pi-brand);
  color: white;
  font-weight: 500;
}

.phosphor-modal__count {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--pi-text-muted);
  white-space: nowrap;
}

.phosphor-modal__grid {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.75rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.25rem;
  align-content: start;
}

.phosphor-modal__loading,
.phosphor-modal__empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem;
  color: var(--pi-text-muted);
  font-size: 0.875rem;
}

.phosphor-modal__cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  aspect-ratio: 1;
  padding: 0.5rem 0.25rem;
  border-radius: 0.5rem;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 120ms, border-color 120ms, transform 80ms;
}

.phosphor-modal__cell:hover {
  background: var(--pi-brand-soft);
  border-color: var(--pi-brand-border);
  transform: translateY(-1px);
}

.phosphor-modal__cell--active {
  background: var(--pi-brand-soft);
  border-color: var(--pi-brand);
}

.phosphor-modal__cell i {
  font-size: 1.5rem;
  color: var(--pi-text);
}

.phosphor-modal__cell:hover i,
.phosphor-modal__cell--active i {
  color: var(--pi-brand);
}

.phosphor-modal__cell-label {
  font-size: 0.625rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--pi-text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.phosphor-modal__cell:hover .phosphor-modal__cell-label,
.phosphor-modal__cell--active .phosphor-modal__cell-label {
  color: var(--pi-text-muted);
}
