:root {
    /* --- Global Colors --- */
    --bs-primary: #3699FF;
    --bs-success: #1BC5BD;
    --bs-danger: #F64E60;
    --bs-warning: #FFA800;
    --bs-body-bg: #F3F6F9;
    --bs-body-color: #212529;

    /* --- Sidebar Variables --- */
    --sidebar-width: 260px;
    --sidebar-bg: #1e1e2d;
    --sidebar-text: #a2a3b7;
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: #1b1b29;
    --sidebar-accent: #3699FF;
}

/* --- Dark Mode Overrides --- */
[data-bs-theme="dark"] {
    --bs-body-bg: #151521;
    --bs-body-color: #e1e1e1;
    --bs-card-bg: #1e1e2d;
    --bs-border-color: #2b2b40;
}

/* --- Global Resets --- */
body {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    overflow-x: hidden;
}

/* =========================================
   SIDEBAR STYLES (Fixed)
   ========================================= */

#wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
    height: 100vh;
    overflow: hidden;
}

#sidebar-wrapper {
    height: 100%;
    width: var(--sidebar-width);
    margin-left: -var(--sidebar-width);
    background-color: var(--sidebar-bg);
    transition: margin 0.25s ease-out;
    z-index: 1000;
    flex-shrink: 0;
    overflow-y: auto;
}

/* --- NUCLEAR RESET: KILL ALL UNDERLINES --- */
/* This targets every link inside the sidebar ID, no matter what */
#sidebar-wrapper a,
#sidebar-wrapper a:hover,
#sidebar-wrapper a:focus,
#sidebar-wrapper a:active,
#sidebar-wrapper a:visited,
#sidebar-wrapper .sidebar-link,
#sidebar-wrapper .sidebar-link:hover {
    text-decoration: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
}

/* --- BULLET KILLER --- */
#sidebar-wrapper ul,
#sidebar-wrapper li {
    list-style: none !important;
    padding-left: 0 !important;
    margin: 0 !important;
}

/* Desktop: Show sidebar by default */
@media (min-width: 768px) {
    #sidebar-wrapper {
        margin-left: 0;
    }

    body.sb-sidenav-toggled #sidebar-wrapper {
        margin-left: -var(--sidebar-width);
    }
}

/* Mobile: Toggled state shows it */
@media (max-width: 767.98px) {
    body.sb-sidenav-toggled #sidebar-wrapper {
        margin-left: 0;
    }
}

/* Sidebar Heading */
.sidebar-heading {
    padding: 1.5rem 1.25rem;
    font-size: 1.25rem;
    color: var(--sidebar-text-hover);
    background-color: rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Link Styling --- */
.sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0.85rem 1.5rem;
    color: var(--sidebar-text);
    transition: color 0.3s ease, background-color 0.3s ease;
    font-size: 0.95rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    outline: none;
    width: 100%;
}

/* Hover & Focus State */
.sidebar-link:hover,
.sidebar-link:focus {
    color: var(--sidebar-text-hover);
    background-color: rgba(255, 255, 255, 0.03);
    border-left-color: rgba(255, 255, 255, 0.2);
}

/* Active State */
.sidebar-link.active {
    color: var(--sidebar-text-hover);
    background-color: var(--sidebar-active-bg);
    border-left-color: var(--sidebar-accent);
}

/* Icon Spacing */
.sidebar-link i {
    font-size: 1.1rem;
    width: 1.5rem;
    text-align: center;
    margin-right: 0.75rem;
    color: #5E6278;
    transition: color 0.3s;
}

.sidebar-link:hover i,
.sidebar-link.active i {
    color: var(--sidebar-accent);
}

/* --- Submenu Styling --- */
.submenu {
    background-color: rgba(0, 0, 0, 0.15);
}

.submenu .sidebar-link {
    padding-left: 3.5rem;
    font-size: 0.9rem;
    border-left: none;
}

/* Chevron Rotation */
.chevron-icon {
    margin-left: auto;
    font-size: 0.8rem !important;
    width: auto !important;
    transition: transform 0.3s ease;
}

[aria-expanded="true"] .chevron-icon {
    transform: rotate(180deg);
}

/* =========================================
   OTHER GLOBAL STYLES
   ========================================= */

#page-content-wrapper {
    width: 100%;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#main-content {
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Navbar */
.navbar-light {
    background-color: #ffffff !important;
    border-bottom: 1px solid #e4e6ef;
}

[data-bs-theme="dark"] .navbar-light {
    background-color: #1e1e2d !important;
    border-bottom-color: #2b2b40 !important;
}

/* Cards & Tables */
[data-bs-theme="dark"] .card {
    background-color: var(--bs-card-bg);
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .table {
    --bs-table-color: #e1e1e1;
    --bs-table-bg: transparent;
    --bs-table-border-color: #2b2b40;
}

[data-bs-theme="dark"] .table-light {
    --bs-table-bg: #2b2b40;
    --bs-table-color: #fff;
}

/* Login Card */
.login-card {
    background-color: #ffffff;
    border-radius: 16px;
}

[data-bs-theme="dark"] .login-card {
    background-color: var(--bs-card-bg);
}

/* --- Login Page Specifics --- */
.login-logo {
    width: 80px;
    height: auto;
}

/* --- Terminal Card Styles --- */
.terminal-card {
    transition: all 0.2s ease-in-out;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.terminal-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.08) !important;
    border-color: var(--bs-primary);
}

.terminal-card .card-actions {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 2;
}

/* =========================================
   SELECT2 DARK MODE SUPPORT
   ========================================= */

/* Select2 container - full width */
.select2-container {
    width: 100% !important;
}

/* Dark mode for Select2 dropdown */
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown {
    background-color: #1e1e2d;
    border-color: #2b2b40;
    color: #e1e1e1;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-search__field {
    background-color: #151521;
    border-color: #2b2b40;
    color: #e1e1e1;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-results__option {
    color: #e1e1e1;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-results__option--highlighted {
    background-color: #3699FF;
    color: #ffffff;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection {
    background-color: #1e1e2d;
    border-color: #2b2b40;
    color: #e1e1e1;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5.select2-container--focus .select2-selection {
    border-color: #3699FF;
    box-shadow: 0 0 0 0.25rem rgba(54, 153, 255, 0.25);
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection__rendered {
    color: #e1e1e1;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection__placeholder {
    color: #a2a3b7;
}

/* Light mode adjustments */
.select2-container--bootstrap-5 .select2-selection {
    min-height: calc(1.5em + 0.75rem + 2px);
}