/* ═══════════════════════════════════════════════════
   FEATURE — ITEMS TAB (Sprint 2.5 VS)
   Reuses the npc-grid/npc-btn class names but scoped
   under .studio .tab-items to avoid pulling unrelated
   NPC rules (anim-grid, playback, etc.). Values mirror
   styles/features/npc.css so the grid reads identically
   across tabs.
   ═══════════════════════════════════════════════════ */

.studio .tab-items .panel-body {
  /* Three-column layout unique to the Items tab: browse tree on the
     left, controls (search + item icons + info + scrolls) in the
     middle, preview on the right. Browse column collapses to a thin
     strip when .collapsed. */
  grid-template-columns: 220px 260px 1fr;
}
.studio .tab-items .panel-body:has(.browse-col.collapsed) {
  grid-template-columns: 28px 260px 1fr;
}

.studio .tab-items .controls-col {
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  background: #f8f8fa;
}

/* ── Search ── */
.studio .tab-items .npc-search-wrap { display: flex; }

.studio .tab-items .npc-search {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  border: 1px solid var(--border-lo);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
}
.studio .tab-items .npc-search:focus       { border-color: var(--accent); }
.studio .tab-items .npc-search::placeholder { color: var(--text-dim); }

/* ── Grid wrapper ── */
.studio .tab-items .npc-grid-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 320px;
  scrollbar-width: thin;
}
.studio .tab-items .npc-grid-wrap::-webkit-scrollbar       { width: 8px; }
.studio .tab-items .npc-grid-wrap::-webkit-scrollbar-track {
  background: var(--chrome-lo);
  border-left: 1px solid var(--border);
  border-radius: 0 8px 8px 0;
}
.studio .tab-items .npc-grid-wrap::-webkit-scrollbar-thumb {
  background: var(--border-lo);
  border: 2px solid var(--chrome-lo);
  border-radius: 4px;
  min-height: 28px;
}

/* ── Grid + buttons ── */
.studio .tab-items .npc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 4px;
  padding: 5px;
  box-sizing: border-box;
  width: 100%;
}

.studio .tab-items .npc-btn {
  background: linear-gradient(180deg, #f6f6f6 0%, #e8e8e8 100%);
  border: none;
  outline: none;
  border-radius: 5px;
  padding: 4px 2px 3px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  width: 100%;
  height: 72px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), background 0.15s;
}
.studio .tab-items .npc-btn:hover {
  background: linear-gradient(180deg, #f0f0f0 0%, #e2e2e2 100%);
  transform: translateY(-3px);
}
.studio .tab-items .npc-btn.active {
  background: linear-gradient(180deg, rgba(74,158,192,0.2) 0%, rgba(42,126,160,0.12) 100%);
}
.studio .tab-items .npc-btn.active:hover { transform: translateY(0); }
.studio .tab-items .npc-btn:focus        { outline: none; }

.studio .tab-items .npc-btn-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.studio .tab-items .npc-btn-icon canvas {
  max-width: 40px;
  max-height: 40px;
}

.studio .tab-items .npc-btn-label {
  font-size: 9px;
  line-height: 1.15;
  text-align: center;
  color: var(--text);
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 2px;
}
.studio .tab-items .npc-btn.active .npc-btn-label { font-weight: 600; }

.studio .tab-items .npc-grid-msg {
  grid-column: 1 / -1;
  padding: 24px 8px;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}
.studio .tab-items .npc-grid-err { color: #c33; }

/* ── Info panel ── */
.studio .tab-items .items-info {
  font-size: 12px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.studio .tab-items .items-info-lbl {
  color: var(--text-dim);
  display: inline-block;
  width: 42px;
}

/* ── Preview canvas ── */
.studio .tab-items #items-tooltip-canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: transparent;
}

/* ── View-mode toggle (CSS / Pixel) in the preview toolbar ── */
.studio .tab-items .items-view-toggle {
  display: inline-flex;
  border: 1px solid var(--border-lo);
  border-radius: 4px;
  overflow: hidden;
}
.studio .tab-items .items-view-toggle button {
  appearance: none;
  background: var(--chrome-lo);
  color: var(--text-dim);
  border: none;
  border-right: 1px solid var(--border-lo);
  padding: 2px 10px;
  font: 11px "Segoe UI", Arial, sans-serif;
  cursor: pointer;
  height: 20px; /* matches .zoom-btn — PROTECTED */
  line-height: 1;
}
.studio .tab-items .items-view-toggle button:last-child { border-right: none; }
.studio .tab-items .items-view-toggle button.active {
  background: var(--accent);
  color: #fff;
}
.studio .tab-items .items-view-toggle button:hover:not(.active) {
  background: var(--border-lo);
  color: var(--text);
}

/* ── Browse column (middle column between controls and preview) ── */
.studio .tab-items .browse-col {
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  background: #f8f8fa;
  min-width: 0;
}

.studio .tab-items .browse-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}
.studio .tab-items .browse-col-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-mid);
  display: flex;
  align-items: center;
  gap: 6px;
}
.studio .tab-items .browse-col-title::before {
  content: '';
  width: 2px;
  height: 11px;
  background: var(--accent);
  border-radius: 1px;
}
.studio .tab-items .browse-col-toggle {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 3px;
  transition: background 0.12s, color 0.12s;
}
.studio .tab-items .browse-col-toggle:hover {
  background: var(--chrome-lo);
  color: var(--text);
}

/* Collapsed state — narrow strip showing only the toggle button. */
.studio .tab-items .browse-col.collapsed {
  padding: 14px 2px;
}
.studio .tab-items .browse-col.collapsed .browse-col-header {
  justify-content: center;
  padding-bottom: 0;
  border-bottom: none;
}
.studio .tab-items .browse-col.collapsed .browse-col-title { display: none; }
.studio .tab-items .browse-col.collapsed .items-tree       { display: none; }

/* ── Category tree ── */
.studio .tab-items .items-tree {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  scrollbar-width: thin;
  min-height: 0;
}
.studio .tab-items .items-tree::-webkit-scrollbar       { width: 8px; }
.studio .tab-items .items-tree::-webkit-scrollbar-track {
  background: var(--chrome-lo);
  border-radius: 4px;
}
.studio .tab-items .items-tree::-webkit-scrollbar-thumb {
  background: var(--border-lo);
  border: 2px solid var(--chrome-lo);
  border-radius: 4px;
  min-height: 28px;
}

.studio .tab-items .items-tree-group {
  display: flex;
  flex-direction: column;
}

.studio .tab-items .items-tree-header {
  appearance: none;
  background: transparent;
  border: none;
  padding: 4px 6px;
  font: 600 12px "Segoe UI", Arial, sans-serif;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 4px;
  text-align: left;
}
.studio .tab-items .items-tree-header:hover {
  background: var(--chrome-lo);
}
.studio .tab-items .items-tree-chev {
  width: 10px;
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1;
  flex-shrink: 0;
}

/* Collapsed groups hide their items row without removing it from the DOM
   (saves a re-render on toggle). */
.studio .tab-items .items-tree-items {
  display: none;
  flex-direction: column;
  gap: 1px;
  padding-left: 18px;
  margin-bottom: 2px;
}
.studio .tab-items .items-tree-group.open > .items-tree-items {
  display: flex;
}

.studio .tab-items .items-tree-item {
  appearance: none;
  background: transparent;
  border: none;
  padding: 3px 8px;
  font: 11px "Segoe UI", Arial, sans-serif;
  color: var(--text);
  cursor: pointer;
  border-radius: 4px;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.studio .tab-items .items-tree-item:hover:not(.active) {
  background: var(--chrome-lo);
}
.studio .tab-items .items-tree-item.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ── Filter panel (job pills + NX + gender checkboxes) ── */
.studio .tab-items .items-filter-jobs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.studio .tab-items .items-filter-jobs button {
  appearance: none;
  background: var(--chrome-lo);
  color: var(--text-dim);
  border: 1px solid var(--border-lo);
  border-radius: 4px;
  padding: 2px 6px;
  font: 600 10px "Segoe UI", Arial, sans-serif;
  cursor: pointer;
  height: 20px;
  line-height: 1;
  min-width: 28px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.studio .tab-items .items-filter-jobs button:hover:not(.active) {
  background: var(--border-lo);
  color: var(--text);
}
.studio .tab-items .items-filter-jobs button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.studio .tab-items .items-filter-gender {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 6px;
}
.studio .tab-items .items-filter-gender label {
  display: flex;
  align-items: center;
  gap: 4px;
  font: 11px "Segoe UI", Arial, sans-serif;
  color: var(--text);
  cursor: pointer;
}
.studio .tab-items .items-filter-gender input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}

/* ── Options panel (tooltip row toggles) ── */
.studio .tab-items .items-options-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.studio .tab-items .items-options-list label {
  display: flex;
  align-items: center;
  gap: 6px;
  font: 11px "Segoe UI", Arial, sans-serif;
  color: var(--text);
  cursor: pointer;
}
.studio .tab-items .items-options-list input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}

/* ── Scroll simulation panel ── */
/* Pills — stat families that exist in MCW/1 for this equip's subCategory.
   Wrap to multiple rows when the family count is high (Cape has 7). */
.studio .tab-items .items-scroll-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.studio .tab-items .items-scroll-pills button {
  appearance: none;
  background: var(--chrome-lo);
  color: var(--text-dim);
  border: 1px solid var(--border-lo);
  border-radius: 4px;
  padding: 2px 8px;
  font: 11px "Segoe UI", Arial, sans-serif;
  cursor: pointer;
  height: 20px;
  line-height: 1;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.studio .tab-items .items-scroll-pills button:hover:not(.active) {
  background: var(--border-lo);
  color: var(--text);
}
.studio .tab-items .items-scroll-pills button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Tier row — 10% / 60% / 100% / Chaos, then Fail with a small gap.
   Uses flex with Fail getting margin-left:auto so it sits at the right. */
.studio .tab-items .items-scroll-tiers {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.studio .tab-items .items-scroll-tiers button {
  flex: 1 1 0;
  min-width: 0;
  appearance: none;
  background: var(--chrome-hi);
  color: var(--text);
  border: 1px solid var(--border-lo);
  border-radius: 4px;
  padding: 2px 4px;
  font: 11px "Segoe UI", Arial, sans-serif;
  font-weight: 600;
  cursor: pointer;
  height: 20px;
  line-height: 1;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.studio .tab-items .items-scroll-tiers button:hover:not(:disabled) {
  background: #fff;
  border-color: var(--accent);
  color: var(--accent-text);
}
.studio .tab-items .items-scroll-tiers button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.studio .tab-items .items-scroll-tiers button.is-fail {
  margin-left: 4px;
  color: var(--text-dim);
}
.studio .tab-items .items-scroll-tiers button.is-fail:hover:not(:disabled) {
  background: #fff;
  border-color: var(--text-dim);
  color: var(--text);
}

/* Hover hint row — sits between the tier buttons and the footer. Shows
   "Click to apply Scroll" by default and the hovered tier's stat gain on
   button mouseover (driven by JS in items.js). */
.studio .tab-items .items-scroll-hint {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.3;
  min-height: 14px;
}

/* Footer — slots counter left, Reset button right. */
.studio .tab-items .items-scroll-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
}
.studio .tab-items .items-scroll-slots { color: var(--text); }
.studio .tab-items .items-scroll-reset {
  appearance: none;
  background: var(--chrome-lo);
  color: var(--text-dim);
  border: 1px solid var(--border-lo);
  border-radius: 4px;
  padding: 2px 10px;
  font: 11px "Segoe UI", Arial, sans-serif;
  cursor: pointer;
  height: 20px;
  line-height: 1;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.studio .tab-items .items-scroll-reset:hover {
  background: #fff;
  border-color: var(--accent);
  color: var(--accent-text);
}
