:root {
    /* Wraith-inspired Solid Palette */
    --brand-color: #3b82f6;     /* Blue */
    --brand-secondary: #10b981; /* Emerald Green */
    --brand-hover: #2563eb;     /* Darker Blue */

    --bg-body: #f1f5f9;         /* Light slate */
    --bg-sidebar: rgba(10, 10, 10, 0.95); /* Black / Very Dark */
    --text-primary: #0f172a;    /* Dark Slate */
    --text-secondary: #64748b;
    --text-light: #3b82f6;      /* Blue for sidebar labels */
    
    --border-color: rgba(15, 23, 42, 0.1);
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 24px;
    --btn-radius: 12px;
    
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    --card-shadow-hover: 0 10px 30px rgba(0, 0, 0, 0.1);
    --glass-blur: blur(12px);
}

body.premium-layout {
    font-family: 'Outfit', system-ui, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(60, 64, 68, 0.2);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(60, 64, 68, 0.4);
}

#wrapper {
    display: flex;
    width: 100%;
    height: 100%; /* Full height */
    overflow: hidden;
    padding: 1rem; /* Space for the floating layout */
    gap: 1.5rem;
}

/* Floating Sidebar Styling */
.premium-sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    color: #fff;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 2rem); /* Full height minus padding */
    border-radius: var(--border-radius-lg);
    box-shadow: 0 8px 32px rgba(60, 64, 68, 0.2);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
    overflow: hidden;
}

body.sb-sidenav-toggled .premium-sidebar {
    margin-left: -320px; /* Hide outside */
}

/* Page wrapper adjustment */
#page-content-wrapper {
    flex: 1;
    min-width: 0;
    background-color: transparent;
    height: calc(100vh - 2rem);
    border-radius: var(--border-radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* The actual scrollable content area */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background: #fff;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--card-shadow);
}

/* Sidebar Internals */
.sidebar-brand {
    padding: 2.5rem 1.5rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-logo {
    width: 44px;
    height: 44px;
    background: var(--brand-color);
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.brand-text {
    font-size: 1.35rem;
    font-weight: 800;
    color: white;
    letter-spacing: -0.03em;
}

.brand-text span {
    color: var(--brand-color);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 1.25rem 2rem;
}

.nav-section {
    margin-bottom: 2.5rem;
}

.nav-label {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-light); /* Beige accent for labels */
    padding-left: 1rem;
    margin-bottom: 1rem;
    opacity: 0.8;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.85rem 1rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: var(--border-radius-md);
    transition: all 0.25s ease;
    margin-bottom: 0.35rem;
    font-size: 0.95rem;
    font-weight: 500;
}

.nav-link i {
    width: 22px;
    margin-right: 1rem;
    font-size: 1.15rem;
    transition: all 0.25s ease;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    transform: translateX(4px);
}

.nav-link:hover i {
    color: var(--brand-color);
}

.nav-link.active {
    background: var(--brand-color);
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.nav-link.active i {
    color: white;
}

.has-arrow::after {
    content: "\f078";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform 0.3s ease;
    opacity: 0.5;
}

.nav-link:not(.collapsed).has-arrow::after {
    transform: rotate(180deg);
}

.nav-sub {
    padding-left: 3rem;
    margin-bottom: 0.5rem;
    position: relative;
}

.nav-sub::before {
    content: "";
    position: absolute;
    left: 1.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
}

.nav-sub-link {
    display: block;
    padding: 0.6rem 0;
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    position: relative;
}

.nav-sub-link:hover, .nav-sub-link.active {
    color: white;
}

.nav-sub-link.active::before {
    content: "";
    position: absolute;
    left: -1.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 100%;
    background: var(--brand-color);
}

/* ========================================================================= */
/* COMPONENT CUSTOMIZATIONS (NO VANILLA BOOTSTRAP)                           */
/* ========================================================================= */

/* Cards */
.card {
    border: none;
    box-shadow: var(--card-shadow);
    border-radius: var(--border-radius-lg);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    background: #fff;
    margin-bottom: 1.5rem;
}
.card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem;
    font-weight: 700;
    font-size: 1.1rem;
}
.card-body {
    padding: 1.5rem;
}

/* Buttons */
.btn {
    font-weight: 600;
    border-radius: var(--btn-radius);
    padding: 0.6rem 1.25rem;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    letter-spacing: 0.02em;
}

.btn-primary {
    background: var(--brand-color);
    border: none;
    color: #fff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background: var(--brand-hover) !important;
    border: none !important;
    color: #fff !important;
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35) !important;
    transform: translateY(-1px);
}

.btn-outline-primary {
    color: var(--brand-color);
    border-color: var(--brand-color);
    border-width: 2px;
}
.btn-outline-primary:hover, .btn-outline-primary:focus, .btn-outline-primary:active {
    background-color: var(--brand-color) !important;
    border-color: var(--brand-color) !important;
    color: #fff !important;
}

.bg-primary {
    background-color: var(--brand-color) !important;
}
.text-primary {
    color: var(--brand-color) !important;
}
.badge {
    padding: 0.5em 0.8em;
    border-radius: 99px;
    font-weight: 600;
}
.badge.bg-primary {
    background: rgba(59, 130, 246, 0.1) !important;
    color: var(--brand-color) !important;
}

/* Form Controls */
.form-control, .form-select {
    border-radius: var(--border-radius-md);
    border: 2px solid var(--border-color);
    padding: 0.6rem 1rem;
    transition: all 0.2s ease;
    box-shadow: none;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand-color);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

/* Select2 overrides */
.select2-container--bootstrap-5 .select2-selection {
    border-radius: var(--border-radius-md) !important;
    border: 2px solid var(--border-color) !important;
    padding: 0.3rem 0.5rem;
}
.select2-container--bootstrap-5 .select2-selection:focus,
.select2-container--bootstrap-5.select2-container--focus .select2-selection {
    border-color: var(--brand-color) !important;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1) !important;
}
.select2-results__option--highlighted[aria-selected] {
    background-color: var(--brand-color) !important;
    color: white !important;
}

/* Table styling (Custom UI) */
.table-responsive {
    border-radius: var(--border-radius-md);
    overflow: hidden;
}
.table {
    margin-bottom: 0;
    color: var(--text-primary);
    border-collapse: separate;
    border-spacing: 0;
}
.table thead th {
    background-color: #f8fafc;
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    border-bottom: 2px solid var(--border-color);
    padding: 1.25rem 1rem;
}
.table tbody td {
    padding: 1.25rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    /* Tabular numbers for financials */
    font-variant-numeric: tabular-nums;
}
.table tbody tr {
    transition: background-color 0.2s ease;
}
.table tbody tr:hover {
    background-color: rgba(59, 130, 246, 0.03);
}
/* Striped tables no longer use heavy borders, just subtle backgrounds */
.table-striped>tbody>tr:nth-of-type(odd)>* {
    box-shadow: inset 0 0 0 9999px rgba(59, 130, 246, 0.02);
}

/* Modals */
.modal-content {
    border-radius: var(--border-radius-lg);
    border: none;
    box-shadow: 0 25px 50px -12px rgba(60, 64, 68, 0.25);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
}
.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
}
.modal-body {
    padding: 2rem;
}
.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
}
.modal-backdrop.show {
    opacity: 0.6;
    backdrop-filter: blur(4px);
}

@media (max-width: 992px) {
    #wrapper {
        padding: 0;
        gap: 0;
    }
    .premium-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        border-radius: 0;
        z-index: 1050;
    }
    #page-content-wrapper {
        height: 100vh;
        border-radius: 0;
    }
    .main-content {
        border-radius: 0;
    }
}
