/* Opening Stock panel (FR-104) — scoped under .open-stock.
   theme.css is loaded globally (client/index.html), but --rw-* tokens do NOT
   reliably resolve inside the billingSkin1 modals, so every token carries a
   literal fallback matching the design system and styling never collapses. */

/* Clip the ui-bootstrap modal shell so the header's rounded corners stay clean. */
.open-stock-modal-window .modal-content {
  border-radius: 14px;
  overflow: hidden;
  border: none;
}
.open-stock-modal-window .modal-body { padding: 0; }
/* Use the screen: wide dialog, small top/bottom margins. */
.open-stock-modal-window .modal-dialog {
  width: 92vw;
  max-width: 1180px;
  margin: 3vh auto;
}

.open-stock {
  display: flex;
  flex-direction: column;
  height: 90vh;
  max-height: 90vh;
  font-family: var(--rw-font, inherit);
  color: var(--rw-text, #1F2937);
}

/* ── header — title row + the read-only summary strip ── */
.open-stock-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 22px;
  background: linear-gradient(135deg, var(--rw-primary, #0E52C1) 0%, var(--rw-primary-end, #5B8FFF) 100%);
  color: #fff;
}
.open-stock-head-main {
  display: flex;
  align-items: center;
  gap: 14px;
}
.open-stock-head-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.open-stock-head-titlewrap { flex: 1; min-width: 0; }
.open-stock-head-title { margin: 0; font-size: 17px; font-weight: 700; }
.open-stock-head-sub { font-size: 12px; opacity: 0.85; }
.open-stock-btn-fetch {
  height: 34px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.open-stock-btn-fetch i { margin-right: 5px; }
.open-stock-btn-fetch:hover { background: rgba(255, 255, 255, 0.26); }
.open-stock-btn-fetch[disabled] { opacity: 0.6; cursor: not-allowed; }
.open-stock-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}

/* ── body ──
   Column layout so the table scrolls on its own: the filters stay put and the
   sticky table head has a scroll container to stick to. */
.open-stock-body {
  display: flex;
  flex-direction: column;
  padding: 16px 22px;
  flex: 1;
  min-height: 0;
  background: var(--rw-bg, #F5F6F8);
}

/* ── summary strip — READ-ONLY counts inside the header.
   Deliberately inert: no ng-click, no pointer, no hover affordance. Filtering
   is done from the chips on the filter line. ── */
.open-stock-summary {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-wrap: wrap;
}
.open-stock-stat {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 9px;
  cursor: default;
}
.open-stock-stat-num { font-size: 18px; font-weight: 700; line-height: 1.1; color: #fff; }
.open-stock-stat-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
}
/* Status is carried by a left rule, since coloured numerals would not read on
   the gradient. */
.open-stock-stat.is-in { border-left: 3px solid #4ade80; }
.open-stock-stat.is-low { border-left: 3px solid #fbbf24; }
.open-stock-stat.is-out { border-left: 3px solid #f87171; }

/* ── one filter line: chips, search, supercategory, category, sort ── */
.open-stock-filterbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.open-stock-search { position: relative; flex: 1 1 190px; min-width: 160px; }
.open-stock-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--rw-text-light, #6B7280);
  font-size: 13px;
  z-index: 1;
}
.open-stock-input {
  height: 38px;
  border: 1px solid var(--rw-border, #E2E5EA);
  border-radius: 9px;
  background: var(--rw-white, #fff);
  font-size: 13px;
  box-shadow: none;
  color: var(--rw-text, #1F2937);
}
.open-stock-search .open-stock-input { padding-left: 34px; }
.open-stock-input:focus {
  border-color: var(--rw-primary, #0E52C1);
  box-shadow: 0 0 0 3px var(--rw-shadow-sm, rgba(0, 70, 255, 0.08));
}
/* Supercategory + category — searchable ui-selects. Clicking opens the full
   list; the dropdown carries its own search box. */
.open-stock-selwrap { position: relative; flex: 1 1 170px; min-width: 150px; }
.open-stock-select { width: 100%; display: block; }
.open-stock-select .ui-select-toggle,
.open-stock-select .ui-select-match > .btn {
  min-height: 38px;
  border-radius: 9px;
  border: 1px solid var(--rw-border, #E2E5EA);
  background: var(--rw-white, #fff);
  font-size: 13px;
  color: var(--rw-text, #1F2937);
  box-shadow: none;
  display: flex;
  align-items: center;
}
.open-stock-select .ui-select-choices { max-height: 260px; overflow-y: auto; }

.open-stock-chips { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.open-stock-chip {
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--rw-border, #E2E5EA);
  background: var(--rw-white, #fff);
  color: var(--rw-text, #1F2937);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.open-stock-chip i { margin-right: 4px; font-size: 11px; }
.open-stock-chip.active {
  background: var(--rw-primary, #0E52C1);
  border-color: var(--rw-primary, #0E52C1);
  color: #fff;
}
.open-stock-chip.is-in.active { background: #16a34a; border-color: #16a34a; }
.open-stock-chip.is-low.active { background: #d97706; border-color: #d97706; }
.open-stock-chip.is-out.active { background: #dc2626; border-color: #dc2626; }
.open-stock-sortlabel {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--rw-text-light, #6B7280);
  margin: 0;
}
.open-stock-sort {
  width: auto;
  flex: 0 1 auto;
  min-width: 148px;
  height: 32px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--rw-border, #E2E5EA);
  background: var(--rw-white, #fff);
  font-size: 12px;
  font-weight: 600;
  color: var(--rw-text, #1F2937);
  box-shadow: none;
}
.open-stock-btn-plain {
  height: 32px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--rw-border, #E2E5EA);
  background: var(--rw-white, #fff);
  font-size: 12px;
  font-weight: 600;
  color: var(--rw-text, #1F2937);
  cursor: pointer;
}
.open-stock-btn-plain i { margin-right: 4px; }

/* ── table ── */
.open-stock-table-wrap {
  background: var(--rw-white, #fff);
  border: 1px solid var(--rw-border, #E2E5EA);
  border-radius: 12px;
  overflow-y: auto;
  overflow-x: auto;
  flex: 1;
  min-height: 0;
}
.open-stock-table {
  width: 100%;
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
}
/* Child-combinator form so this outranks Bootstrap's `.table > thead > tr > th`
   (0,1,3), which otherwise wins on padding and border regardless of load order. */
.open-stock-table > thead > tr > .open-stock-th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--rw-surface, #f1f5f9);
  color: var(--rw-text-light, #6B7280);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--rw-border, #E2E5EA);
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.open-stock-table > thead > tr > .open-stock-th-num { width: 70px; }
.open-stock-table > thead > tr > .open-stock-th-cat { width: 18%; }
.open-stock-table > thead > tr > .open-stock-th-qty { width: 210px; }
.open-stock-table > thead > tr > .open-stock-th-updated { width: 150px; cursor: default; }
.open-stock-table > thead > tr > .open-stock-th-user { width: 130px; cursor: default; }
.open-stock-sorticon { margin-left: 5px; color: var(--rw-primary, #0E52C1); }

.open-stock-row { border-bottom: 1px solid #eef1f5; transition: background 0.12s; }
.open-stock-row:hover { background: var(--rw-surface, #f8fafc); }
.open-stock-row.is-out { background: #fef2f2; }
.open-stock-row.is-low { background: #fffbeb; }

/* Same reason as the header rule — outrank `.table > tbody > tr > td`, which
   would otherwise re-impose Bootstrap's 8px padding and top border. */
.open-stock-table > tbody > tr > .open-stock-td {
  padding: 9px 14px;
  font-size: 13px;
  vertical-align: middle;
  border-top: none;
  border-bottom: 1px solid #eef1f5;
}
.open-stock-td-num { color: #94a3b8; font-size: 12px; }
.open-stock-name { font-weight: 600; color: var(--rw-text, #1F2937); }
.open-stock-row.is-out .open-stock-name { color: #dc2626; }
.open-stock-td-cat { color: var(--rw-text-light, #6B7280); }
.open-stock-cat { display: block; }
.open-stock-scat { display: block; font-size: 11px; color: #94a3b8; }
.open-stock-td-updated, .open-stock-td-user { color: var(--rw-text-light, #6B7280); font-size: 12px; }

/* ── quantity cell ── */
.open-stock-qtywrap { display: flex; align-items: center; gap: 8px; }
.open-stock-qty {
  width: 88px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--rw-border, #E2E5EA);
  background: var(--rw-white, #fff);
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  box-shadow: none;
  color: var(--rw-text, #1F2937);
}
.open-stock-qty:focus {
  border-color: var(--rw-primary, #0E52C1);
  box-shadow: 0 0 0 3px var(--rw-shadow-sm, rgba(0, 70, 255, 0.08));
}
.open-stock-qty[disabled] { background: #f1f5f9; color: #94a3b8; }
.open-stock-lock { color: #94a3b8; font-size: 11px; }

/* ── stock badges ── */
.open-stock-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.open-stock-badge.is-in { background: #dcfce7; color: #15803d; }
.open-stock-badge.is-low { background: #fef3c7; color: #b45309; }
.open-stock-badge.is-out { background: #fee2e2; color: #dc2626; }
.open-stock-badge.is-unset { background: #eef1f5; color: #64748b; }

/* ── pager ── */
.open-stock-pager {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 4px 4px 0;
}
.open-stock-pager-info { font-size: 12px; color: var(--rw-text-light, #6B7280); }
.open-stock-pager-spacer { flex: 1; }
.open-stock-pager-page { font-size: 12px; font-weight: 600; color: var(--rw-text, #1F2937); }
.open-stock-pager-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--rw-border, #E2E5EA);
  background: var(--rw-white, #fff);
  color: var(--rw-text, #1F2937);
  font-size: 13px;
  cursor: pointer;
}
.open-stock-pager-btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.open-stock-pager-btn:not([disabled]):hover { border-color: var(--rw-primary, #0E52C1); color: var(--rw-primary, #0E52C1); }

/* ── empty ── */
.open-stock-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--rw-text-light, #6B7280);
  background: var(--rw-white, #fff);
  border: 1px solid var(--rw-border, #E2E5EA);
  border-radius: 12px;
}
.open-stock-empty i { font-size: 30px; color: #cbd5e1; display: block; margin-bottom: 10px; }
.open-stock-empty-text strong { display: block; color: var(--rw-text, #1F2937); margin-bottom: 4px; }
.open-stock-empty-text span { font-size: 12px; }
.open-stock-empty .open-stock-btn-plain { margin-top: 14px; }

/* ── footer ── */
.open-stock-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--rw-border, #E2E5EA);
  background: var(--rw-white, #fff);
}
.open-stock-foot-meta { font-size: 13px; color: var(--rw-text-light, #6B7280); }
.open-stock-foot-spacer { flex: 1; }
.open-stock-footer .btn { min-width: 110px; font-weight: 600; }
