/* ============================================================
   Bank Position module — namespaced --bp- component classes.
   Reuses the shared design tokens from app.css (var(--brand-*),
   var(--gray-*), var(--radius*), var(--shadow*), var(--ease)) rather
   than redefining color/spacing values, per this app's convention of
   shared token values + per-module namespaced component classes.
   ============================================================ */

.bp-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.bp-toolbar-actions { display: flex; gap: 10px; }

.bp-warning-banner {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--warning-50); border: 1px solid rgba(217, 119, 6, 0.25);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px;
  font-size: 13px; color: var(--gray-800);
}
.bp-warning-banner i { color: var(--warning-600); font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.bp-warning-banner table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 12.5px; background: #fff; border-radius: 8px; overflow: hidden; }
.bp-warning-banner th, .bp-warning-banner td { padding: 6px 10px; border-bottom: 1px solid var(--gray-100); text-align: left; }
.bp-warning-banner thead th { position: sticky; top: 0; background: #fff; z-index: 1; }
.bp-warning-banner td.bp-amount, .bp-warning-banner th.bp-amount { text-align: right; }
.bp-warning-close { margin-left: auto; background: none; border: none; color: var(--gray-500); cursor: pointer; font-size: 16px; }

/* KPI strip */
.bp-kpi-grid {
  display: grid; grid-template-columns: repeat(8, minmax(150px, 1fr)); gap: 10px;
  margin-bottom: 16px; overflow-x: auto; padding-bottom: 2px;
}
.bp-kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 12px; box-shadow: var(--shadow-sm); min-width: 0;
}
.bp-kpi-top { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.bp-kpi-icon {
  width: 26px; height: 26px; border-radius: 8px; display: flex; align-items: center;
  justify-content: center; font-size: 12.5px; flex-shrink: 0;
}
.bp-kpi-icon.primary { background: var(--brand-50); color: var(--brand-600); }
.bp-kpi-icon.success { background: var(--success-50); color: var(--success-600); }
.bp-kpi-icon.danger { background: var(--danger-50); color: var(--danger-600); }
.bp-kpi-icon.info { background: var(--info-50); color: var(--info-500); }
.bp-kpi-icon.warning { background: var(--warning-50); color: var(--warning-600); }
.bp-kpi-icon.secondary { background: var(--gray-100); color: var(--gray-600); }
.bp-kpi-label { font-size: 10.5px; color: var(--text-muted); font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.bp-kpi-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.bp-kpi-value { font-size: 16px; font-weight: 750; color: var(--text); letter-spacing: -0.01em; white-space: nowrap; }
.bp-kpi-tag { font-size: 10px; font-weight: 650; display: flex; align-items: center; gap: 3px; white-space: nowrap; }
.bp-kpi-tag.positive { color: var(--success-600); }
.bp-kpi-tag.negative { color: var(--danger-600); }
.bp-kpi-tag.neutral { color: var(--gray-500); }

/* Bank cards on the left, three separate chart cards stacked in a fixed-
   width column on the right. The sidebar's width is fixed (not a flex
   fraction) so chart size stays bounded regardless of viewport -- that,
   plus maintainAspectRatio:false + a fixed .bp-chart-container height, is
   what keeps these charts from ballooning the way they used to. */
.bp-layout { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
@media (max-width: 1300px) { .bp-layout { grid-template-columns: 1fr; } }

.bp-cards-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 1750px) { .bp-cards-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1300px) { .bp-cards-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px) { .bp-cards-grid { grid-template-columns: 1fr; } }

/* Bank card */
.bp-bank-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); overflow: hidden; display: flex; flex-direction: column;
}
.bp-bank-card-header {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 18px 16px 14px; border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
}
.bp-bank-logo { height: 34px; max-width: 82%; object-fit: contain; }
.bp-bank-logo-fallback {
  width: 38px; height: 38px; border-radius: 10px; background: var(--brand-50); color: var(--brand-600);
  display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.bp-bank-name { font-size: 10.5px; font-weight: 700; color: var(--gray-500); letter-spacing: 0.05em; text-transform: uppercase; }

.bp-bank-table { width: 100%; border-collapse: collapse; font-size: 12.5px; table-layout: fixed; }
.bp-bank-table col.bp-col-label { width: 60%; }
.bp-bank-table col.bp-col-amount { width: 40%; }
.bp-row { border-bottom: 1px solid var(--gray-100); }
.bp-row td { padding: 8px 12px; vertical-align: middle; }
.bp-row.bp-clickable { cursor: default; }
.bp-row .bp-label { display: flex; align-items: center; gap: 6px; color: var(--gray-700); min-width: 0; }
.bp-row .bp-label span { overflow-wrap: anywhere; }
.bp-row .bp-label .bi { font-size: 12.5px; color: var(--gray-400); flex-shrink: 0; }
.bp-row .bp-amount { text-align: right; font-weight: 650; color: var(--text); overflow-wrap: anywhere; }

.bp-section-header { cursor: pointer; background: var(--surface-2); user-select: none; }
.bp-section-header:hover { background: var(--gray-100); }
.bp-section-header .bp-label { font-weight: 650; color: var(--text); }
.bp-section-header .bp-chevron { margin-left: auto; transition: transform 0.15s ease; color: var(--gray-400); font-size: 11px; }
.bp-section-header.expanded .bp-chevron { transform: rotate(180deg); }
.bp-amount.highlight-red { color: var(--danger-600); }
.bp-amount.highlight-green { color: var(--success-600); }
.bp-amount.highlight-blue { color: var(--brand-600); }

/* display:none (not max-height/overflow) -- browsers largely ignore
   max-height/overflow on <tbody> (a table-row-group box), so an
   animated-height collapse silently never collapses here. */
.bp-detail-section { display: none; background: #fbfcfe; }
.bp-detail-section.show { display: table-row-group; }
.bp-detail-row td { padding: 6px 10px 6px 28px; font-size: 12px; overflow-wrap: anywhere; }
.bp-detail-row .bp-label-sub { color: var(--text-muted); }
.bp-detail-row .bp-label-sub.bp-link { color: var(--brand-600); cursor: pointer; text-decoration: none; }
.bp-detail-row .bp-label-sub.bp-link:hover { text-decoration: underline; }
.bp-detail-row .bp-amount-sub { text-align: right; font-weight: 600; color: var(--gray-700); font-size: 12px; padding-left: 6px; }

/* Clickable account / detail rows that open the mini-statement movement modal */
.bp-row.bp-mov-row, .bp-detail-row.bp-mov-row { cursor: pointer; }
.bp-row.bp-mov-row:hover, .bp-detail-row.bp-mov-row:hover { background: var(--gray-50); }
.bp-row .bp-label .bp-mov-ic { margin-left: auto; color: var(--gray-400); font-size: 11px; flex-shrink: 0; }
.bp-row.bp-mov-row:hover .bp-label .bp-mov-ic { color: var(--brand-600); }

/* Movement modal: rows whose account number has no chart account get a stale-account highlight */
.bp-mov-star td { background: #fef2f2; }
.bp-mov-star td.bp-num { color: var(--danger-600); }

.bp-bank-card-footer { margin-top: auto; padding: 10px 14px; border-top: 1px solid var(--border); }
.bp-notes-sticky {
  background: #fffbe8; border: 1px solid #f5e6a8; border-radius: 8px; padding: 8px 10px;
  font-size: 11.5px; color: #6b5b1a; margin-bottom: 8px; position: relative; white-space: pre-wrap;
}
.bp-notes-sticky .bi { color: #caa316; margin-right: 4px; }
.bp-btn-notes {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 10px; border: 1px dashed var(--border-strong); border-radius: 8px;
  background: transparent; color: var(--gray-500); font-size: 11.5px; font-weight: 600;
  cursor: pointer; transition: all 0.15s ease;
}
.bp-btn-notes:hover { border-color: var(--primary); color: var(--primary); background: var(--brand-50); }

/* Analytics panel — ONE card in the right sidebar (not three separate
   cards) holding all three charts as internally-divided sections. Reads as
   a single cohesive "Analytics" panel rather than a repetitive stack of
   bordered cards, while each chart still gets a fixed, sane height
   (maintainAspectRatio:false in JS) so it can't balloon with the sidebar's
   width the way the single full-width sidebar chart used to. */
.bp-analytics-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); overflow: hidden; display: flex; flex-direction: column;
}
.bp-charts-card-header {
  display: flex; align-items: center; gap: 8px; padding: 14px 16px;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.bp-charts-card-header .bi { color: var(--brand-600); font-size: 15px; }
.bp-charts-card-header span { font-size: 12.5px; font-weight: 700; color: var(--text); }
.bp-charts-card-body { padding: 16px; }
.bp-chart-section + .bp-chart-section { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 16px; }
.bp-mini-chart-title {
  display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  color: var(--text); margin-bottom: 10px;
}
.bp-mini-chart-title .bi { color: var(--brand-600); font-size: 12.5px; }
.bp-mini-chart-box { position: relative; height: 180px; }
.bp-mini-chart-empty { text-align: center; color: var(--text-muted); font-size: 12px; padding-top: 70px; }

/* Notes editing form (rendered inside the shared .drawer) */
.bp-notes-form textarea { width: 100%; min-height: 160px; font-family: inherit; }

/* PDC modal (rendered inside the shared .modal-box) */
.bp-pdc-modal { display: flex; flex-direction: column; height: 100%; max-height: none; }

/* Account movement / mini-statement modal — same flex shell and header as
   the PDC modal, so it fills the enlarged (80vh) modal box. */
.bp-mov-modal { display: flex; flex-direction: column; height: 100%; max-height: none; }
.bp-mov-modal .bp-pdc-body { flex: 1; overflow: auto; }

/* Mini-statement table: give the Date column a bit more room than the
   compact PDC defaults. */
.bp-mov-modal .bp-pdc-table td:nth-child(2),
.bp-mov-modal .bp-pdc-table th:nth-child(2) { min-width: 110px; white-space: nowrap; }
.bp-mov-modal .bp-pdc-table td:nth-child(4) { min-width: 180px; }
.bp-pdc-header {
  background: linear-gradient(135deg, var(--grad-deep-a) 0%, var(--grad-deep-b) 100%); color: #fff;
  padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.bp-pdc-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; }
.bp-pdc-count { background: rgba(255,255,255,0.18); border-radius: 999px; padding: 2px 10px; font-size: 11.5px; font-weight: 600; }
.bp-pdc-header-actions { display: flex; align-items: center; gap: 8px; }
.bp-pdc-search { position: relative; }
.bp-pdc-search input {
  width: 210px; padding: 6px 10px 6px 30px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.12); color: #fff; font-size: 12.5px;
}
.bp-pdc-search input::placeholder { color: rgba(255,255,255,0.7); }
.bp-pdc-search i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: rgba(255,255,255,0.7); font-size: 12px; }
.bp-pdc-icon-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;
}
.bp-pdc-icon-btn:hover { background: rgba(255,255,255,0.15); }
.bp-pdc-close { width: 30px; height: 30px; border-radius: 8px; border: none; background: transparent; color: #fff; cursor: pointer; font-size: 16px; }

.bp-pdc-subheader {
  background: var(--surface-2); border-bottom: 1px solid var(--border); padding: 8px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.bp-pdc-tabs { display: flex; gap: 4px; }
.bp-pdc-tab {
  border: none; background: transparent; padding: 6px 14px; border-radius: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--gray-600); cursor: pointer;
}
.bp-pdc-tab.active { background: var(--grad-deep-b); color: #fff; }
.bp-pdc-filter-label { font-size: 12px; color: var(--text-muted); }

.bp-pdc-body { flex: 1; overflow: auto; }
.bp-pdc-table-wrap { max-height: none; overflow: visible; }
.bp-pdc-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.bp-pdc-table thead th {
  position: sticky; top: 0; background: var(--surface-2); text-align: left; padding: 8px 10px;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gray-600);
  border-bottom: 2px solid var(--border); white-space: nowrap; z-index: 1;
}
.bp-pdc-table th.bp-num, .bp-pdc-table td.bp-num { text-align: right; }
.bp-pdc-table th.bp-center, .bp-pdc-table td.bp-center { text-align: center; }
.bp-pdc-table tbody td { padding: 7px 10px; border-bottom: 1px solid var(--gray-100); }
.bp-pdc-table tbody tr:hover { background: var(--gray-50); }
.bp-pdc-table tfoot td {
  position: sticky; bottom: 0; background: var(--gray-900); color: #fff; font-weight: 700;
  padding: 8px 10px;
}
.bp-due-overdue { color: var(--danger-600); font-weight: 650; }
.bp-due-soon { color: var(--warning-600); font-weight: 650; }
.bp-pdc-empty { text-align: center; padding: 40px 0; color: var(--text-muted); }
.bp-pdc-empty .bi { font-size: 30px; color: var(--gray-300); display: block; margin-bottom: 8px; }

.bp-pdc-footer {
  padding: 10px 18px; border-top: 1px solid var(--border); background: var(--surface-2);
  display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-muted);
}

@media print {
  body * { visibility: hidden; }
  .bp-pdc-modal, .bp-pdc-modal *,
  .bp-mov-modal, .bp-mov-modal * { visibility: visible; }
  .bp-pdc-modal, .bp-mov-modal { position: fixed; inset: 0; max-height: none; overflow: auto; }
  .bp-pdc-header, .bp-pdc-subheader .bp-pdc-tabs, .bp-pdc-footer { display: none !important; }
  .bp-pdc-table-wrap { max-height: none !important; overflow: visible !important; }
}
