/* ==========================================================
   Pemilih item, filter kategori, dan slot build
   ========================================================== */

/* ===== Kepala layar item ===== */

.items-head {
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.items-head h2 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.items-sub {
  margin: 6px 0 0;
  font-size: 13.5px;
  color: var(--ink-2);
}

.note-items {
  flex: none;
  margin-top: 6px;
  text-align: right;
  transform: rotate(5deg);
  transform-origin: right center;
}

/* ===== Pencarian ===== */

.search-wrap {
  position: relative;
  flex: none;
  color: var(--ink-3);
}

.search-wrap svg {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.picker-search {
  width: 100%;
  height: 48px;
  padding: 0 18px 0 46px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 14px;
  color: var(--ink);
}

.picker-search::placeholder {
  color: var(--ink-3);
}

/* ===== Filter kategori (seperti pemilih hari) ===== */

.picker-filters {
  flex: none;
  display: flex;
  gap: 8px;
  margin: 6px -8px 4px;
  padding: 8px 8px 18px;
  overflow-x: auto;
  scrollbar-width: none;
}

.picker-filters::-webkit-scrollbar {
  display: none;
}

.filter-btn {
  flex: none;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.filter-btn:hover {
  color: var(--ink);
  background: var(--soft);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 6px 14px var(--accent-shadow);
}

/* ===== Daftar item (grid ikon bulat: nama dan harga di bawah) ===== */

:root {
  --gold: #a06a12;
}

:root[data-theme="dark"] {
  --gold: #e3b24d;
}

.item-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  align-content: start;
  gap: 10px 6px;
  min-height: 0;
  flex: 1;
  max-height: 640px;
  overflow-y: auto;
  padding: 4px 8px 10px 6px;
  margin: 0 -8px 0 -6px;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}

.item-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 6px 0 8px;
  border: 1px solid transparent;
  border-radius: 18px;
  background: transparent;
  color: var(--ink);
  text-align: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.item-tile:hover {
  background: var(--hover);
  border-color: var(--line-strong);
}

.tile-icon {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 60px;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: var(--soft);
  font-size: 19px;
  font-weight: 800;
  color: var(--forest-2);
  transition: box-shadow 0.2s;
}

.tile-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  width: 100%;
}

.tile-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.5em;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink-2);
  overflow-wrap: break-word;
}

.tile-sub {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* Harga (emas) hanya untuk item yang punya kolom price */
.tile-sub.is-price {
  font-weight: 700;
  color: var(--gold);
}

/* Lencana centang di pojok ikon, hanya tampil untuk item terpilih */
.tile-check {
  position: absolute;
  top: 2px;
  right: 6px;
  display: none;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 2px 6px var(--accent-shadow);
}

.item-tile.selected {
  background: var(--sage);
  border-color: var(--sage-2);
}

.item-tile.selected .tile-icon {
  box-shadow: 0 0 0 3px var(--accent);
}

.item-tile.selected .tile-name {
  color: var(--ink);
}

.item-tile.selected .tile-check {
  display: grid;
}

/* Slot penuh: item lain diredupkan */
.item-picker.is-full .item-tile:not(.selected) {
  opacity: 0.45;
  cursor: not-allowed;
}

.picker-empty {
  grid-column: 1 / -1;
  padding: 40px 0;
  text-align: center;
  font-size: 14px;
  color: var(--ink-3);
}

/* ===== Slot build (kartu kecil seperti daftar proyek) ===== */

.build-block {
  flex: none;
  margin-bottom: 22px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.build-block .block-head {
  margin-bottom: 12px;
}

.build-slots {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.build-slot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 8px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.slot-circle {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: var(--soft);
  font-size: 22px;
  font-weight: 800;
  color: var(--forest-2);
}

.slot-circle img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.build-slot:disabled {
  background: transparent;
  box-shadow: none;
  border-style: dashed;
  border-color: var(--line-strong);
}

.build-slot:disabled .slot-circle {
  background: transparent;
  color: var(--ink-3);
  font-weight: 400;
  font-size: 26px;
}

/* Hover di slot terisi: tampilkan aksi melepas */
.build-slot.filled .slot-circle::after {
  content: "Lepas";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(36, 50, 41, 0.62);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.2s;
}

.build-slot.filled:hover .slot-circle::after,
.build-slot.filled:focus-visible .slot-circle::after {
  opacity: 1;
}

.slot-label {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
  padding: 0 2px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink-2);
}

/* Penghitung berkedip saat slot penuh */
.count-note.flash {
  animation: count-flash 0.4s ease;
}

@keyframes count-flash {
  0%, 100% { transform: translateX(0); color: var(--ink-3); }
  25% { transform: translateX(-3px); color: #c0432d; }
  75% { transform: translateX(3px); color: #c0432d; }
}

@media (max-width: 480px) {
  .items-head h2 {
    font-size: 23px;
  }

  .item-picker {
    max-height: 560px;
  }
}

@media (max-width: 640px) {
  .build-slots {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }
}