/* ============================================
   Nexus Dark Theme
   Forces dark mode regardless of data-bs-theme
   ============================================ */

/* FORCE dark mode on :root (fallback if data-bs-theme not set) */
:root,
:root[data-bs-theme="light"],
:root[data-bs-theme="dark"],
[data-bs-theme="dark"],
[data-bs-theme="light"] {
    /* Core backgrounds - darker than Bootstrap default */
    --bs-body-bg: #0d1117 !important;
    --bs-body-bg-rgb: 13, 17, 23 !important;
    --bs-secondary-bg: #161b22 !important;
    --bs-tertiary-bg: #21262d !important;
    
    /* Text colors */
    --bs-body-color: #e6edf3 !important;
    --bs-body-color-rgb: 230, 237, 243 !important;
    --bs-secondary-color: #ccc !important;
    --bs-tertiary-color: #aaa !important;
    
    /* Border colors */
    --bs-border-color: #30363d !important;
    --bs-border-color-translucent: rgba(48, 54, 61, 0.75) !important;
    
    /* Links - muted, not blue */
    --bs-link-color: #8b949e !important;
    --bs-link-hover-color: #e6edf3 !important;
    
    /* Card/component backgrounds */
    --bs-card-bg: #161b22 !important;
    --bs-card-border-color: #30363d !important;
    
    /* Dark theme specific */
    --bs-dark: #0d1117 !important;
    --bs-light: #21262d !important;
    
    /* Form controls */
    --bs-form-control-bg: #0d1117 !important;
    
    /* Emphasis colors - all gray/muted */
    --bs-emphasis-color: #e6edf3 !important;
    --bs-emphasis-color-rgb: 230, 237, 243 !important;
    
    /* Primary color - muted blue-gray */
    --bs-primary: #30363d !important;
    --bs-primary-rgb: 48, 54, 61 !important;
}

/* Force body dark */
body {
    background-color: #0d1117 !important;
    color: #e6edf3 !important;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Links - no underline, gray */
a {
    color: #8b949e !important;
    text-decoration: none !important;
}
a:hover {
    color: #e6edf3 !important;
}

/* Headings */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    color: #e6edf3 !important;
}

/* Tables */
.table {
    --bs-table-bg: transparent !important;
    --bs-table-color: #e6edf3 !important;
    --bs-table-striped-bg: #161b22 !important;
    --bs-table-striped-color: #e6edf3 !important;
    --bs-table-hover-bg: #21262d !important;
    --bs-table-hover-color: #e6edf3 !important;
    --bs-table-border-color: #21262d !important;
    color: #e6edf3 !important;
}

.table > thead {
    background-color: #161b22 !important;
}

.table > thead th {
    color: #8b949e !important;
    border-color: #30363d !important;
}

.table > tbody > tr {
    border-color: #21262d !important;
}

.table > tbody > tr > td {
    color: #e6edf3 !important;
}

/* Cards */
.card {
    background-color: #161b22 !important;
    border-color: #30363d !important;
    color: #e6edf3 !important;
}

.card-header {
    background-color: #21262d !important;
    border-color: #30363d !important;
    color: #e6edf3 !important;
}

.card-body {
    background-color: #161b22 !important;
}

.card-footer {
    background-color: #161b22 !important;
    border-color: #30363d !important;
}

/* Buttons - all muted/gray */
.btn {
    border-color: #30363d !important;
}

.btn-primary {
    background-color: #21262d !important;
    border-color: #30363d !important;
    color: #e6edf3 !important;
}

.btn-primary:hover, .btn-primary:focus {
    background-color: #30363d !important;
    border-color: #484f58 !important;
    color: #e6edf3 !important;
}

.btn-secondary {
    background-color: #21262d !important;
    border-color: #30363d !important;
    color: #8b949e !important;
}

.btn-secondary:hover {
    background-color: #30363d !important;
    color: #e6edf3 !important;
}

.btn-outline-primary,
.btn-outline-secondary {
    color: #8b949e !important;
    border-color: #30363d !important;
    background-color: transparent !important;
}

.btn-outline-primary:hover,
.btn-outline-secondary:hover {
    background-color: #21262d !important;
    color: #e6edf3 !important;
}

.btn-success {
    background-color: #238636 !important;
    border-color: #238636 !important;
}

.btn-danger {
    background-color: #da3633 !important;
    border-color: #da3633 !important;
}

/* Forms */
.form-control,
.form-select,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
textarea,
select {
    background-color: #0d1117 !important;
    border-color: #30363d !important;
    color: #e6edf3 !important;
}

.form-control:focus,
.form-select:focus,
input:focus,
textarea:focus,
select:focus {
    background-color: #161b22 !important;
    border-color: #484f58 !important;
    box-shadow: 0 0 0 0.2rem rgba(48, 54, 61, 0.5) !important;
    color: #e6edf3 !important;
}

.form-control::placeholder,
input::placeholder {
    color: #6e7681 !important;
}

.form-label,
label {
    color: #ccc !important;
}

/* Alerts */
.alert {
    border-radius: 6px !important;
}

.alert-info {
    background-color: #161b22 !important;
    border-color: #30363d !important;
    color: #8b949e !important;
}

.alert-success {
    background-color: rgba(46, 160, 67, 0.15) !important;
    border-color: #238636 !important;
    color: #3fb950 !important;
}

.alert-danger {
    background-color: rgba(248, 81, 73, 0.15) !important;
    border-color: #da3633 !important;
    color: #f85149 !important;
}

.alert-warning {
    background-color: rgba(187, 128, 9, 0.15) !important;
    border-color: #9e6a03 !important;
    color: #d29922 !important;
}

/* Dropdowns */
.dropdown-menu {
    background-color: #161b22 !important;
    border-color: #30363d !important;
}

.dropdown-item {
    color: #e6edf3 !important;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: #21262d !important;
    color: #e6edf3 !important;
}

.dropdown-divider {
    border-color: #30363d !important;
}

/* Modals */
.modal-content {
    background-color: #161b22 !important;
    border-color: #30363d !important;
    color: #e6edf3 !important;
}

.modal-header {
    border-color: #30363d !important;
}

.modal-footer {
    border-color: #30363d !important;
}

.modal-backdrop {
    background-color: #000 !important;
}

/* Nav */
.nav-link {
    color: #fff !important;
}

/* Sidebar nav-link — tight spacing, no wrap */
.nav-scrollable .nav-link {
    display: flex !important;
    align-items: center !important;
    gap: 0.4rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    padding-top: 0.25rem !important;
    padding-bottom: 0.25rem !important;
    line-height: 1.3 !important;
}

.nav-scrollable .nav-link .bi {
    flex-shrink: 0 !important;
}

.nav-link:hover,
.nav-link.active {
    color: #e6edf3 !important;
}

.nav-tabs {
    border-color: #30363d !important;
}

.nav-tabs .nav-link {
    border-color: transparent !important;
}

.nav-tabs .nav-link.active {
    background-color: #161b22 !important;
    border-color: #30363d #30363d #161b22 !important;
}

.nav-pills .nav-link.active {
    background-color: #21262d !important;
}

/* Badges */
.badge {
    font-weight: 500 !important;
}

.badge.bg-primary,
.badge.bg-secondary {
    background-color: #21262d !important;
    color: #8b949e !important;
}

/* List groups */
.list-group-item {
    background-color: #161b22 !important;
    border-color: #30363d !important;
    color: #e6edf3 !important;
}

.list-group-item:hover {
    background-color: #21262d !important;
}

/* Pagination */
.page-link {
    background-color: #0d1117 !important;
    border-color: #30363d !important;
    color: #8b949e !important;
}

.page-link:hover {
    background-color: #21262d !important;
    color: #e6edf3 !important;
}

.page-item.active .page-link {
    background-color: #30363d !important;
    border-color: #484f58 !important;
}

.page-item.disabled .page-link {
    background-color: #161b22 !important;
    color: #6e7681 !important;
}

/* Progress */
.progress {
    background-color: #21262d !important;
}

/* Accordion */
.accordion-item {
    background-color: #161b22 !important;
    border-color: #30363d !important;
}

.accordion-button {
    background-color: #161b22 !important;
    color: #e6edf3 !important;
}

.accordion-button:not(.collapsed) {
    background-color: #21262d !important;
    color: #e6edf3 !important;
}

.accordion-button::after {
    filter: invert(1) !important;
}

/* Breadcrumb */
.breadcrumb {
    background-color: transparent !important;
}

.breadcrumb-item a {
    color: #8b949e !important;
}

.breadcrumb-item.active {
    color: #e6edf3 !important;
}

/* Code blocks */
code {
    color: #f0883e !important;
    background-color: #161b22 !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
}

pre {
    background-color: #161b22 !important;
    border: 1px solid #30363d !important;
    border-radius: 6px !important;
    padding: 1rem !important;
    color: #e6edf3 !important;
}

/* Scrollbar (Webkit) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #0d1117;
}

::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}

/* Checkboxes & Radio */
.form-check-input {
    background-color: #0d1117 !important;
    border-color: #30363d !important;
}

.form-check-input:checked {
    background-color: #30363d !important;
    border-color: #484f58 !important;
}

.form-check-label {
    color: #e6edf3 !important;
}

/* Spinners */
.spinner-border,
.spinner-grow {
    color: #8b949e !important;
}

/* Tooltips */
.tooltip-inner {
    background-color: #21262d !important;
    color: #e6edf3 !important;
}

/* Popovers */
.popover {
    background-color: #161b22 !important;
    border-color: #30363d !important;
}

.popover-body {
    color: #e6edf3 !important;
}

/* ============================================
   Blazor-specific & Layout
   ============================================ */

/* Content area padding */
.content {
    padding-top: 1rem;
}

/* Focus states */
.btn:focus,
.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 0.2rem rgba(48, 54, 61, 0.5) !important;
}

/* Validation */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid #238636 !important;
}

.invalid {
    outline: 1px solid #da3633 !important;
}

.validation-message {
    color: #f85149 !important;
}

/* Blazor error boundary */
.blazor-error-boundary {
    background: #da3633 !important;
    padding: 1rem !important;
    color: white !important;
    border-radius: 6px !important;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* ============================================
   Custom Components
   ============================================ */

/* Stat cards (dashboard) */
.stat-card {
    background-color: #161b22 !important;
    border: 1px solid #30363d !important;
    border-radius: 8px !important;
    padding: 1.5rem !important;
    text-align: center !important;
}

.stat-card .stat-value {
    font-size: 2rem !important;
    font-weight: 600 !important;
    color: #e6edf3 !important;
}

.stat-card .stat-label {
    font-size: 0.85rem !important;
    color: #8b949e !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    margin-top: 0.25rem !important;
}

/* Monochrome badge */
.badge-mono {
    background-color: #21262d !important;
    color: #8b949e !important;
    border: 1px solid #30363d !important;
}

/* Separator */
.separator {
    border-top: 1px solid #21262d !important;
    margin: 1rem 0 !important;
}

/* Text helpers */
.text-muted,
.text-muted-custom {
    color: #aaa !important;
}

/* Close button */
.btn-close {
    filter: invert(1) grayscale(100%) brightness(200%) !important;
}


/* ========================================
   KNOWLEDGE BASE - Dark Theme
   ======================================== */

/* Cards - dark background */
.knowledge-section .card {
    background-color: #161b22 !important;
    border-color: #30363d !important;
}

.knowledge-section .card-header {
    background-color: #21262d !important;
    border-color: #30363d !important;
}

/* Tables - dark */
.knowledge-section .table {
    color: #c9d1d9 !important;
    --bs-table-bg: transparent;
}

.knowledge-section .table th,
.knowledge-section .table td {
    border-color: #30363d !important;
}

.knowledge-section .table-light,
.knowledge-section .thead-light {
    background-color: #21262d !important;
    color: #c9d1d9 !important;
}

.knowledge-section .table-light th,
.knowledge-section .table-light td {
    background-color: #21262d !important;
    color: #c9d1d9 !important;
}

/* Alerts - dark variants */
.knowledge-section .alert-light {
    background-color: #21262d !important;
    border-color: #30363d !important;
    color: #c9d1d9 !important;
}

.knowledge-section .alert-warning {
    background-color: #3d2e00 !important;
    border-color: #5c4400 !important;
    color: #f0c674 !important;
}

/* Boxes with borders */
.knowledge-section .border {
    border-color: #30363d !important;
}

.knowledge-section .border.rounded {
    background-color: #161b22 !important;
}

/* Icon circles */
.knowledge-section .icon-circle {
    background-color: #21262d !important;
    border-color: #30363d !important;
}

/* Hover cards on index */
.knowledge-card:hover {
    border-color: #58a6ff !important;
}

/* Primary accents */
.knowledge-section .text-primary {
    color: #58a6ff !important;
}

.knowledge-section .border-primary {
    border-color: #58a6ff !important;
}

.knowledge-section .bg-primary {
    background-color: #1f6feb !important;
}

/* Badge adjustments */
.knowledge-section .badge.bg-secondary {
    background-color: #30363d !important;
}

.knowledge-section .badge.bg-dark {
    background-color: #0d1117 !important;
}

.knowledge-section .badge.bg-light {
    background-color: #c9d1d9 !important;
    color: #0d1117 !important;
}

.knowledge-section .badge.bg-primary {
    background-color: #1f6feb !important;
}


/* Table row highlights - dark theme */
.knowledge-section .table-primary,
.knowledge-section .table-primary > td,
.knowledge-section .table-primary > th {
    background-color: #1f3a5f !important;
    color: #c9d1d9 !important;
    --bs-table-bg: #1f3a5f !important;
}

.knowledge-section .table-active,
.knowledge-section .table-active > td,
.knowledge-section .table-active > th {
    background-color: #21262d !important;
    color: #c9d1d9 !important;
    --bs-table-bg: #21262d !important;
}

.knowledge-section .table > tbody > tr {
    background-color: transparent;
}

.knowledge-section .table-hover > tbody > tr:hover {
    background-color: #21262d !important;
    --bs-table-hover-bg: #21262d !important;
}


/* Alert light in knowledge section - dark theme */
.knowledge-section .alert-light {
    background-color: #21262d !important;
    border-color: #30363d !important;
    color: #c9d1d9 !important;
}

.knowledge-section .alert-light .alert-link {
    color: #58a6ff !important;
}


/* Alert secondary in knowledge section - dark theme */
.knowledge-section .alert-secondary {
    background-color: #21262d !important;
    border-color: #30363d !important;
    color: #c9d1d9 !important;
}

/* Form controls in knowledge section - dark theme */
.knowledge-section .form-control,
.knowledge-section .form-select {
    background-color: #161b22;
    border-color: #30363d;
    color: #c9d1d9;
}

.knowledge-section .form-control:focus,
.knowledge-section .form-select:focus {
    background-color: #1c2128;
    border-color: #58a6ff;
    color: #c9d1d9;
    box-shadow: 0 0 0 0.2rem rgba(88, 166, 255, 0.25);
}

.knowledge-section .form-control::placeholder {
    color: #6e7681;
}

/* Activity Feed detail rows — global styles needed because RenderTreeBuilder
   bypasses Blazor scoped CSS attribute injection */
.af-detail-row {
    display: flex;
    align-items: baseline;
    font-size: 0.85rem;
    min-height: 1.4em;
}
.af-detail-label {
    color: #555;
    font-size: 0.82rem;
    flex: 0 0 230px;
    min-width: 230px;
    padding-right: 1rem;
    line-height: 1.4;
}
.af-detail-value {
    color: #ccc;
    font-size: 0.85rem;
    flex: 1;
    line-height: 1.4;
}
@media (max-width: 800px) {
    .af-detail-label { flex: 0 0 140px; min-width: 140px; }
}

/* ===== Bonus Impact Map ===== */
.bonus-impact-map { font-family: var(--font-sans, sans-serif); }
.bim-tree-container { position: relative; overflow-x: auto; overflow-y: visible; margin-bottom: 16px; width: 100%; display: block; -webkit-overflow-scrolling: touch; }
.bim-tree-container::-webkit-scrollbar { height: 4px; }
.bim-tree-container::-webkit-scrollbar-track { background: #1a1a1a; }
.bim-tree-container::-webkit-scrollbar-thumb { background: #444; border-radius: 2px; }
.bonus-impact-map .card-body { overflow: visible; }
.bim-node { cursor: pointer; transition: opacity 0.15s; }
.bim-node:hover { opacity: 0.85; }
.bim-node.active circle:first-child { stroke-width: 2.5 !important; }
.bim-breakaway-ring { fill: none; stroke: #E24B4A; stroke-width: 1.8; stroke-dasharray: 4 2; }
.bim-breakaway-badge { font-size: 10px; fill: #A32D2D; font-weight: 500; }
.bim-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.bim-legend-item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: #888; }
.bim-legend-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.wf-container { margin-top: 8px; }
.wf-section-label { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: #888; margin-bottom: 8px; }
.wf-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; min-height: 28px; }
.wf-label { width: 160px; font-size: 12px; color: #888; text-align: right; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-bar-wrap { flex: 1; display: flex; align-items: center; justify-content: flex-start; }
.wf-bar { height: 22px; border-radius: 4px; display: flex; align-items: center; min-width: 64px; }
.wf-bar-val { font-size: 11px; font-weight: 500; padding: 0 6px; white-space: nowrap; }
.wf-total { background: #3D5A2A; color: #A8CFA0; }
.wf-deduct { background: #5A2828; color: #D09090; }
.wf-qualify { background: #2A4060; color: #90B8D8; }
.wf-result { background: #1E5040; color: #80C8A8; }
.wf-contract { background: #5A2020; color: #D09090; }
.wf-underpay { background: #5A3A10; color: #D0A868; }
.wf-level { background: #3A3660; color: #B0A8D8; }
.wf-fullwidth { width: 100%; min-width: 100%; box-sizing: border-box; }
.wf-label-contract { color: #888; }
.wf-label-underpay { color: #888; }
.wf-rate-text { font-size: 12px; color: #888; padding-left: 4px; }
.wf-divider { border: none; border-top: 0.5px solid #333; margin: 6px 0 6px 168px; }
.wf-total-row { display: flex; align-items: center; gap: 8px; }
.wf-total-label { width: 160px; font-size: 13px; font-weight: 500; text-align: right; flex-shrink: 0; }
.wf-total-value { font-size: 18px; font-weight: 500; color: #80C8A8; padding-left: 4px; }

/* Waterfall responsive — mobile */
@media (max-width: 576px) {
    .wf-label { width: 100px; font-size: 11px; }
    .wf-total-label { width: 100px; font-size: 12px; }
    .wf-total-value { font-size: 15px; }
    .wf-divider { margin-left: 108px; }
    .wf-total-row { flex-wrap: wrap; }
}

/* Break-away detail table */
.ba-detail-section { margin-top: 14px; }
.ba-detail-title { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: #888; margin-bottom: 6px; }
.ba-detail-table { width: 100%; font-size: 12px; border-collapse: collapse; }
.ba-detail-table th { color: #666; font-weight: 500; padding: 4px 8px; border-bottom: 1px solid #333; }
.ba-detail-table td { color: #ccc; padding: 4px 8px; border-bottom: 1px solid #222; }
.ba-detail-table tfoot td { border-top: 1px solid #333; border-bottom: none; font-weight: 500; padding-top: 6px; }
.ba-level-dot { display: inline-block; width: 20px; height: 20px; border-radius: 50%; text-align: center; line-height: 20px; font-size: 10px; font-weight: 600; border: 1px solid; color: #111; }
.ba-none-msg { margin-top: 12px; padding: 8px 12px; background: #1a1a1a; border: 1px solid #333; border-radius: 4px; font-size: 12px; color: #888; }

/* Level protection badge */
.calc-lp-badge { display: inline-block; font-size: 10px; font-weight: 500; padding: 1px 6px; border-radius: 3px; margin-left: 6px; vertical-align: middle; }
.calc-lp-gray { background: #333; color: #888; }
.calc-lp-yellow { background: #BA7517; color: #fff; }
.calc-lp-red { background: #E24B4A; color: #fff; }
.calc-lp-dropped { background: #222; color: #555; }
