/* warehouse.css — дополнения к foreman.css для кладовщика */

/* ── Column freeze override ─────────────────────────────────────────────────
   foreman.css freezes columns 1-3 for the foreman table (Date / Installer / Client).
   Warehouse table columns are different, so we un-freeze cols 2 and 3 and keep
   only column 1 (Клиент) sticky. */
#warehouse-view .fm-table th:nth-child(2),
#warehouse-view .fm-table td:nth-child(2),
#warehouse-view .fm-table th:nth-child(3),
#warehouse-view .fm-table td:nth-child(3) {
  position: static;
  left: auto;
  z-index: auto;
  box-shadow: none;
}

/* Move the freeze-edge shadow to column 1 in warehouse */
#warehouse-view .fm-table td:nth-child(1),
#warehouse-view .fm-table th:nth-child(1) {
  box-shadow: 2px 0 4px rgba(0, 0, 0, .08);
  min-width: 150px;
}

.wh-cell-warn {
  background: #fff3cd !important;
}

/* Cancelled deal row — красная подсветка (Закрыто и не реализовано) */
.wh-row-cancelled td {
  background: rgba(229, 62, 62, 0.10);
}
.fm-table tbody tr.wh-row-cancelled:hover td {
  background: rgba(229, 62, 62, 0.18);
}
[data-theme="dark"] .wh-row-cancelled td {
  background: rgba(229, 62, 62, 0.18);
}
[data-theme="dark"] .fm-table tbody tr.wh-row-cancelled:hover td {
  background: rgba(229, 62, 62, 0.26);
}

/* Status column badges */
.wh-cell-deal-status {
  white-space: nowrap;
  text-align: center;
  min-width: 90px;
}
.wh-badge-cancelled {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: #e53e3e;
  color: #fff;
}
.wh-badge-active {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  background: #c6f6d5;
  color: #276749;
}
[data-theme="dark"] .wh-badge-active {
  background: rgba(39, 103, 73, 0.35);
  color: #9ae6b4;
}

/* Installer = Доставка — ярко-зелёная подсветка */
.wh-cell-installer-delivery {
  background: #48bb78 !important;
  color: #fff;
  font-weight: 700;
}
[data-theme="dark"] .wh-cell-installer-delivery {
  background: #38a169 !important;
  color: #f0fff4;
}

.wh-cell-instock {
  background: #c6f6d5 !important;
}
.wh-cell-instock input {
  background: #9ae6b4 !important;
  font-weight: 700;
  color: #1c4532;
}

.wh-cell-invoice-dup {
  background: #ff1744 !important;
}
.wh-cell-invoice-dup input {
  background: #ff1744 !important;
  color: #fff !important;
  font-weight: 700;
}
[data-theme="dark"] .wh-cell-instock {
  background: rgba(56, 161, 105, 0.30) !important;
}
[data-theme="dark"] .wh-cell-instock input {
  background: rgba(56, 161, 105, 0.45) !important;
  color: #c6f6d5;
}
.wh-instock-badge {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  color: #276749;
  margin-bottom: 3px;
  white-space: nowrap;
}
[data-theme="dark"] .wh-instock-badge {
  color: #9ae6b4;
}

/* «Новые»: счёт на такую станцию уже есть в строке-маркере — ярко-зелёная ячейка счёта */
.wh-cell-invoice-avail {
  background: #48bb78 !important;
}
.wh-cell-invoice-avail input {
  background: #38a169 !important;
  color: #fff !important;
  font-weight: 700;
}
[data-theme="dark"] .wh-cell-invoice-avail {
  background: rgba(56, 161, 105, 0.40) !important;
}
[data-theme="dark"] .wh-cell-invoice-avail input {
  background: rgba(56, 161, 105, 0.55) !important;
  color: #f0fff4 !important;
}
.wh-invoice-avail-badge {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 3px;
  white-space: nowrap;
}

/* Строка-маркер «счёт»/«склад» — бейдж в ячейке «Клиент» */
.wh-marker-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
}
.wh-marker-inv { background: #3182ce; }   /* СЧЁТ — синий */
.wh-marker-wh  { background: #805ad5; }    /* СКЛАД — фиолетовый */
[data-theme="dark"] .wh-marker-inv { background: #2b6cb0; }
[data-theme="dark"] .wh-marker-wh  { background: #6b46c1; }

/* Вкладка «На складе» — маленькая аккуратная таблица под содержимое (не на всю ширину).
   Ужимаем И обёртку (бордюр/фон), и саму таблицу: базовый .fm-table имеет min-width:100%,
   а .fm-table-wrap — блок на всю ширину, поэтому переопределяем оба. */
#warehouse-view .wh-stock-wrap { width: max-content; max-width: 100%; }
#warehouse-view .wh-table-stock { width: auto; min-width: 0; }
#warehouse-view .wh-table-stock th,
#warehouse-view .wh-table-stock td { white-space: nowrap; width: 1%; }
#warehouse-view .wh-table-stock td:nth-child(2),
#warehouse-view .wh-table-stock th:nth-child(2) { text-align: center; }

/* Terminal payment row highlight */
.wh-row-terminal td {
  background: #fff3cd;
}
.fm-table tbody tr.wh-row-terminal:hover td {
  background: #ffe69c;
}
[data-theme="dark"] .wh-row-terminal td {
  background: rgba(255, 193, 7, 0.18);
}
[data-theme="dark"] .fm-table tbody tr.wh-row-terminal:hover td {
  background: rgba(255, 193, 7, 0.28);
}
.wh-cell-product {
  max-width: 220px;
  font-size: 12px;
  line-height: 1.35;
}
.wh-status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-l, #e8f4f4);
  color: var(--accent, #01696f);
  white-space: nowrap;
}
.wh-data-title {
  margin: 16px 20px 8px;
  font-size: 14px;
  font-weight: 700;
}
.wh-data-table .fm-inline-text {
  min-width: 120px;
}
.wh-add-row {
  background: #f4f8ff;
}
.wh-add-row td {
  vertical-align: middle;
}

/* ── Archive checkbox column ─────────────────────────────────────────────────*/
.wh-archive-cell {
  background: #fff8f0 !important;
}
.wh-archive-cell input[type="checkbox"] {
  accent-color: #e07000;
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.wh-archive-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  background: #fde8c8;
  color: #9a4900;
  margin-left: 4px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: .03em;
}

/* Sub-tabs inside "Данные" section */
.wh-data-seg {
  margin: 0;
  padding: 8px 20px 0;
  border-bottom: 1px solid var(--border, #e0e0e0);
  flex-shrink: 0;
}
.wh-data-panel {
  padding: 12px 0 8px;
}

/* ── Column width overrides: Поставщик (−20%) and Горловина (−50%) ────────────*/
#warehouse-view .wh-cell-supplier {
  max-width: 128px;
  width: 128px;
}
#warehouse-view .wh-cell-supplier .fm-inline-select {
  max-width: 100%;
  width: 100%;
}
#warehouse-view .fm-cell-neck {
  max-width: 80px;
  width: 80px;
}
#warehouse-view .fm-cell-neck .fm-inline-text {
  max-width: 72px;
  width: 72px;
}

/* ── Счёт column: −30% (160px → 112px) in Новые / В работе ────────────────*/
#warehouse-view .wh-table-new th:nth-child(5),
#warehouse-view .wh-table-new td:nth-child(5),
#warehouse-view .wh-table-work th:nth-child(5),
#warehouse-view .wh-table-work td:nth-child(5) {
  width: 112px;
  max-width: 112px;
  min-width: 72px;
  box-sizing: border-box;
}
#warehouse-view .wh-table-new td:nth-child(5) .fm-inline-text,
#warehouse-view .wh-table-work td:nth-child(5) .fm-inline-text {
  max-width: 104px;
  width: 100%;
  box-sizing: border-box;
}

/* ── Завершенные: «В архив» −75% (150px → 38px), клиент sticky ─────────────*/
#warehouse-view .wh-table-done th:nth-child(1),
#warehouse-view .wh-table-done td:nth-child(1) {
  position: static;
  left: auto;
  z-index: auto;
  box-shadow: none;
  width: 38px;
  max-width: 38px;
  min-width: 38px;
  padding-left: 4px;
  padding-right: 4px;
  text-align: center;
  box-sizing: border-box;
}
#warehouse-view .wh-table-done th:nth-child(1) {
  font-size: 10px;
  white-space: normal;
  line-height: 1.15;
}
#warehouse-view .wh-table-done th:nth-child(2),
#warehouse-view .wh-table-done td:nth-child(2) {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface, #fff);
  box-shadow: 2px 0 4px rgba(0, 0, 0, .08);
  min-width: 150px;
}
#warehouse-view .wh-table-done th:nth-child(2) {
  z-index: 3;
  background: var(--card-bg, #f5f5f5);
}
#warehouse-view .wh-table-work th:nth-child(1),
#warehouse-view .wh-table-work td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface, #fff);
  box-shadow: none;
  width: 48px;
  max-width: 48px;
  min-width: 48px;
  padding-left: 4px;
  padding-right: 4px;
  text-align: center;
  box-sizing: border-box;
}
#warehouse-view .wh-table-work th:nth-child(1) {
  font-size: 10px;
  white-space: normal;
  line-height: 1.15;
  z-index: 3;
  background: var(--card-bg, #f5f5f5);
}
#warehouse-view .wh-table-work th:nth-child(2),
#warehouse-view .wh-table-work td:nth-child(2) {
  position: sticky;
  left: 48px;
  z-index: 2;
  background: var(--surface, #fff);
  box-shadow: 2px 0 4px rgba(0, 0, 0, .08);
  min-width: 150px;
}
#warehouse-view .wh-table-work th:nth-child(2) {
  z-index: 3;
  background: var(--card-bg, #f5f5f5);
}
#warehouse-view .wh-table-work th:nth-child(3),
#warehouse-view .wh-table-work td:nth-child(3) {
  position: static;
  left: auto;
  z-index: auto;
  box-shadow: none;
}

/* ── Sticky header pin (warehouse) ───────────────────────────────────────────
   Must NOT depend on #warehouse-view — pin moves to document.body when fixed. */
.fm-thead-pin .fm-thead-pin-table.wh-table-new th:nth-child(1) {
  position: sticky !important;
  left: 0;
  z-index: 27;
  box-shadow: 2px 0 4px rgba(0, 0, 0, .08);
}
.fm-thead-pin .fm-thead-pin-table.wh-table-new th:nth-child(2),
.fm-thead-pin .fm-thead-pin-table.wh-table-new th:nth-child(3) {
  position: static !important;
  left: auto;
  box-shadow: none;
}
.fm-thead-pin .fm-thead-pin-table.wh-table-new th:nth-child(5) {
  width: 112px;
  max-width: 112px;
  min-width: 72px;
}
.fm-thead-pin .fm-thead-pin-table.wh-table-done th:nth-child(1) {
  position: static !important;
  left: auto !important;
  z-index: auto !important;
  box-shadow: none !important;
  width: 38px;
  max-width: 38px;
  min-width: 38px;
  padding-left: 4px;
  padding-right: 4px;
  text-align: center;
  font-size: 10px;
  white-space: normal;
  line-height: 1.15;
}
.fm-thead-pin .fm-thead-pin-table.wh-table-done th:nth-child(2) {
  position: sticky !important;
  left: 0 !important;
  z-index: 27 !important;
  box-shadow: 2px 0 4px rgba(0, 0, 0, .08);
  min-width: 150px;
}
.fm-thead-pin .fm-thead-pin-table:not(.wh-table-work):not(.wh-table-done):not(.wh-data-table) th:nth-child(1) {
  position: sticky !important;
  left: 0;
  z-index: 27;
  box-shadow: 2px 0 4px rgba(0, 0, 0, .08);
}
.fm-thead-pin .fm-thead-pin-table:not(.wh-table-work):not(.wh-table-done):not(.wh-data-table) th:nth-child(2),
.fm-thead-pin .fm-thead-pin-table:not(.wh-table-work):not(.wh-table-done):not(.wh-data-table) th:nth-child(3) {
  position: static !important;
  left: auto;
  box-shadow: none;
}

/* В работе: cols 1–2 (архив + клиент) sticky in pin header */
.fm-thead-pin .fm-thead-pin-table.wh-table-work th:nth-child(1) {
  position: sticky !important;
  left: 0 !important;
  z-index: 27 !important;
  box-shadow: none !important;
  width: 48px;
  max-width: 48px;
  min-width: 48px;
  padding-left: 4px;
  padding-right: 4px;
  text-align: center;
  font-size: 10px;
  white-space: normal;
  line-height: 1.15;
  background: var(--card-bg, #f5f5f5);
}
.fm-thead-pin .fm-thead-pin-table.wh-table-work th:nth-child(2) {
  position: sticky !important;
  left: 48px !important;
  z-index: 28 !important;
  box-shadow: 2px 0 4px rgba(0, 0, 0, .08);
  min-width: 150px;
  background: var(--card-bg, #f5f5f5);
}
.fm-thead-pin .fm-thead-pin-table.wh-table-work th:nth-child(3) {
  position: static !important;
  left: auto !important;
  z-index: auto !important;
  box-shadow: none !important;
}
.fm-thead-pin .fm-thead-pin-table.wh-table-work th:nth-child(5) {
  width: 112px;
  max-width: 112px;
  min-width: 72px;
}

/* ── Выборка по поставщику ───────────────────────────────────── */
.wh-invoice-missing {
  background: #fff8e1 !important;
}
[data-theme="dark"] .wh-invoice-missing {
  background: rgba(255, 220, 50, 0.13) !important;
}

/* Wrap shrinks to content width — table is compact, left-aligned */
#warehouse-view .fm-table-wrap:has(.wh-table-supplier) {
  width: fit-content;
  max-width: 100%;
}
#warehouse-view .wh-table-supplier {
  width: auto;
  min-width: auto;
}

/* Col 2: Дата поставки */
#warehouse-view .wh-table-supplier th:nth-child(2),
#warehouse-view .wh-table-supplier td:nth-child(2) {
  width: 110px;
  min-width: 100px;
  white-space: nowrap;
}
/* Col 4: Счёт */
#warehouse-view .wh-table-supplier th:nth-child(4),
#warehouse-view .wh-table-supplier td:nth-child(4) {
  width: 112px;
  min-width: 90px;
}

.fm-thead-pin .fm-thead-pin-table.wh-table-supplier th:nth-child(2) {
  width: 110px;
  min-width: 100px;
}
.fm-thead-pin .fm-thead-pin-table.wh-table-supplier th:nth-child(4) {
  width: 112px;
  max-width: 112px;
  min-width: 72px;
}
