/* ── WAREHOUSE VIEW ─────────────────────────────────────────────────────────
   Tries to match the rest of the dashboard:
   uses .dash-view__inner padding/gap, .select-wrap arrows, .btn/.input tokens.
*/

/* Toolbar above the items table (search + scope + location + add button) */
.wh-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 200px 220px auto;
  gap: var(--sp-3);
  align-items: center;
}
.wh-toolbar__search {
  position: relative;
}
.wh-toolbar__search .input {
  padding-left: 38px;
  width: 100%;
}
.wh-toolbar__search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.wh-toolbar__select { width: 100%; }

@media (max-width: 960px) {
  .wh-toolbar {
    grid-template-columns: 1fr 1fr;
  }
  .wh-toolbar__search { grid-column: 1 / -1; }
  .wh-toolbar .btn { grid-column: 1 / -1; }
}

/* Make the warehouse-select in the header behave like other header dropdowns */
#view-warehouse .view-header .select-wrap .select-input {
  height: 40px;
  min-height: 40px;
  font-size: var(--text-sm);
  padding-top: 0;
  padding-bottom: 0;
}

/* Custom-field filter chips */
.wh-custom-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.wh-custom-filters .wh-cf-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 6px 10px;
}
.wh-custom-filters .wh-cf-chip__label {
  color: var(--muted-strong);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.wh-custom-filters .wh-cf-chip input {
  height: 28px;
  border: 0;
  background: transparent;
  outline: 0;
  font: inherit;
  color: var(--text);
  min-width: 120px;
  padding: 0;
}

/* Items table */
.wh-table-card {
  padding: 0;
  overflow: hidden;
}
.wh-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.wh-table thead th {
  text-align: left;
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-strong);
  padding: var(--sp-3) var(--sp-4);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
}
.wh-table tbody tr {
  border-top: 1px solid var(--line);
}
.wh-table tbody tr:hover {
  background: var(--panel-hover);
}
.wh-table tbody td {
  padding: var(--sp-3) var(--sp-4);
  vertical-align: middle;
}
.wh-table .wh-cell-photo {
  width: 56px;
}
.wh-table .wh-cell-photo img,
.wh-table .wh-cell-photo .wh-photo-empty {
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  object-fit: cover;
  display: block;
}
.wh-table .wh-cell-photo img.wh-thumb { cursor: zoom-in; }
.wh-photo-grid__cell img { cursor: zoom-in; }
.wh-table .wh-cell-photo .wh-photo-empty {
  background: var(--panel-strong);
  border: 1px dashed var(--line-strong);
}
.wh-table .wh-cell-sku {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--text-xs);
  color: var(--muted-strong);
  white-space: nowrap;
}
.wh-table .wh-cell-actions {
  white-space: nowrap;
  width: 1%;            /* shrink-to-fit so the column matches its header */
  text-align: left;
}
.wh-table .wh-cell-actions .btn + .btn {
  margin-left: var(--sp-2);
}
/* row hover/click affordance */
.wh-table tbody tr.wh-row {
  cursor: pointer;
}
.wh-table tbody tr.wh-row:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: -2px;
}
/* dangerous action gets a red tint on hover so it can't be confused with QR */
.wh-table .wh-btn-danger {
  color: var(--red);
}
.wh-table .wh-btn-danger:hover {
  background: var(--red-dim);
  color: var(--red);
}
.wh-table .wh-empty {
  padding: var(--sp-8) var(--sp-4);
  text-align: center;
  color: var(--muted-strong);
}

/* ── WAREHOUSE MODAL (built by warehouse.js) ──────────────────────────── */
.wh-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
}
.wh-modal {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
}
.wh-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--line);
}
.wh-modal__title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 700;
}
.wh-modal__body {
  padding: var(--sp-5) var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.wh-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--line);
  background: var(--panel);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* form rows inside warehouse modals */
.wh-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-5);
}
@media (max-width: 720px) {
  .wh-form-grid { grid-template-columns: 1fr; }
}
.wh-field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.wh-field-row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: var(--sp-3);
}

/* item editor photo grid */
.wh-photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
  min-height: 80px;
}
.wh-photo-grid__cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--panel);
}
.wh-photo-grid__cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.wh-photo-grid__remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  line-height: 22px;
  text-align: center;
  padding: 0;
}
.wh-photo-grid__empty {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: var(--text-sm);
  background: var(--panel);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  padding: var(--sp-4);
}

.wh-photo-actions {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.wh-qr-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.wh-qr-block img {
  width: 180px;
  height: 180px;
  background: #fff;
  padding: 8px;
  border-radius: var(--r-sm);
}
.wh-qr-block code {
  font-size: var(--text-xs);
  word-break: break-all;
  color: var(--muted-strong);
}

.wh-cf-list,
.wh-loc-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.wh-cf-list__row,
.wh-loc-list__row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-top: 1px solid var(--line);
}
.wh-cf-list__row:first-child,
.wh-loc-list__row:first-child {
  border-top: 0;
}
.wh-cf-list__row > span,
.wh-loc-list__row > span {
  flex: 1;
}
.wh-cf-list__row small,
.wh-loc-list__row small {
  color: var(--muted);
}

/* publish-to-shared checkbox */
.wh-publish {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.wh-publish label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  font-size: var(--text-sm);
}

/* serial numbers */
.wh-serials-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-bottom: var(--sp-2);
}
.wh-serials-empty {
  font-size: var(--text-sm);
  color: var(--text-muted);
  padding: var(--sp-1) 0;
}
.wh-serial-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-sm);
  background: var(--bg-alt, rgba(0,0,0,.04));
  font-size: var(--text-sm);
}
.wh-serial-sn {
  font-family: monospace;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wh-serial-desc {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wh-serial-del {
  padding: 2px 6px;
  font-size: 1rem;
  line-height: 1;
  color: var(--danger, #c00);
  flex-shrink: 0;
}
.wh-serial-add-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: var(--sp-2);
  align-items: center;
}
.wh-serial-add-row .input {
  padding-top: 5px;
  padding-bottom: 5px;
  font-size: var(--text-sm);
}
.wh-serial-count {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: normal;
  margin-left: var(--sp-1);
}
.wh-serial-badge {
  display: inline-block;
  margin-left: var(--sp-2);
  padding: 1px 6px;
  border-radius: 999px;
  font-size: var(--text-xs);
  background: var(--accent-alpha, rgba(99,102,241,.15));
  color: var(--accent, #6366f1);
  vertical-align: middle;
  white-space: nowrap;
}

/* invite block */
.wh-invite-row {
  display: flex;
  gap: var(--sp-2);
}
.wh-invite-row .input {
  flex: 1;
}
.wh-invite-qr {
  text-align: center;
  padding: var(--sp-3);
}
.wh-invite-qr img {
  width: 200px;
  height: 200px;
  background: #fff;
  padding: 8px;
  border-radius: var(--r-sm);
}

/* ── Публичная витрина (модалка) ─────────────────────────────────── */
.wh-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 500;
  user-select: none;
}
.wh-switch input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent, #4f7cff);
  cursor: pointer;
}
