/**
 * Risk Intelligence — dark neon overrides (html[data-theme="dark"])
 */

/* Light defaults for new theme classes */
.ri-legend-high { background: #dcfce7; border-color: #bbf7d0; }
.ri-legend-med { background: #fef9c3; border-color: #fef08a; }
.ri-legend-low { background: #fee2e2; border-color: #fecaca; }
.ri-legend-label { color: #475569; }
.ri-group-meta { background: #f1f5f9; color: #475569; }
.ri-group-fatf { background: #e0f2fe; color: #0369a1; }
.ri-group-wgi { background: #dcfce7; color: #15803d; }
.ri-group-sanc { background: #fee2e2; color: #b91c1c; }
.ri-group-cpi { background: #fef3c7; color: #b45309; }
.ri-group-engine { background: #eef2ff; color: #4338ca; }
.ri-sticky-col,
.master-repo-country-cell {
    background: #f1f5f9;
    min-width: 140px;
    max-width: 150px;
    width: 140px;
}
.ri-counter {
    background: #f8fafc;
}

/* Confidence column — light defaults */
.ri-conf--high { background: #dcfce7 !important; color: #15803d !important; }
.ri-conf--med { background: #fef9c3 !important; color: #854d0e !important; }
.ri-conf--low { background: #fee2e2 !important; color: #b91c1c !important; }
.ri-conf--critical { background: #7f1d1d !important; color: #ffffff !important; }

/* Confidence column — dark neon */
html[data-theme="dark"] .ri-conf--high {
    background: rgba(45, 212, 122, 0.16) !important;
    color: #4ade80 !important;
}
html[data-theme="dark"] .ri-conf--med {
    background: rgba(255, 214, 10, 0.14) !important;
    color: #ffd60a !important;
}
html[data-theme="dark"] .ri-conf--low {
    background: rgba(255, 59, 92, 0.16) !important;
    color: #ff6b8a !important;
}
html[data-theme="dark"] .ri-conf--critical {
    background: rgba(127, 29, 29, 0.55) !important;
    color: #fecaca !important;
}

/* Page wrapper helpers */
html[data-theme="dark"] .ri-toolbar {
    background: rgba(6, 16, 30, 0.94) !important;
    border: 1px solid rgba(255, 255, 255, 0.108) !important;
    border-radius: 12px !important;
    box-shadow: 0 0 20px rgba(0, 140, 220, 0.08);
    height: auto !important;
    min-height: 48px;
    padding: 0.55rem 0.75rem !important;
}

html[data-theme="dark"] .ri-toolbar .input-group {
    background: rgba(4, 16, 28, 0.92) !important;
    border-color: rgba(255, 255, 255, 0.108) !important;
}

html[data-theme="dark"] .ri-toolbar .form-control,
html[data-theme="dark"] .ri-toolbar .form-select {
    background: rgba(4, 16, 28, 0.92) !important;
    border-color: rgba(255, 255, 255, 0.108) !important;
    color: #e8f4ff !important;
}

html[data-theme="dark"] .ri-toolbar .form-select option {
    background: #06101e;
    color: #e8f4ff;
}

html[data-theme="dark"] .ri-toolbar .text-muted,
html[data-theme="dark"] .ri-toolbar .text-dark {
    color: #8eb4d0 !important;
}

html[data-theme="dark"] .ri-toolbar .bg-light {
    background: rgba(0, 40, 70, 0.45) !important;
    border-color: rgba(255, 255, 255, 0.085) !important;
    color: #c5d8ea !important;
}

html[data-theme="dark"] .ri-legend-label {
    color: #8eb4d0 !important;
}

html[data-theme="dark"] .ri-legend-high {
    background: rgba(45, 212, 122, 0.2) !important;
    border-color: rgba(45, 212, 122, 0.22) !important;
}

html[data-theme="dark"] .ri-legend-med {
    background: rgba(255, 214, 10, 0.18) !important;
    border-color: rgba(255, 214, 10, 0.4) !important;
}

html[data-theme="dark"] .ri-legend-low {
    background: rgba(255, 59, 92, 0.2) !important;
    border-color: rgba(255, 59, 92, 0.4) !important;
}

/* Table card */
html[data-theme="dark"] .ri-repo-card {
    background: rgba(6, 16, 30, 0.94) !important;
    border: 1px solid rgba(255, 255, 255, 0.092) !important;
    box-shadow: 0 0 32px rgba(0, 140, 220, 0.1), 0 16px 40px rgba(0, 0, 0, 0.35) !important;
}

html[data-theme="dark"] .master-repo-wrap {
    background: #06101e;
}

html[data-theme="dark"] .master-repo-wrap::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.106);
}

html[data-theme="dark"] .master-repo-table {
    color: #c5d8ea;
}

html[data-theme="dark"] .master-repo-table thead.sticky-top,
html[data-theme="dark"] .master-repo-table thead.bg-white {
    background: #06101e !important;
}

html[data-theme="dark"] .master-repo-subhead th {
    background: #0a1a14 !important;
    color: #b8d4ef !important;
    border-color: rgba(255, 255, 255, 0.066) !important;
}

html[data-theme="dark"] .master-repo-table tbody td {
    background: #06101e;
    color: #c5d8ea !important;
    border-color: rgba(255, 255, 255, 0.055) !important;
}

html[data-theme="dark"] .master-repo-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.05) !important;
}

html[data-theme="dark"] .master-repo-table .country-name {
    color: #e8f4ff !important;
}

html[data-theme="dark"] .master-repo-table .country-code {
    color: #7ea3c4 !important;
}

html[data-theme="dark"] .master-repo-table .text-dark,
html[data-theme="dark"] .master-repo-table .fw-bold.text-dark {
    color: #e8f4ff !important;
}

html[data-theme="dark"] .master-repo-table .text-muted {
    color: #8eb4d0 !important;
}

html[data-theme="dark"] .master-repo-table .bg-light,
html[data-theme="dark"] .master-repo-table .bg-light.text-dark {
    background: rgba(0, 40, 70, 0.4) !important;
    color: #c5d8ea !important;
}

/* Sticky country stays opaque + above scrolled/hovered cells */
html[data-theme="dark"] .master-repo-country-cell,
html[data-theme="dark"] .master-repo-table th.sticky-left,
html[data-theme="dark"] .ri-sticky-col,
html[data-theme="dark"] .master-repo-table tbody td.ri-sticky-col,
html[data-theme="dark"] .master-repo-table tbody td.master-repo-country-cell {
    background: #0a1a14 !important;
    color: #e8f4ff !important;
    border-right: 2px solid rgba(255, 255, 255, 0.136) !important;
    box-shadow: 3px 0 10px rgba(0, 0, 0, 0.45);
    z-index: 10;
}

html[data-theme="dark"] .master-repo-table thead th.ri-sticky-col,
html[data-theme="dark"] .master-repo-table thead th.sticky-left {
    z-index: 22 !important;
    background: #0a1a14 !important;
}

html[data-theme="dark"] .master-repo-table tbody tr:hover td.ri-sticky-col,
html[data-theme="dark"] .master-repo-table tbody tr:hover td.master-repo-country-cell,
html[data-theme="dark"] .master-repo-table.table-hover > tbody > tr:hover > td.ri-sticky-col,
html[data-theme="dark"] .master-repo-table.table-hover > tbody > tr:hover > td.master-repo-country-cell {
    --bs-table-accent-bg: transparent;
    background: #0f2438 !important;
    background-color: #0f2438 !important;
    z-index: 12 !important;
}

html[data-theme="dark"] .ri-counter {
    background: rgba(0, 40, 70, 0.45) !important;
    border-color: rgba(255, 255, 255, 0.085) !important;
    color: #c5d8ea !important;
}

/* Group header bands */
html[data-theme="dark"] .ri-group-meta {
    background: rgba(8, 24, 42, 0.95) !important;
    color: #94a3b8 !important;
}

html[data-theme="dark"] .ri-group-fatf {
    background: rgba(0, 100, 180, 0.28) !important;
    color: #7dd3fc !important;
    border-left-color: #2a9b6c !important;
}

html[data-theme="dark"] .ri-group-wgi {
    background: rgba(16, 120, 80, 0.25) !important;
    color: #6ee7b7 !important;
    border-left-color: #3cb87a !important;
}

html[data-theme="dark"] .ri-group-sanc {
    background: rgba(180, 40, 60, 0.28) !important;
    color: #ff8aa0 !important;
    border-left-color: #ff3b5c !important;
}

html[data-theme="dark"] .ri-group-cpi {
    background: rgba(180, 120, 20, 0.28) !important;
    color: #ffd60a !important;
    border-left-color: #ff8a1f !important;
}

html[data-theme="dark"] .ri-group-engine {
    background: rgba(70, 40, 160, 0.3) !important;
    color: #c4b5fd !important;
    border-left-color: #8b5cf6 !important;
}

/* Badges */
html[data-theme="dark"] .bg-success-subtle {
    background-color: rgba(45, 212, 122, 0.16) !important;
    border-color: rgba(45, 212, 122, 0.193) !important;
    color: #4ade80 !important;
}

html[data-theme="dark"] .bg-warning-subtle {
    background-color: rgba(255, 214, 10, 0.14) !important;
    border-color: rgba(255, 214, 10, 0.35) !important;
    color: #ffd60a !important;
}

html[data-theme="dark"] .bg-danger-subtle {
    background-color: rgba(255, 59, 92, 0.16) !important;
    border-color: rgba(255, 59, 92, 0.35) !important;
    color: #ff6b8a !important;
}

html[data-theme="dark"] .master-repo-table .category-badge--high {
    background: rgba(255, 59, 92, 0.18) !important;
    color: #ff6b8a !important;
    border-color: rgba(255, 59, 92, 0.4) !important;
}

html[data-theme="dark"] .master-repo-table .category-badge--medium {
    background: rgba(255, 214, 10, 0.14) !important;
    color: #ffd60a !important;
    border-color: rgba(255, 214, 10, 0.4) !important;
}

html[data-theme="dark"] .master-repo-table .category-badge--low {
    background: rgba(45, 212, 122, 0.14) !important;
    color: #4ade80 !important;
    border-color: rgba(45, 212, 122, 0.22) !important;
}

html[data-theme="dark"] .master-repo-table .badge.bg-light {
    background: rgba(0, 40, 70, 0.5) !important;
    color: #8eb4d0 !important;
    border-color: rgba(255, 255, 255, 0.085) !important;
}

/* Toolbar action buttons — neon edge */
html[data-theme="dark"] .btn-toolbar-action {
    box-shadow: 0 0 14px rgba(255, 255, 255, 0.066);
}

html[data-theme="dark"] .btn-toolbar-action:hover {
    box-shadow: 0 0 22px rgba(255, 255, 255, 0.108);
}

/* ── Modals on Risk Intelligence page ───────────────────── */
html[data-theme="dark"] #sanctionsMatrixModal .modal-content,
html[data-theme="dark"] #afghanistanAuditModal .modal-content,
html[data-theme="dark"] #regionBenchmarkModal .modal-content,
html[data-theme="dark"] #regionalModal .modal-content {
    background: #06101e !important;
    border: 1px solid rgba(255, 255, 255, 0.123) !important;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55) !important;
    color: #c5d8ea !important;
}

html[data-theme="dark"] #sanctionsMatrixModal .modal-header {
    background: linear-gradient(115deg, rgba(180, 40, 60, 0.45), #06101e) !important;
    border-bottom: 1px solid rgba(255, 59, 92, 0.3) !important;
}

html[data-theme="dark"] #sanctionsMatrixModal .modal-header h6,
html[data-theme="dark"] #sanctionsMatrixModal .modal-header .text-danger {
    color: #ff8aa0 !important;
}

html[data-theme="dark"] #afghanistanAuditModal .modal-header,
html[data-theme="dark"] #regionBenchmarkModal .modal-header {
    background: linear-gradient(115deg, rgba(0, 100, 160, 0.4), #06101e) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.11) !important;
    color: #e8f4ff !important;
}

html[data-theme="dark"] #sanctionsMatrixModal .modal-body,
html[data-theme="dark"] #afghanistanAuditModal .modal-body,
html[data-theme="dark"] #regionBenchmarkModal .modal-body,
html[data-theme="dark"] #regionalModal .modal-body {
    background: #06101e !important;
    color: #c5d8ea !important;
}

html[data-theme="dark"] #sanctionsMatrixModal .modal-footer,
html[data-theme="dark"] #afghanistanAuditModal .modal-footer,
html[data-theme="dark"] #regionBenchmarkModal .modal-footer,
html[data-theme="dark"] #regionalModal .modal-footer {
    background: #06101e !important;
    border-top: 1px solid rgba(255, 255, 255, 0.088) !important;
}

html[data-theme="dark"] #sanctionsMatrixModal .bg-light,
html[data-theme="dark"] #sanctionsMatrixModal .bg-white,
html[data-theme="dark"] #afghanistanAuditModal .bg-light,
html[data-theme="dark"] #afghanistanAuditModal .bg-white,
html[data-theme="dark"] #regionBenchmarkModal .bg-white,
html[data-theme="dark"] #regionBenchmarkModal .bg-light,
html[data-theme="dark"] #regionalModal .bg-white,
html[data-theme="dark"] #regionalModal .bg-light,
html[data-theme="dark"] #sanctionsMatrixModal .card,
html[data-theme="dark"] #afghanistanAuditModal .card,
html[data-theme="dark"] #regionBenchmarkModal .card,
html[data-theme="dark"] #regionalModal .card,
html[data-theme="dark"] #regionalModal #calculationExample,
html[data-theme="dark"] #afghanistanAuditModal .p-4.bg-white,
html[data-theme="dark"] #regionalModal .table-responsive {
    background: rgba(8, 24, 42, 0.95) !important;
    border-color: rgba(255, 255, 255, 0.11) !important;
    color: #c5d8ea !important;
}

html[data-theme="dark"] #sanctionsMatrixModal .text-dark,
html[data-theme="dark"] #afghanistanAuditModal .text-dark,
html[data-theme="dark"] #regionBenchmarkModal .text-dark,
html[data-theme="dark"] #regionalModal .text-dark,
html[data-theme="dark"] #sanctionsMatrixModal h6,
html[data-theme="dark"] #afghanistanAuditModal h6,
html[data-theme="dark"] #regionBenchmarkModal h6,
html[data-theme="dark"] #regionalModal h6,
html[data-theme="dark"] #sanctionsMatrixModal .fw-bold,
html[data-theme="dark"] #afghanistanAuditModal .fw-bold,
html[data-theme="dark"] #regionBenchmarkModal .fw-bold {
    color: #e8f4ff !important;
}

html[data-theme="dark"] #sanctionsMatrixModal .text-muted,
html[data-theme="dark"] #afghanistanAuditModal .text-muted,
html[data-theme="dark"] #regionBenchmarkModal .text-muted,
html[data-theme="dark"] #regionalModal .text-muted {
    color: #8eb4d0 !important;
}

html[data-theme="dark"] #sanctionsMatrixModal .table,
html[data-theme="dark"] #afghanistanAuditModal .table,
html[data-theme="dark"] #regionBenchmarkModal .table,
html[data-theme="dark"] #regionalModal .table {
    color: #c5d8ea !important;
    --bs-table-bg: transparent;
    --bs-table-striped-bg: rgba(255, 255, 255, 0.05);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
    --bs-table-color: #c5d8ea;
}

html[data-theme="dark"] #sanctionsMatrixModal .table td,
html[data-theme="dark"] #sanctionsMatrixModal .table th,
html[data-theme="dark"] #afghanistanAuditModal .table td,
html[data-theme="dark"] #afghanistanAuditModal .table th,
html[data-theme="dark"] #regionBenchmarkModal .table td,
html[data-theme="dark"] #regionBenchmarkModal .table th,
html[data-theme="dark"] #regionalModal .table td,
html[data-theme="dark"] #regionalModal .table th {
    border-color: rgba(255, 255, 255, 0.066) !important;
    color: #c5d8ea !important;
    background-color: transparent !important;
}

html[data-theme="dark"] #regionBenchmarkModal thead,
html[data-theme="dark"] #regionBenchmarkModal thead th,
html[data-theme="dark"] #sanctionsMatrixModal thead.bg-dark,
html[data-theme="dark"] #regionalModal thead.bg-light,
html[data-theme="dark"] #afghanistanAuditModal thead {
    background: #0a1a14 !important;
    color: #e8f4ff !important;
}

html[data-theme="dark"] #sanctionsMatrixModal .btn-close,
html[data-theme="dark"] #afghanistanAuditModal .btn-close,
html[data-theme="dark"] #regionBenchmarkModal .btn-close,
html[data-theme="dark"] #regionalModal .btn-close {
    filter: invert(1) grayscale(1) brightness(1.5);
}

html[data-theme="dark"] #sanctionsMatrixModal .badge.bg-white,
html[data-theme="dark"] #afghanistanAuditModal .badge.bg-white {
    background: rgba(8, 24, 42, 0.9) !important;
}

html[data-theme="dark"] #regionalModal .modal-header.bg-dark {
    background: linear-gradient(115deg, rgba(0, 100, 160, 0.45), #06101e) !important;
}

html[data-theme="dark"] #sanctionsMatrixModal tr.bg-light,
html[data-theme="dark"] #afghanistanAuditModal tr.bg-light,
html[data-theme="dark"] #afghanistanAuditModal tr.bg-light td {
    background: rgba(0, 40, 70, 0.4) !important;
    color: #9eb8cc !important;
}
