:root {
    /* Brand Colors - Apex Premium Style */
    --primary-purple: #551996;
    --dark-purple: #2d0d53;
    --accent-purple: #9650e6;
    --deep-bg: #0d061a;
    --silver-text: #b8b3c5;
    --sidebar-gradient: linear-gradient(180deg, #1a0833 0%, #0d061a 100%);
    --active-indicator: #9650e6;
    --sidebar-hover-bg: rgba(150, 80, 230, 0.1);
    --section-title-color: rgba(150, 80, 230, 0.6);

    --primary-color: var(--primary-purple);
    --secondary-color: #6c757d;
    --bg-color: #f8f9fa;
    --sidebar-bg: var(--deep-bg);
    --sidebar-hover: var(--sidebar-hover-bg);
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    --accent-color: var(--accent-purple);
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: #f4f5f7;
    color: #444;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Wrapper and Sidebar */
.wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
}

#sidebar {
    min-width: 270px;
    max-width: 270px;
    min-height: 100vh;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--sidebar-gradient);
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.2);
    z-index: 1050;
    position: sticky;
    top: 0;
}

#sidebar.active {
    margin-right: -270px;
}

#sidebar .sidebar-header {
    padding: 40px 20px;
    background: transparent;
    border-bottom: 1px solid rgba(150, 80, 230, 0.1) !important;
}

#sidebar .brand-logo {
    transition: transform 0.3s ease;
}

#sidebar .brand-logo:hover {
    transform: scale(1.1);
}

#sidebar ul.components {
    padding: 15px 12px;
}

/* Section Title */
.sidebar-section-title {
    padding: 20px 25px 8px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--section-title-color);
    opacity: 0.8;
}

#sidebar ul li a {
    padding: 11px 18px;
    font-size: 0.92rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 12px;
    margin: 4px 0;
    color: var(--silver-text) !important;
    position: relative;
    overflow: hidden;
}

#sidebar ul li a i {
    width: 26px;
    text-align: center;
    font-size: 1.05rem;
    opacity: 0.7;
    margin-left: 10px;
}

#sidebar ul li a:hover {
    background: var(--sidebar-hover);
    color: #fff !important;
    padding-right: 22px;
}

#sidebar ul li a:hover i {
    opacity: 1;
    color: var(--accent-purple);
}

#sidebar ul li a.active {
    background: linear-gradient(90deg, rgba(85, 25, 150, 0.3) 0%, rgba(150, 80, 230, 0.1) 100%);
    color: #fff !important;
    font-weight: 600;
}

#sidebar ul li a.active::before {
    content: "";
    position: absolute;
    right: 0;
    top: 25%;
    height: 50%;
    width: 3px;
    background: var(--active-indicator);
    border-radius: 4px 0 0 4px;
    box-shadow: -2px 0 10px var(--active-indicator);
}

#sidebar ul li.active>a,
a[aria-expanded="true"] {
    background: rgba(150, 80, 230, 0.05);
}

#sidebar ul ul li a {
    padding: 8px 45px 8px 20px;
    font-size: 0.88rem;
    margin: 2px 0;
}

#sidebar ul ul li a:hover {
    padding-right: 50px;
}

/* Content Area */
#content {
    width: 100%;
    min-height: 100vh;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    padding: 15px 10px;
    background: #fff;
    border: none;
    border-radius: 0;
    margin-bottom: 30px;
    box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.05);
}

.navbar-btn {
    box-shadow: none;
    outline: none !important;
    border: none;
}

/* Modern Cards */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
    overflow: hidden;
    background: #fff;
    transition: transform 0.2s ease;
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, .03);
    padding: 1.5rem;
    font-weight: 700;
    color: var(--dark-purple);
    display: flex;
    align-items: center;
}

.card-header i {
    margin-left: 10px;
    color: var(--primary-purple);
}

.card-body {
    padding: 2rem;
}

/* Tables */
.table-responsive {
    border-radius: 0.5rem;
}

.table {
    margin-bottom: 0;
    vertical-align: middle;
}

.table thead th {
    background-color: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
    color: #495057;
    font-weight: 600;
    padding: 1rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
}

.table-hover tbody tr:hover {
    background-color: #f8f9fa;
    transition: background-color 0.2s;
}

/* Buttons */
.btn-primary {
    background-color: var(--primary-purple);
    border-color: var(--primary-purple);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--dark-purple);
    border-color: var(--dark-purple);
}

.btn-info {
    background-color: var(--accent-purple);
    border-color: var(--accent-purple);
    color: #fff !important;
}

.btn-info:hover {
    background-color: var(--primary-purple);
    border-color: var(--primary-purple);
}

.btn {
    border-radius: 8px;
    padding: 0.5rem 1.25rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-action {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    margin: 0 0.1rem;
}

/* Form Controls */
.form-control,
.form-select {
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ced4da;
}

.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
    border-color: #86b7fe;
}

/* Select2 Customization to match Bootstrap 5 */
.select2-container--bootstrap-5 .select2-selection {
    min-height: 38px;
    border-radius: 0.375rem;
}

/* Fix RTL issues for dropdowns */
.dropdown-menu {
    text-align: right;
}

@media (max-width: 768px) {
    #sidebar {
        margin-right: -260px;
        position: fixed;
        height: 100vh;
        z-index: 1050;
    }

    #sidebar.active {
        margin-right: 0;
    }

    #content {
        width: 100%;
    }

    /* Overlay for mobile sidebar */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        opacity: 0;
        transition: all 0.3s ease-in-out;
    }

    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }
}

/* --- Print Styles --- */
@media print {

    /* Hide Navigation and Sidebar */
    #sidebar,
    .navbar,
    nav,
    header,
    footer,
    .btn-primary:not(.print-visible),
    .btn-secondary,
    .btn-success,
    .btn-danger,
    .btn-info,
    .btn-warning,
    .btn-outline-secondary,
    .btn-outline-primary,
    .no-print {
        display: none !important;
    }

    /* Expand Content to full width */
    #content,
    .container,
    .container-fluid {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        min-height: auto !important;
        box-shadow: none !important;
        border: none !important;
    }

    body {
        background-color: white !important;
        font-size: 14pt !important;
        color: black !important;
    }

    /* Card styling for print */
    .card {
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        margin-bottom: 20px !important;
        break-inside: avoid;
    }

    .card-header {
        background-color: #f8f9fa !important;
        border-bottom: 2px solid #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Print Badges with borders instead of colors if needed */
    .badge {
        border: 1px solid #000 !important;
        color: #000 !important;
        background-color: transparent !important;
    }

    table {
        page-break-inside: auto;
    }

    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    thead {
        display: table-header-group;
    }

    tfoot {
        display: table-footer-group;
    }
}