/* ============================================================
   Accounts module — master/detail: account list (left) + live
   statement (right). Reuses shared tokens (var(--brand-*),
   var(--gray-*) etc.) and the shared gcc-* primitives from app.css
   so the look stays consistent across the whole project.
   ============================================================ */

/* Accounts list table rows: chart-of-accounts hierarchy via dots */
.gcc-table .acc-row { cursor: default; }
.gcc-table .acc-row.acc-leaf { cursor: pointer; }
.gcc-table .acc-row.acc-leaf:hover td { background: var(--brand-50); }
.gcc-table .acc-row.acc-selected td { background: var(--brand-100); }
.gcc-table .acc-row.acc-debit td { background: var(--danger-50); }
.gcc-table .acc-row.acc-debit.acc-selected td { background: #fdd; }
.gcc-table .acc-row .acc-dots { display: inline-block; width: 0; }
.gcc-table .acc-row .acc-code { font-family: 'SFMono-Regular', 'Consolas', monospace; font-size: 11.5px; color: var(--gray-600); }
.gcc-table .acc-row .acc-name { overflow-wrap: anywhere; }
.gcc-table .acc-row.acc-head td { font-weight: 700; background: var(--surface-2); }
.gcc-table .acc-row.acc-head td.acc-code { color: var(--text); }

/* Pagination footer inside the Accounts panel */
.acc-pager {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 14px; border-top: 1px solid var(--border); background: var(--surface-2);
  font-size: 11.5px; color: var(--text-muted);
}
.acc-pager-btns { display: flex; gap: 4px; }
.acc-pager-btn {
  min-width: 28px; height: 28px; border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius-sm); cursor: pointer; font-size: 12px; color: var(--gray-700);
}
.acc-pager-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.acc-pager-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.acc-pager-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Statement header + subheader (mirrors the mini-statement modal look from
   Bank Position: navy gradient banner, white-on-dark search, stat chips) */
.acc-stmt-panel { min-height: 440px; }
.acc-stmt { display: flex; flex-direction: column; height: 100%; }
.acc-stmt-head {
  background: linear-gradient(135deg, var(--grad-deep-a) 0%, var(--grad-deep-b) 100%); color: #fff;
  padding: 13px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.acc-stmt-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; min-width: 0; }
.acc-stmt-title .acc-stmt-ic { font-size: 15px; opacity: 0.9; }
.acc-stmt-title .acc-stmt-code { color: rgba(255, 255, 255, 0.75); font-weight: 600; font-size: 12.5px; }
.acc-stmt-actions { display: flex; align-items: center; gap: 8px; }
.acc-stmt-actions .gcc-search input {
  width: 200px; background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff; padding-left: 28px;
}
.acc-stmt-actions .gcc-search input::placeholder { color: rgba(255, 255, 255, 0.7); }
.acc-stmt-actions .gcc-search i { color: rgba(255, 255, 255, 0.7); }
.acc-stmt-action-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.35);
  background: transparent; color: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.acc-stmt-action-btn:hover { background: rgba(255, 255, 255, 0.15); }

.acc-stmt-bar {
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  padding: 8px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.acc-stmt-dates { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.acc-stmt-date-field { display: flex; align-items: center; gap: 5px; }
.acc-stmt-date-field label { font-size: 11px; font-weight: 650; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.acc-stmt-date-field input[type="date"] {
  padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--text); background: var(--surface);
}
.acc-stmt-chips { display: flex; gap: 8px; flex-wrap: wrap; }

/* Movement table inside the statement: sticky header (like the ministry
   modal) + running balance column */
.acc-mov-table thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); }
.acc-mov-table td { font-variant-numeric: tabular-nums; }
.acc-mov-table td.acc-desc { overflow-wrap: anywhere; min-width: 160px; }
.acc-mov-table td.acc-mov-date { min-width: 110px; white-space: nowrap; }
.acc-mov-table .acc-num { text-align: right; }
.acc-mov-table .acc-mov-star td { background: #fef2f2; }
.acc-mov-table .acc-mov-star td.acc-num { color: var(--danger-600); }
.acc-mov-table tbody .acc-mov-row { cursor: pointer; }
.acc-mov-table tbody .acc-mov-row:hover td { background: var(--brand-50); }

/* Statement / Purchase Orders tabs above the panes */
.acc-stmt-tabs {
  display: flex; gap: 4px; padding: 6px 16px; background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.acc-stmt-tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--gray-700); font-size: 12.5px; font-weight: 650;
  cursor: pointer; transition: all .12s ease;
}
.acc-stmt-tab:hover { border-color: var(--primary); color: var(--primary); }
.acc-stmt-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.acc-stmt-tab-count {
  min-width: 18px; padding: 0 5px; border-radius: 999px; background: rgba(255, 255, 255, 0.25);
  font-size: 11px; text-align: center;
}
.acc-stmt-tab:not(.active) .acc-stmt-tab-count { background: var(--brand-100); color: var(--primary); }
.acc-stmt-pane { display: flex; flex-direction: column; min-height: 0; }

/* Purchase orders table rows (drill to LPO modal) */
.acc-orders-row { cursor: pointer; }
.acc-orders-row:hover td { background: var(--brand-50); }

.ord-badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 650; text-transform: capitalize;
}
.ord-badge.ord-critical { background: #fee2e2; color: var(--danger-700); }
.ord-badge.ord-high    { background: #ffedd5; color: #c2410c; }
.ord-badge.ord-medium  { background: #fef9c3; color: #a16207; }
.ord-badge.ord-normal  { background: var(--gray-100); color: var(--gray-600); }
.ord-badge.ord-ok      { background: #dcfce7; color: var(--success-700); }

/* LPO drill-down modal body */
.modal-box.modal-box-lpo { width: min(1280px, 100vw); }
.acc-lpo { display: flex; flex-direction: column; gap: 14px; }

/* Professional purchase-order document layout (mirrors the reference
   get_lpo_details.php: number + supplier identity, status badge, info grid) */
.acc-lpo-doc {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); overflow: hidden;
}
.acc-lpo-brand {
  background: linear-gradient(135deg, var(--grad-deep-a) 0%, var(--grad-deep-b) 100%);
  color: #fff; font-size: 10.5px; font-weight: 800; letter-spacing: 0.14em;
  text-transform: uppercase; padding: 5px 14px;
}
.acc-lpo-doc-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; padding: 14px 14px 0;
}
.acc-lpo-identity { display: flex; flex-direction: column; gap: 6px; }
.acc-lpo-number { display: flex; align-items: baseline; gap: 6px; }
.acc-lpo-value-lg { font-size: 20px; font-weight: 800; color: var(--text); letter-spacing: 0.01em; }
.acc-lpo-supplier { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 700; color: var(--text); }
.acc-lpo-supplier .bi { color: var(--primary); }
.acc-lpo-status { padding-top: 2px; }
.acc-lpo-info {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px 18px; padding: 12px 14px 14px;
}
.acc-lpo-field { display: flex; flex-direction: column; gap: 2px; }
.acc-lpo-label { font-size: 10.5px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.acc-lpo-value { font-size: 13px; color: var(--text); }
.acc-lpo-total { color: var(--primary) !important; font-size: 15px !important; font-weight: 700 !important; }
.acc-lpo-subtitle {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700;
  color: var(--gray-700); padding-bottom: 6px; border-bottom: 1px solid var(--border);
}

/* Line-item cells: item name/code/description stack, free-text kept pre-line */
.acc-lpo-item-name { font-weight: 650; overflow-wrap: anywhere; }
.acc-lpo-item-code { font-size: 10.5px; color: var(--text-muted); font-family: 'SFMono-Regular', 'Consolas', monospace; }
.acc-lpo-item-desc { white-space: pre-line; font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
.acc-lpo-item-net { font-weight: 650; }

/* LPO line-items table: the shared .bp-mov-modal rule gives the 2nd column
   min-width 110px + nowrap (meant for the date column in mini-statements),
   which would blow out the Item column. Re-scope so the item wraps and the
   whole table fits the 80%-width modal with no horizontal scroll. */
.acc-lpo .bp-pdc-table-wrap .bp-pdc-table th:nth-child(2),
.acc-lpo .bp-pdc-table-wrap .bp-pdc-table td:nth-child(2) {
  min-width: 220px; max-width: 420px; white-space: normal; overflow-wrap: anywhere;
}
.acc-lpo .bp-pdc-table-wrap .bp-pdc-table td:nth-child(4) { min-width: 0; }

.acc-stmt-empty, .acc-stmt-loading {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 48px 20px; color: var(--text-muted); text-align: center;
}
.acc-stmt-empty .bi { font-size: 34px; color: var(--gray-300); }
.acc-stmt-loading .spinner { width: 30px; height: 30px; border-width: 3px; }

/* Print: only the statement panel prints (matches the ministry modal rules) */
@media print {
  body * { visibility: hidden; }
  .acc-stmt, .acc-stmt * { visibility: visible; }
  .acc-stmt { position: fixed; inset: 0; max-height: none; overflow: auto; }
  .acc-stmt-head, .acc-stmt-bar, .acc-stmt-actions { display: none !important; }
  .acc-stmt .acc-mov-table tfoot td { background: var(--gray-900) !important; color: #fff !important; }
}
/* Statement opened as a modal (e.g. cheque supplier-no badge) */
.acc-stmt-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  background: var(--surface-2, #f8fafc);
  flex-shrink: 0;
}
.acc-stmt-modal-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.acc-stmt-modal-body .acc-stmt { flex: 1; min-height: 0; }
