/*
 * Copyright (C) 2026 Yzapre
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

/* ── Inventory page ──────────────────────────────────── */
.inv-wrap {
  --goal-count: 3;
  max-width: min(100%, calc(700px + var(--goal-count, 3) * 95px));
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: max-width 0.15s ease;
}

/* ── Toolbar ─────────────────────────────────────────── */
.inv-toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Tab bar ─────────────────────────────────────────── */
.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.tab-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
  font-family: inherit;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}
.tab-btn:hover { background: var(--border); color: var(--text); }
.tab-btn.active {
  background: var(--border);
  color: var(--text);
  font-weight: 600;
  border-color: var(--muted);
}
/* Separator between alpha tab and section tabs */
.tab-btn.tab-alpha {
  border-style: solid;
}
.tab-divider {
  width: 1px;
  background: var(--border);
  align-self: stretch;
  margin: 0 0.1rem;
}

/* ── Stats panel ─────────────────────────────────────── */
.stats-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  cursor: pointer;
  user-select: none;
}
.stats-header:hover { background: var(--border); }
.stats-header strong { font-size: 0.9rem; }
.stats-arrow {
  font-size: 0.75rem;
  color: var(--muted);
  transition: transform 0.15s;
}
.stats-panel.open .stats-arrow { transform: rotate(180deg); }
.stats-body {
  display: none;
  padding: 0.75rem 1rem;
  gap: 2rem;
  border-top: 1px solid var(--border);
}
.stats-panel.open .stats-body { display: flex; flex-wrap: wrap; }
.stats-group { display: flex; flex-direction: column; gap: 0.3rem; min-width: 160px; }
/* Keeps Others and Collections stacked vertically together as a single
   unit within the horizontal stats-body layout, rather than letting
   Collections float off to the side as its own peer group when there's
   enough width. */
.stats-group-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 160px;
}
.stats-group-title {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.15rem;
}
.stats-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.82rem;
}
.stats-row .s-label { color: var(--muted); }
.stats-row .s-value { font-weight: 600; }

/* ── Section panel ───────────────────────────────────── */
.section-panel { display: none; }
.section-panel.active { display: block; }
.section-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border);
}
.section-title-bar strong { font-size: 0.9rem; }
.section-subtitle { font-size: 0.8rem; color: var(--muted); }

/* ── AV Goal columns ───────────────────────────────────
   Progress-toward-goal cells: text-only coloring (no background block)
   teal once the goal's met, tapering through green / yellow / orange
   down to red the further off it is. */
.av-goal-th { white-space: nowrap; }
.av-goal-cell {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: color 0.1s;
}
.av-goal-cell.av-goal-empty {
  color: var(--border) !important;
  font-weight: 400;
}

/* Amount input */
.amount-inp {
  width: 100px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.28rem 0.45rem;
  font-size: 0.85rem;
  font-family: inherit;
}
.amount-inp:focus { outline: none; border-color: var(--muted); }

.td-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.td-av { font-weight: 600; }

/* Notes input */
.notes-inp {
  width: 100%;
  min-width: 100px;
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-family: inherit;
  padding: 0.2rem 0;
  transition: border-color 0.1s, color 0.1s;
}
.notes-inp:focus { outline: none; border-bottom-color: var(--border); color: var(--text); }
.notes-inp::placeholder { color: var(--border); }

/* ── Section footer ──────────────────────────────────── */
.section-footer {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}
.footer-stat { display: flex; gap: 0.35rem; align-items: center; }
.footer-stat .f-label { color: var(--muted); }
.footer-stat .f-value { font-weight: 600; }

/* Clear Section / Clear All / AV Goals modals reuse the shared
   .modal-overlay / .modal-box / .modal-actions family from styles.css
   (the bigger Layout editor below has its own dedicated modal). */

/* ── AV Goals modal ───────────────────────────────────── */
.goal-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
  min-height: 30px;
}
.goal-chip-empty {
  font-size: 0.8rem;
  color: var(--muted);
}
.goal-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.5rem 0.3rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
}
.goal-chip-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0 0.2rem;
  font-family: inherit;
}
.goal-chip-remove:hover { color: #ff9999; }
.goal-add-row {
  display: flex;
  gap: 0.5rem;
}
.goal-add-row input[type="number"] {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
}
.goal-add-row input[type="number"]:focus { outline: none; border-color: var(--muted); }
.goal-add-row button {
  flex-shrink: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 0.4rem 0.85rem;
  font-family: inherit;
  font-weight: 600;
}
.goal-add-row button:hover { background: var(--border); }

/* ── Layout modal, fixed height, inner scroll ───────── */
.layout-modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.layout-modal-overlay.open { display: flex; }

.layout-modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 100%;
  max-width: 680px;
  /* Fixed height layout: header + presets + sections (scrollable) + footer */
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.layout-modal-header {
  padding: 1.1rem 1.4rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.layout-modal-header h3 { font-size: 1rem; margin-bottom: 0.25rem; }
.layout-modal-header p { font-size: 0.82rem; color: var(--muted); margin: 0; }

.layout-modal-presets {
  padding: 0.75rem 1.4rem 0;
  flex-shrink: 0;
}
.layout-modal-presets-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.preset-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.preset-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.3rem 0.65rem;
  font-family: inherit;
  transition: background 0.1s;
}
.preset-btn:hover { background: var(--border); }
.preset-btn.active { border-color: var(--muted); font-weight: 600; }

.preset-empty {
  font-size: 0.8rem;
  color: var(--muted);
}

/* User-saved presets, same look as a built-in preset button, plus a
   small delete affordance since (unlike the built-ins) these can be
   removed. */
.preset-chip-wrap {
  display: inline-flex;
  align-items: stretch;
  border-radius: 4px;
  overflow: hidden;
}
.preset-chip-wrap .preset-btn {
  border-radius: 4px 0 0 4px;
  border-right: none;
}
.preset-chip-remove {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 1px solid var(--border);
  border-radius: 0 4px 4px 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.3rem 0.5rem;
  font-family: inherit;
}
.preset-chip-remove:hover { background: #3a1010; border-color: #7a2020; color: #ff9999; }

.save-preset-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.save-preset-row input[type="text"] {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
}
.save-preset-row input[type="text"]:focus { outline: none; border-color: var(--muted); }
.save-preset-row button {
  flex-shrink: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 0.35rem 0.7rem;
  font-family: inherit;
  white-space: nowrap;
}
.save-preset-row button:hover { background: var(--border); }

/* THE scrollable region, this is the only part that scrolls */
.layout-modal-sections {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  /* Thin scrollbar */
  scrollbar-width: thin;
}
.layout-modal-sections::-webkit-scrollbar { width: 5px; }
.layout-modal-sections::-webkit-scrollbar-track { background: transparent; }
.layout-modal-sections::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.layout-modal-footer {
  padding: 0.75rem 1.4rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ── Section editor cards ────────────────────────────── */
.le-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0; /* prevent squish */
}
.le-section.dragging { opacity: 0.4; }
.le-section.drag-over { border-color: var(--muted); }

.le-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
.le-drag-handle {
  cursor: grab;
  color: var(--muted);
  font-size: 1rem;
  padding: 0 0.15rem;
  user-select: none;
  flex-shrink: 0;
}
.le-drag-handle:active { cursor: grabbing; }
.le-section-name {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 0;
}
.le-section-name:focus { outline: none; }
.le-section-name::placeholder { color: var(--muted); }
.le-remove-section {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.1rem 0.3rem;
  font-family: inherit;
  flex-shrink: 0;
}
.le-remove-section:hover { color: #ff9999; }

.le-stats-toggle {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
  font-size: 0.72rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.le-stats-toggle input[type="checkbox"] { cursor: pointer; }

.le-ore-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.5rem 0.6rem;
  min-height: 38px;
}
.le-ore-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.45rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 600;
  user-select: none;
  cursor: grab;
  transition: opacity 0.1s, box-shadow 0.1s;
}
.le-ore-chip:active { cursor: grabbing; }
.le-ore-chip.dragging { opacity: 0.4; }
.le-ore-chip.drag-over { box-shadow: 0 0 0 2px var(--text); }
.le-chip-drag {
  display: inline-flex;
  align-items: center;
  opacity: 0.6;
  font-size: 0.7rem;
}
.le-ore-chip img {
  width: 15px; height: 15px;
  object-fit: contain;
  image-rendering: pixelated;
}
.le-chip-remove {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0;
  opacity: 0.55;
}
.le-chip-remove:hover { opacity: 1; }

.le-add-ore-btn {
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 3px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.18rem 0.45rem;
  font-family: inherit;
  align-self: center;
}
.le-add-ore-btn:hover { background: var(--border); color: var(--text); }

.le-add-section-btn {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 0.35rem 0.7rem;
  font-family: inherit;
}
.le-add-section-btn:hover { background: var(--border); color: var(--text); }

/* ── Ore picker popup ────────────────────────────────── */
.ore-picker-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 600;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.ore-picker-overlay.open { display: flex; }
.ore-picker-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  width: 440px;
  max-width: 95vw;
  max-height: 75vh;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.ore-picker-box h4 { font-size: 0.95rem; margin: 0; flex-shrink: 0; }
.ore-picker-search {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.35rem 0.6rem;
  width: 100%;
  flex-shrink: 0;
}
.ore-picker-search:focus { outline: none; border-color: var(--muted); }
.ore-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  overflow-y: auto;
  flex: 1;
  align-content: flex-start;
}
.ore-pick-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.5rem;
  border-radius: 3px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.1s, filter 0.1s;
}
.ore-pick-chip:hover { filter: brightness(1.15); }
.ore-pick-chip.already-added {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}
/* Toggle mode (Collections), selected chips stay fully clickable (to
   allow un-marking) and get a ring instead of the "locked" dim look
   already-added uses for sections. */
.ore-pick-chip.picker-selected {
  box-shadow: 0 0 0 2px var(--text);
}
.ore-pick-chip img {
  width: 16px; height: 16px;
  object-fit: contain;
  image-rendering: pixelated;
}
.ore-picker-actions { display: flex; justify-content: flex-end; flex-shrink: 0; }
.ore-picker-actions button {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.35rem 0.9rem;
  font-family: inherit;
}
.ore-picker-actions button:hover { background: var(--border); }

/* ── Section checkboxes ──────────────────────────────── */
.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.25rem;
}
.checkbox-list label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
}

@media (max-width: 580px) {
  .amount-inp { width: 75px; }
}

/* Center alignment helper reused by AV cells etc. */
.ore-table thead th.th-center { text-align: center; }

/* ── Mobile ────────────────────────────────────────────── */
@media (max-width: 480px) {
  .section-search-row .section-search-input { flex: 1 1 100%; }
}
