/* ===== DARK MODE TOGGLE BUTTON ===== */
.dark-mode-toggle {
    background: none;
    border: 1px solid #dee2e6;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0;
    color: #212529;
    transition: background-color 0.2s, border-color 0.2s;
}

.dark-mode-toggle:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

[data-bs-theme="dark"] .dark-mode-toggle {
    border-color: #495057;
    color: #ffc107;
}

[data-bs-theme="dark"] .dark-mode-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* ===== GLOBAL bg-white / bg-light OVERRIDES ===== */
[data-bs-theme="dark"] .bg-white {
    background-color: var(--bs-body-bg) !important;
}

[data-bs-theme="dark"] .bg-light {
    background-color: var(--bs-tertiary-bg) !important;
}

/* ===== NAVBAR ===== */
[data-bs-theme="dark"] .nav-link.text-dark,
[data-bs-theme="dark"] .btn.text-dark,
[data-bs-theme="dark"] .navbar-brand {
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .navbar-toggler-icon {
    filter: invert(1);
}

/* ===== MAP SIDEBAR ===== */
[data-bs-theme="dark"] .map-sidebar-header {
    background-color: #2b3035;
}

[data-bs-theme="dark"] .map-sidebar-toggle {
    background: #2b3035;
    color: #dee2e6;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
}

/* ===== WIDGETS ===== */
[data-bs-theme="dark"] .widget-card {
    background: rgba(33, 37, 41, 0.96);
}

[data-bs-theme="dark"] .widget-card .card-header.bg-white {
    background-color: #2b3035 !important;
}

[data-bs-theme="dark"] .widget-card table td:first-child {
    color: #9ea7b0;
}

/* ===== ADMIN SIDEBAR (_AdminNav) ===== */
[data-bs-theme="dark"] .admin-sidebar {
    background-color: var(--bs-body-bg) !important;
}

[data-bs-theme="dark"] .admin-sidebar .list-group-item {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .admin-sidebar .list-group-item.active {
    background-color: #212529;
    color: #6ea8fe;
    border-left-color: #6ea8fe;
}

[data-bs-theme="dark"] .admin-sidebar .list-group-item:hover:not(.active) {
    background-color: #212529;
    border-left-color: #495057;
}

/* ===== ADMIN HEADER (_AdminHeader) ===== */
[data-bs-theme="dark"] .admin-sidebar h6 {
    color: var(--bs-secondary-color) !important;
}

/* ===== ADMIN TABS (inactive nav-tabs links) ===== */
[data-bs-theme="dark"] .nav-tabs .nav-link:not(.active) {
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .nav-tabs .nav-link:not(.active):hover {
    color: #6ea8fe;
    border-color: transparent transparent var(--bs-border-color);
}

/* ===== INSTALLER SIDE PANELS (Devices + Alarms left list) ===== */
[data-bs-theme="dark"] .list-group-item.list-group-item-action {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .list-group-item.list-group-item-action:hover:not(.active) {
    background-color: var(--bs-tertiary-bg);
}

[data-bs-theme="dark"] .list-group-item.list-group-item-action.active {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}

/* ===== INSTALLER DATA SYNC STATUS CARDS ===== */
[data-bs-theme="dark"] .card.border-0.bg-light {
    background-color: var(--bs-tertiary-bg) !important;
}

/* ===== USERS / DEPARTMENTS: dept/project access panels ===== */
[data-bs-theme="dark"] .card-body .rounded.border.bg-light,
[data-bs-theme="dark"] .modal-body .rounded.border.bg-light {
    background-color: var(--bs-tertiary-bg) !important;
    border-color: var(--bs-border-color) !important;
}

/* ===== ADMIN GEOFENCE MAP ===== */
[data-bs-theme="dark"] #geofenceMap {
    border-color: var(--bs-border-color);
}

/* ===== LEAFLET MAP – DARK TILE FILTER ===== */
/* Invert + hue-rotate the tile pane so every base layer gets a dark look.
   Satellite / hybrid imagery is excluded because inversion ruins photos. */
[data-bs-theme="dark"] .leaflet-container {
    background: #000;
}

[data-bs-theme="dark"] .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(0.95) contrast(1.1);
}

/* Undo the filter for satellite / hybrid imagery tiles so photos stay natural */
[data-bs-theme="dark"] .leaflet-tile-pane .leaflet-tile[src*="lyrs=s"],
[data-bs-theme="dark"] .leaflet-tile-pane .leaflet-tile[src*="World_Imagery"] {
    filter: invert(1) hue-rotate(180deg);  /* double-invert = back to normal */
}

/* ===== LEAFLET MAP POPUPS / CONTROLS ===== */
[data-bs-theme="dark"] .leaflet-popup-content-wrapper,
[data-bs-theme="dark"] .leaflet-popup-tip {
    background: #2b3035;
    color: #dee2e6;
}

[data-bs-theme="dark"] .leaflet-control-zoom a {
    background-color: #2b3035;
    color: #dee2e6;
    border-color: #495057;
}

[data-bs-theme="dark"] .leaflet-control-zoom a:hover {
    background-color: #343a40;
}

[data-bs-theme="dark"] .leaflet-control-attribution {
    background: rgba(43, 48, 53, 0.85) !important;
    color: #9ea7b0;
}

[data-bs-theme="dark"] .leaflet-control-attribution a {
    color: #6ea8fe;
}

/* Keep markers / vectors / interactive overlays looking normal */
[data-bs-theme="dark"] .leaflet-marker-pane,
[data-bs-theme="dark"] .leaflet-shadow-pane,
[data-bs-theme="dark"] .leaflet-overlay-pane svg,
[data-bs-theme="dark"] .leaflet-overlay-pane canvas {
    filter: invert(1) hue-rotate(180deg);  /* counter the parent invert */
}

/* ===== FOOTER ===== */
[data-bs-theme="dark"] .footer.text-muted {
    border-color: var(--bs-border-color) !important;
}

/* ===== DATALOG ===== */
[data-bs-theme="dark"] .datalog-table tr.active-row {
    background-color: rgba(110, 168, 254, 0.15);
}
