/* ============================================================
   NEXORA — shared BI report widgets.
   NEXORA.UI/Components/Reports/* is consumed by pages in other
   assemblies, where Blazor CSS isolation cannot reach it; these
   rules live here and are scoped under .bi-report-page so they
   never leak into unrelated pages.
   ============================================================ */

.bi-report-page { direction: inherit; }

/* ---------- Icons ---------- */
.bi-report-page svg.i {
    width: 15px; height: 15px; flex: none;
    fill: none; stroke: currentColor; stroke-width: 1.8;
    stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Badges / live pulse ---------- */
.bi-report-page .badge {
    display: inline-flex; align-items: center; gap: 5px;
    height: 22px; padding: 0 9px; border-radius: 6px;
    font-size: 10.5px; font-weight: 700; white-space: nowrap;
}
.bi-report-page .badge svg.i { width: 12px; height: 12px; }
.bi-report-page .badge-live { background: var(--green-soft); color: var(--green); border: 1px solid #bbf7d0; }
.bi-report-page .badge-soft { background: var(--accent-soft); color: var(--accent-d); border: 1px solid #e0e7ff; }
.bi-report-page .badge-ghost { background: #f8fafc; color: var(--muted); border: 1px solid var(--line); }
.bi-report-page .pulse {
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; box-shadow: 0 0 0 3px rgba(5, 150, 105, .13);
}

/* ---------- Widget grid ---------- */
.bi-report-page .bi-grid-row {
    display: flex; flex-wrap: wrap; gap: 16px;
    margin-bottom: 16px; align-items: stretch;
}
.bi-report-page .bi-widget {
    min-width: 0; flex: 1 1 0;
    display: flex; flex-direction: column;
}
.bi-report-page .bi-widget > * { flex: 1; min-width: 0; }

.bi-report-page .bi-widget-card {
    background: #fff; border: 1px solid var(--card-line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 14px 16px 8px; display: flex; flex-direction: column;
}
.bi-report-page .bi-widget-head {
    font-size: 13.5px; font-weight: 700; color: var(--ink-2);
    margin-bottom: 8px;
}
.bi-report-page .widget-drill {
    display: flex; justify-content: flex-end; margin-bottom: 4px;
}
.bi-report-page .widget-drill a { font-size: 11.5px; font-weight: 600; color: var(--accent-d); }

/* ---------- Loading / error / empty ---------- */
.bi-report-page .widget-state {
    display: flex; align-items: center; gap: 8px;
    padding: 18px 20px; border: 1px solid var(--card-line);
    border-radius: var(--radius); background: #fff;
    box-shadow: var(--shadow); color: var(--muted);
    font-size: 12.5px; font-weight: 500;
}
.bi-report-page .widget-state .pulse { color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, .13); }
.bi-report-page .widget-state.widget-error {
    border-color: #fecdd3; background: #fff1f2; color: #9f1239;
}

/* ---------- Filter bar ---------- */
.bi-report-page .filter-card {
    background: #fff; border: 1px solid var(--card-line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    margin-bottom: 16px; overflow: visible;
}
.bi-report-page .filter-head {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 18px; border-bottom: 1px solid #f1f5f9;
}
.bi-report-page .filter-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; font-weight: 700; color: var(--ink-2);
}
.bi-report-page .f-icon {
    width: 28px; height: 28px; border-radius: 8px;
    display: grid; place-items: center;
    background: var(--accent-soft); color: var(--accent);
}
.bi-report-page .count-pill {
    display: inline-grid; place-items: center; min-width: 20px; height: 20px;
    border-radius: 6px; background: #f1f5f9; color: var(--muted);
    font-size: 10.5px; font-weight: 800; padding: 0 5px;
}
.bi-report-page .filter-body { padding: 16px 18px 14px; }
.bi-report-page .filters-grid {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px 16px;
}
.bi-report-page .field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.bi-report-page .field > label { font-size: 11.5px; font-weight: 600; color: #475569; }
.bi-report-page .field input {
    border: 1px solid var(--line); border-radius: 9px; background: #fff;
    min-height: 38px; padding: 0 10px; font-size: 12.5px; font-family: inherit;
    outline: 0; color: var(--ink-2);
}
.bi-report-page .field input:focus { border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(99, 102, 241, .1); }
.bi-report-page .filter-foot {
    display: flex; align-items: center; justify-content: flex-end; gap: 14px;
    flex-wrap: wrap; padding-top: 14px; margin-top: 14px;
    border-top: 1px solid #f1f5f9;
}
.bi-report-page .filter-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- KPI cards ---------- */
.bi-report-page .kpi {
    background: #fff; border: 1px solid var(--card-line); border-radius: 14px;
    padding: 14px 16px 13px; box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
    display: flex; flex-direction: column; min-width: 0;
}
.bi-report-page .kpi-label {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
    font-size: 11.5px; color: var(--muted); font-weight: 600;
}
.bi-report-page .kpi-value {
    font-size: 23px; font-weight: 800; letter-spacing: -.025em; margin-top: 7px;
    line-height: 1.2; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.bi-report-page .kpi-foot {
    display: flex; align-items: center; gap: 5px; margin-top: auto;
    padding-top: 7px; font-size: 10.5px; color: var(--muted-2); flex-wrap: wrap;
}
.bi-report-page .delta-up,
.bi-report-page .delta-down {
    display: inline-flex; align-items: center; gap: 2px;
    font-weight: 700; font-size: 10.5px; padding: 1px 5px; border-radius: 5px;
}
.bi-report-page .delta-up { color: var(--green); background: var(--green-soft); }
.bi-report-page .delta-down { color: var(--rose); background: var(--rose-soft); }
.bi-report-page .kpi-warn { border-color: #fde68a; }
.bi-report-page .kpi-warn .kpi-value { color: var(--amber); }
.bi-report-page .kpi-danger { border-color: #fecdd3; }
.bi-report-page .kpi-danger .kpi-value { color: var(--rose); }
.bi-report-page .kpi-spark { width: 100%; height: 24px; margin-top: 6px; color: var(--accent); opacity: .75; }

/* ---------- Cards ---------- */
.bi-report-page .card {
    background: #fff; border: 1px solid var(--card-line);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.bi-report-page .card-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; padding: 18px 20px 14px;
}
.bi-report-page .card-head h3 {
    font-size: 14.5px; font-weight: 700; color: var(--ink-2);
    display: flex; align-items: center; gap: 7px;
}
.bi-report-page .card-head p { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.bi-report-page .table-card { margin-bottom: 16px; }
.bi-report-page .chart-wrap { padding: 0 12px 12px; }
.bi-report-page .chart-wrap svg { width: 100%; height: auto; display: block; direction: ltr; }
.bi-report-page .bi-chart { display: block; width: 100%; height: auto; direction: ltr; }
.bi-report-page .chart-bar { cursor: default; }
.bi-report-page .chart-bar:hover rect { opacity: 1; }

/* ---------- Table ---------- */
.bi-report-page .table-head { align-items: center; padding-bottom: 12px; }
.bi-report-page .table-head p { display: flex; align-items: center; gap: 3px; }
.bi-report-page .table-tools {
    display: flex; align-items: center; gap: 7px;
    flex-wrap: wrap; justify-content: flex-end;
}
.bi-report-page .mini-search {
    display: flex; align-items: center; gap: 6px;
    border: 1px solid var(--line); border-radius: 8px; height: 34px;
    padding: 0 9px; background: #fff; width: 190px;
}
.bi-report-page .mini-search svg.i { width: 14px; height: 14px; color: var(--muted-2); }
.bi-report-page .mini-search input {
    border: 0; outline: 0; min-width: 0; width: 100%;
    font-size: 11.5px; background: transparent; font-family: inherit;
}
.bi-report-page .mini-search:focus-within { border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(99, 102, 241, .1); }
.bi-report-page .menu-wrap { position: relative; }
.bi-report-page .icon-btn {
    border: 0; background: transparent; color: var(--muted-2);
    width: 34px; height: 34px; border-radius: 8px;
    display: inline-grid; place-items: center;
}
.bi-report-page .icon-btn.bordered { border: 1px solid var(--line); background: #fff; }
.bi-report-page .icon-btn:hover { background: #f1f5f9; color: var(--ink-2); }
.bi-report-page .pop-menu {
    position: absolute; top: calc(100% + 6px); inset-inline-end: 0; z-index: 45;
    min-width: 205px; background: #fff; border: 1px solid var(--line);
    border-radius: 11px; box-shadow: 0 14px 40px rgba(15, 23, 42, .14);
    padding: 8px;
}
.bi-report-page .pop-menu .pop-title {
    font-size: 10px; font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: var(--muted-2); padding: 2px 4px 6px;
}
.bi-report-page .pop-menu label {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 4px; font-size: 12px; color: var(--ink-2); cursor: pointer;
}
.bi-report-page .pop-menu input { accent-color: var(--accent); }
.bi-report-page .density {
    display: flex; border: 1px solid var(--line); border-radius: 8px;
    overflow: hidden; height: 34px;
}
.bi-report-page .density button {
    border: 0; background: #fff; width: 32px;
    display: grid; place-items: center; color: var(--muted-2);
}
.bi-report-page .density button + button { border-inline-start: 1px solid var(--line); }
.bi-report-page .density button.active { background: #f1f5f9; color: var(--ink-2); }
.bi-report-page .dense-ico {
    display: block; width: 13px; height: 9px;
    border-top: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
    position: relative;
}
.bi-report-page .dense-ico::after {
    content: ""; position: absolute; inset-inline: 0; top: 3px;
    border-top: 1.5px solid currentColor;
}
.bi-report-page .table-scroll { overflow: auto; border-top: 1px solid #f1f5f9; }
.bi-report-page .data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 720px; }
.bi-report-page .data-table th {
    position: sticky; top: 0; z-index: 2; background: #f8fafc; text-align: start;
    font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
    color: var(--muted); padding: 9px 12px;
    border-bottom: 1px solid var(--line); white-space: nowrap;
}
html[lang="ar"] .bi-report-page .data-table th { letter-spacing: 0; text-transform: none; font-size: 11px; }
.bi-report-page .data-table th.num-col { width: 36px; text-align: center; }
.bi-report-page .data-table th.money,
.bi-report-page .data-table td.money { text-align: end; font-variant-numeric: tabular-nums; }
.bi-report-page .data-table td {
    padding: 10px 12px; border-bottom: 1px solid #f1f5f9;
    vertical-align: middle; white-space: nowrap;
}
.bi-report-page .data-table tbody tr { transition: background .12s; }
.bi-report-page .data-table tbody tr:hover { background: #f8faff; }
.bi-report-page .data-table .num-col {
    color: var(--muted-2); text-align: center;
    font-variant-numeric: tabular-nums; width: 36px;
}
.bi-report-page .data-table .money { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.bi-report-page .data-table thead .sortable { cursor: pointer; user-select: none; }
.bi-report-page .data-table thead .sortable:hover { color: var(--ink-2); }
.bi-report-page .sort-ico {
    width: 11px !important; height: 11px !important;
    opacity: .35; margin-inline-start: 3px; vertical-align: -1px;
}
.bi-report-page th.sorted .sort-ico { opacity: 1; color: var(--accent); }
.bi-report-page .data-table tfoot td {
    background: #fbfcfe; border-top: 1px solid var(--line); border-bottom: 0;
    padding: 11px 12px; font-size: 11.5px;
}
.bi-report-page .density-compact .data-table td { padding-block: 6px; }
.bi-report-page .density-compact .data-table th { padding-block: 7px; }

/* ---------- Empty note ---------- */
.bi-report-page .empty-note {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; padding: 42px 20px; color: var(--muted);
}
.bi-report-page .empty-note svg.i { width: 24px; height: 24px; color: #cbd5e1; margin-bottom: 4px; }
.bi-report-page .empty-note strong { font-size: 13px; color: var(--ink-2); }

/* ---------- Pager + footer ---------- */
.bi-report-page .table-foot {
    padding: 10px 16px; border-top: 1px solid #f1f5f9;
    background: #fcfdff; border-radius: 0 0 var(--radius) var(--radius);
}
.bi-report-page .tbl-footer {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap;
}
.bi-report-page .tbl-foot-side { display: flex; align-items: center; gap: 8px; }
.bi-report-page .tbl-muted { color: var(--muted); font-size: 12.5px; }
.bi-report-page .tbl-range { color: var(--muted-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.bi-report-page .tbl-page {
    color: var(--ink); font-size: 12.5px; font-weight: 600;
    white-space: nowrap; font-variant-numeric: tabular-nums;
}
.bi-report-page .tbl-size {
    border: 1px solid var(--line); border-radius: 6px; background: #fff;
    font-size: 12.5px; color: var(--ink-2); padding: 4px 6px; font-family: inherit;
}
.bi-report-page .btn-xs { min-height: 0; height: 28px; padding: 0 10px; font-size: 11px; }
.bi-report-page .btn-xs svg.i { width: 13px; height: 13px; }
.bi-report-page .run-foot {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    padding: 12px 4px 0; font-size: 10.5px; color: var(--muted-2);
    border-top: 1px solid var(--line); margin-top: 4px;
}
.bi-report-page .run-foot span { display: inline-flex; align-items: center; gap: 5px; }

/* ---------- Chart legend + custom-report bits ---------- */
.bi-report-page .chart-card { margin-bottom: 16px; }
.bi-report-page .chart-legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-top: 2px; }
.bi-report-page .lg { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); font-weight: 500; }
.bi-report-page .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.bi-report-page .swatch.booked { background: linear-gradient(180deg, #60a5fa, #6366f1); }
.bi-report-page .swatch.target { background: repeating-linear-gradient(90deg, #f59e0b 0 3px, transparent 3px 6px); height: 2px; width: 14px; }

.bi-report-page .filter-applied { font-size: 11.5px; color: var(--muted-2); font-weight: 500; }
.bi-report-page .filter-head .icon-btn { margin-inline-start: auto; transition: transform .2s; }
.bi-report-page .filter-card.collapsed .filter-head .icon-btn { transform: rotate(180deg); }
.bi-report-page .filter-card.collapsed .filter-body { display: none; }
.bi-report-page .filter-card.collapsed .filter-head { border-bottom: 0; }

.bi-report-page .chips-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 240px; }
.bi-report-page .chips-label {
    font-size: 10px; font-weight: 700; letter-spacing: .1em;
    text-transform: uppercase; color: var(--muted-2); margin-inline-end: 2px;
}
.bi-report-page .chip {
    display: inline-flex; align-items: center; gap: 2px; height: 26px; padding: 0 3px 0 9px;
    border-radius: 7px; border: 1px solid #dbe3ef; background: #f8fafc;
    color: #334155; font-size: 11px; font-weight: 500;
}
.bi-report-page .chip-x {
    border: 0; background: transparent; color: var(--muted-2); font-size: 14px;
    padding: 0 4px; line-height: 1; border-radius: 4px;
}
.bi-report-page .chip-x:hover { background: #e2e8f0; color: var(--ink-2); }
.bi-report-page .chips-empty { font-size: 11.5px; color: var(--muted-2); }

.bi-report-page .kpi-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px; margin-bottom: 16px;
}
.bi-report-page .run-foot .live { margin-inline-start: auto; color: var(--green); font-weight: 600; }
.bi-report-page .run-foot svg.i { width: 12px; height: 12px; }

/* Toasts sit outside the report body but inside a .bi-report-page wrapper,
   so they stay styled without leaking the global names. */
.bi-report-page .toast-stack {
    position: fixed; inset-block-end: 22px; inset-inline-end: 22px; z-index: 90;
    display: flex; flex-direction: column; gap: 8px; max-width: 360px;
}
.bi-report-page .toast {
    display: flex; align-items: flex-start; gap: 9px; background: #111827; color: #e5e7eb;
    padding: 10px 12px; border-radius: 10px; box-shadow: 0 12px 30px rgba(15, 23, 42, .25);
    font-size: 11.5px; line-height: 1.4;
}
.bi-report-page .toast .t-ico {
    width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
    background: rgba(56, 189, 248, .16); color: #7dd3fc; flex: none;
}
.bi-report-page .toast .t-ico.ok { background: rgba(16, 185, 129, .16); color: #6ee7b7; }
.bi-report-page .toast .t-ico.warn { background: rgba(244, 63, 94, .16); color: #fda4af; }
.bi-report-page .toast svg.i { width: 12px; height: 12px; stroke-width: 2.2; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
    .bi-report-page .filters-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .bi-report-page .filters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .bi-report-page .table-head { align-items: flex-start; flex-direction: column; }
    .bi-report-page .table-tools { width: 100%; justify-content: flex-start; }
    .bi-report-page .mini-search { flex: 1; width: auto; }
    .bi-report-page .bi-grid-row { gap: 12px; }
    .bi-report-page .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .bi-report-page .run-foot .live { margin-inline-start: 0; }
    .bi-report-page .toast-stack { inset-inline: 16px; max-width: none; }
}
@media (max-width: 640px) {
    .bi-report-page .filters-grid { grid-template-columns: 1fr; }
    .bi-report-page .filter-applied { display: none; }
    .bi-report-page .filter-foot { align-items: stretch; flex-direction: column; }
    .bi-report-page .kpi-grid { grid-template-columns: 1fr; }
    .bi-report-page .card-head { flex-direction: column; gap: 8px; padding: 14px 14px 10px; }
    .bi-report-page .table-tools .mini-search { display: none; }
    .bi-report-page .bi-widget { flex: 1 1 100%; }
}
