/**
 * Arise Suite - Dark Theme Tokens & Overrides
 * Corporate Brand Colors Adapted for Dark Mode:
 * - Primary Navy: #0b1629 / #111e33
 * - Accent Orange: #e8622c
 * - Slate/Pure White: #f1f5f9 / #ffffff
 */

[data-bs-theme="dark"] {
    --arise-sidebar-bg: #0b1426;
    --arise-sidebar-hover: rgba(232, 98, 44, 0.15);
    --arise-sidebar-active: #e8622c;
    --arise-sidebar-text: #94a3b8;

    --arise-header-bg: #152238;
    --arise-body-bg: #0c1322;
    --arise-card-bg: #152238;
    --arise-border-color: #21324e;
    --arise-text-main: #f1f5f9;
    --arise-text-muted: #94a3b8;
    --arise-title-color: #ffffff;

    --arise-navy-subtle: rgba(255, 255, 255, 0.08);
    --arise-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
    --arise-shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
    --arise-shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.55);
}

/* Dark Mode Universal Legibility & Contrast Overrides */
[data-bs-theme="dark"] .card {
    background-color: var(--arise-card-bg) !important;
    border: 1px solid var(--arise-border-color) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25) !important;
}

[data-bs-theme="dark"] .bg-body-tertiary {
    background-color: #0f192b !important;
    border-color: #223450 !important;
}

[data-bs-theme="dark"] .card-footer {
    border-top-color: var(--arise-border-color) !important;
}

/* User Avatar in Dark Mode */
[data-bs-theme="dark"] .avatar-circle {
    background: linear-gradient(135deg, rgba(232, 98, 44, 0.28) 0%, rgba(232, 98, 44, 0.18) 100%) !important;
    color: #ff9b6a !important;
    border: 1px solid rgba(232, 98, 44, 0.45) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4) !important;
}

/* High contrast badges in dark mode */
[data-bs-theme="dark"] .badge.bg-success,
[data-bs-theme="dark"] .badge.bg-success-subtle {
    background-color: #10b981 !important;
    color: #ffffff !important;
    font-weight: 600 !important;
}

[data-bs-theme="dark"] .badge.bg-warning,
[data-bs-theme="dark"] .badge.bg-warning-subtle {
    background-color: #f59e0b !important;
    color: #000000 !important;
    font-weight: 600 !important;
}

[data-bs-theme="dark"] .badge.bg-danger,
[data-bs-theme="dark"] .badge.bg-danger-subtle {
    background-color: #ef4444 !important;
    color: #ffffff !important;
    font-weight: 600 !important;
}

[data-bs-theme="dark"] .badge.bg-secondary-subtle {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #cbd5e1 !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
}

[data-bs-theme="dark"] .badge.bg-info-subtle {
    background-color: rgba(14, 165, 233, 0.15) !important;
    color: #38bdf8 !important;
    border-color: rgba(14, 165, 233, 0.3) !important;
}

[data-bs-theme="dark"] .badge.bg-primary-subtle {
    background-color: rgba(59, 130, 246, 0.15) !important;
    color: #60a5fa !important;
    border-color: rgba(59, 130, 246, 0.3) !important;
}

[data-bs-theme="dark"] .badge-pulse-passive,
[data-bs-theme="dark"] .badge-status-passive {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #f8fafc !important;
    border: 1px solid rgba(255, 255, 255, 0.22) !important;
    font-weight: 600 !important;
}

/* Table styling in dark mode */
[data-bs-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: #e2e8f0;
    --bs-table-hover-bg: rgba(255, 255, 255, 0.03);
    border-color: var(--arise-border-color);
}

[data-bs-theme="dark"] .table thead th {
    background-color: #0b1629 !important;
    color: #94a3b8 !important;
    border-bottom: 2px solid var(--arise-border-color) !important;
}

[data-bs-theme="dark"] .table tbody td {
    border-bottom: 1px solid var(--arise-border-color) !important;
    color: #cbd5e1;
}

/* Key names and links in dark mode */
[data-bs-theme="dark"] .font-monospace.text-primary {
    color: #60a5fa !important;
}

/* Buttons in dark mode */
[data-bs-theme="dark"] .btn-outline-secondary {
    color: #94a3b8 !important;
    border-color: #2a3c5a !important;
    background-color: rgba(255, 255, 255, 0.02);
}

[data-bs-theme="dark"] .btn-outline-secondary:hover {
    color: #ffffff !important;
    background-color: var(--arise-orange) !important;
    border-color: var(--arise-orange) !important;
}

[data-bs-theme="dark"] .btn-outline-primary {
    color: #60a5fa !important;
    border-color: #3b82f6 !important;
}

[data-bs-theme="dark"] .btn-outline-primary:hover {
    color: #ffffff !important;
    background-color: #2563eb !important;
    border-color: #2563eb !important;
}

/* Pagination in dark mode */
[data-bs-theme="dark"] .pagination .page-link {
    background-color: #0b1629 !important;
    border-color: var(--arise-border-color) !important;
    color: #94a3b8 !important;
}

[data-bs-theme="dark"] .pagination .page-item.active .page-link {
    background-color: var(--arise-orange) !important;
    border-color: var(--arise-orange) !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .pagination .page-item:not(.active) .page-link:hover {
    background-color: #1e2d45 !important;
    color: #ffffff !important;
}

/* Watermark icons visibility in dark mode */
[data-bs-theme="dark"] .card .position-absolute[style*="opacity: 0.08"] {
    opacity: 0.16 !important;
}

[data-bs-theme="dark"] [style*="color: var(--arise-navy)"],
[data-bs-theme="dark"] [style*="color:var(--arise-navy)"],
[data-bs-theme="dark"] [style*="color: #152a4e"],
[data-bs-theme="dark"] [style*="color:#152a4e"],
[data-bs-theme="dark"] .text-arise-navy,
[data-bs-theme="dark"] h1,
[data-bs-theme="dark"] h2,
[data-bs-theme="dark"] h3,
[data-bs-theme="dark"] h4,
[data-bs-theme="dark"] h5,
[data-bs-theme="dark"] h6 {
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .text-muted,
[data-bs-theme="dark"] .small.text-muted,
[data-bs-theme="dark"] p.text-muted,
[data-bs-theme="dark"] span.text-muted,
[data-bs-theme="dark"] div.text-muted {
    color: #94a3b8 !important;
}

[data-bs-theme="dark"] .text-secondary {
    color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .btn-arise-outline-navy {
    color: #f1f5f9 !important;
    border-color: #334155 !important;
    background-color: rgba(255, 255, 255, 0.06) !important;
}

[data-bs-theme="dark"] .btn-arise-outline-navy:hover {
    color: #ffffff !important;
    background-color: var(--arise-orange) !important;
    border-color: var(--arise-orange) !important;
}

[data-bs-theme="dark"] .card-custom,
[data-bs-theme="dark"] .demo-card,
[data-bs-theme="dark"] .profile-card,
[data-bs-theme="dark"] .modal-content {
    background-color: #111e33;
    border-color: #1e2d45;
}

[data-bs-theme="dark"] .demo-card-title,
[data-bs-theme="dark"] .form-section-title,
[data-bs-theme="dark"] .section-header {
    color: #f1f5f9 !important;
    border-bottom-color: #1e2d45 !important;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #0b1526;
    border-color: #1e2d45;
    color: #f1f5f9;
}

[data-bs-theme="dark"] .form-floating>label {
    color: #94a3b8 !important;
}

[data-bs-theme="dark"] .form-floating>.form-control:focus~label,
[data-bs-theme="dark"] .form-floating>.form-control:not(:placeholder-shown)~label,
[data-bs-theme="dark"] .form-floating>.form-select~label {
    color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .form-floating>.form-control:focus~label {
    color: var(--arise-orange) !important;
}

[data-bs-theme="dark"] .form-floating>label::after {
    background-color: transparent !important;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: #0b1526;
    border-color: var(--arise-orange);
    color: #ffffff;
}

[data-bs-theme="dark"] .table {
    color: #f1f5f9;
    --bs-table-color: #f1f5f9;
    --bs-table-bg: transparent;
    --bs-table-border-color: #1e2d45;
    --bs-table-hover-bg: rgba(255, 255, 255, 0.03);
    --bs-table-hover-color: #ffffff;
}

[data-bs-theme="dark"] .table th {
    background-color: rgba(255, 255, 255, 0.03);
    color: #cbd5e1;
}

[data-bs-theme="dark"] .list-group-item {
    background-color: transparent !important;
    border-color: #1e2d45 !important;
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .list-group-item:hover {
    background-color: rgba(255, 255, 255, 0.025) !important;
}

/* Dark Mode Dropdown Menus */
[data-bs-theme="dark"] .dropdown-menu {
    background-color: #111e33 !important;
    border-color: #1e2d45 !important;
    color: #f1f5f9 !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
}

[data-bs-theme="dark"] .dropdown-menu .border-bottom {
    border-bottom-color: #1e2d45 !important;
}

[data-bs-theme="dark"] .dropdown-divider {
    border-top-color: #1e2d45 !important;
    opacity: 1;
}

[data-bs-theme="dark"] .dropdown-item {
    color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
    background-color: rgba(232, 98, 44, 0.15) !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .dropdown-item:hover i {
    color: var(--arise-orange) !important;
}

[data-bs-theme="dark"] .dropdown-item.text-danger {
    color: #f87171 !important;
}

[data-bs-theme="dark"] .dropdown-item.text-danger:hover {
    background-color: rgba(239, 68, 68, 0.15) !important;
    color: #fca5a5 !important;
}


/* Subtle Badges in Brand Harmony */
[data-bs-theme="dark"] .bg-primary-subtle {
    background-color: rgba(21, 42, 78, 0.7) !important;
    color: #cbd5e1 !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .bg-warning-subtle,
[data-bs-theme="dark"] .bg-accent-subtle {
    background-color: rgba(232, 98, 44, 0.18) !important;
    color: #ffaa80 !important;
    border: 1px solid rgba(232, 98, 44, 0.3);
}

[data-bs-theme="dark"] .bg-success-subtle,
[data-bs-theme="dark"] .bg-info-subtle,
[data-bs-theme="dark"] .bg-secondary-subtle {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: #94a3b8 !important;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Dark Mode Stat Card Icons & Accents */
[data-bs-theme="dark"] .stat-icon.navy {
    background-color: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .stat-icon.navy i {
    color: #ffffff !important;
}

[data-bs-theme="dark"] .stat-icon.navy-light {
    background-color: rgba(232, 98, 44, 0.15) !important;
    border: 1px solid rgba(232, 98, 44, 0.25) !important;
    color: #ffaa80 !important;
}

[data-bs-theme="dark"] .stat-icon.navy-light i {
    color: #ffaa80 !important;
}

[data-bs-theme="dark"] .stat-icon.navy-outline {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .stat-icon.orange {
    background-color: rgba(232, 98, 44, 0.18) !important;
    border: 1px solid rgba(232, 98, 44, 0.3) !important;
    color: #ff9b6a !important;
}

[data-bs-theme="dark"] .stat-icon.orange i {
    color: #ff9b6a !important;
}


/* Dynamic Tabs */
[data-bs-theme="dark"] .nav-tabs-dynamic .nav-link {
    color: #94a3b8;
}

[data-bs-theme="dark"] .nav-tabs-dynamic .nav-link:hover {
    color: var(--arise-orange) !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
}

[data-bs-theme="dark"] .nav-tabs-dynamic .nav-link:hover i {
    color: var(--arise-orange) !important;
}

[data-bs-theme="dark"] .nav-tabs-dynamic .nav-link.active {
    color: #ffffff !important;
    background-color: var(--arise-body-bg) !important;
    border-color: #1e2d45 #1e2d45 transparent !important;
    border-top: 3px solid var(--arise-orange) !important;
}

[data-bs-theme="dark"] .nav-tabs-dynamic .nav-link.active i {
    color: var(--arise-orange) !important;
}

[data-bs-theme="dark"] .tab-close-btn {
    color: #94a3b8;
}

[data-bs-theme="dark"] .tab-close-btn:hover {
    background-color: rgba(239, 68, 68, 0.25) !important;
    color: #fca5a5 !important;
}

/* Pagination */
[data-bs-theme="dark"] .page-item .page-link {
    background-color: #0b1526;
    border-color: #1e2d45;
    color: #cbd5e1;
}

[data-bs-theme="dark"] .page-item:hover:not(.disabled):not(.active) .page-link {
    color: #ffffff;
    background-color: rgba(232, 98, 44, 0.2);
    border-color: var(--arise-orange);
}

[data-bs-theme="dark"] .page-item.active .page-link {
    background-color: var(--arise-orange) !important;
    border-color: var(--arise-orange) !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .page-item.disabled .page-link {
    background-color: #0b1526 !important;
    border-color: #1e2d45 !important;
    color: #64748b !important;
}

/* Scrollbar */
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}

/* Select2 Dark Mode Full Integration */
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection,
[data-bs-theme="dark"] .select2-container--default .select2-selection--single,
[data-bs-theme="dark"] .select2-container--default .select2-selection--multiple {
    background-color: #0b1526 !important;
    border-color: #1e2d45 !important;
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered,
[data-bs-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--single .select2-selection__placeholder,
[data-bs-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #94a3b8 !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5.select2-container--focus .select2-selection,
[data-bs-theme="dark"] .select2-container--bootstrap-5.select2-container--open .select2-selection,
[data-bs-theme="dark"] .select2-container--default.select2-container--focus .select2-selection--multiple,
[data-bs-theme="dark"] .select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--arise-orange) !important;
    box-shadow: 0 0 0 0.25rem rgba(232, 98, 44, 0.25) !important;
}

[data-bs-theme="dark"] .select2-dropdown {
    background-color: #111e33 !important;
    border-color: #1e2d45 !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown .select2-search .select2-search__field,
[data-bs-theme="dark"] .select2-container--default .select2-search--dropdown .select2-search__field {
    background-color: #0b1526 !important;
    border-color: #1e2d45 !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-results__option,
[data-bs-theme="dark"] .select2-container--default .select2-results__option {
    color: #cbd5e1 !important;
    background-color: transparent !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-results__option--highlighted,
[data-bs-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected],
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-results__option:hover {
    background-color: rgba(232, 98, 44, 0.2) !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-results__option[aria-selected="true"],
[data-bs-theme="dark"] .select2-container--default .select2-results__option[aria-selected="true"] {
    background-color: var(--arise-orange) !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice {
    background-color: #152a4e !important;
    border-color: #1e3a6a !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice__remove {
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: var(--arise-orange) !important;
}

/* Dark Mode Settings & Profile Vertical Nav Pills */
[data-bs-theme="dark"] .settings-nav .nav-link,
[data-bs-theme="dark"] .profile-nav .nav-link {
    color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .settings-nav .nav-link .leading-tight,
[data-bs-theme="dark"] .profile-nav .nav-link span {
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .settings-nav .nav-link:hover,
[data-bs-theme="dark"] .profile-nav .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.06) !important;
    color: #ffffff !important;
    border-color: rgba(232, 98, 44, 0.3) !important;
}

[data-bs-theme="dark"] .settings-nav .nav-link:hover .leading-tight,
[data-bs-theme="dark"] .profile-nav .nav-link:hover span {
    color: var(--arise-orange) !important;
}

[data-bs-theme="dark"] .settings-nav .nav-link:hover i,
[data-bs-theme="dark"] .profile-nav .nav-link:hover i {
    color: var(--arise-orange) !important;
}

[data-bs-theme="dark"] .settings-nav .nav-link.active,
[data-bs-theme="dark"] .profile-nav .nav-link.active {
    background: linear-gradient(135deg, var(--arise-navy) 0%, #1e3a6a 100%) !important;
    border-color: var(--arise-orange) !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .settings-nav .nav-link.active .leading-tight,
[data-bs-theme="dark"] .profile-nav .nav-link.active span {
    color: #ffffff !important;
}

[data-bs-theme="dark"] .settings-nav .nav-link.active .text-muted,
[data-bs-theme="dark"] .profile-nav .nav-link.active .text-muted {
    color: #94a3b8 !important;
}

/* Dark Mode Form Input Groups & Switch Containers */
[data-bs-theme="dark"] .input-group-text {
    background-color: #0b1629 !important;
    border-color: #1e2d45 !important;
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .form-switch-container {
    background-color: rgba(255, 255, 255, 0.03) !important;
    border-color: #1e2d45 !important;
}

[data-bs-theme="dark"] .delete-confirm-info-box {
    background-color: rgba(255, 255, 255, 0.04) !important;
    border-color: #1e2d45 !important;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    border-color: var(--arise-orange) !important;
    box-shadow: 0 0 0 0.25rem rgba(232, 98, 44, 0.2) !important;
}