/* ==========================================
   Variables & General Settings
   ========================================== */
:root {
    /* Brand Colors */
    --primary-navy: #2B3674;     /* Lighter, softer navy */
    --primary-purple: #80246A;   /* Vibrant purple to match the image */
    --primary-purple-light: #f4eaff; /* Soft background for active states */
    
    /* Layout */
    --sidebar-width: 250px;
    --header-height: 80px;
    
    /* Theme Colors */
    --bg-body: #f4f7fe;          /* Very light blue-grey background */
    --surface-white: #ffffff;
    
    /* Typography Colors */
    --text-main: #2B3674;        /* Dark navy for headings */
    --text-secondary: #A3AED0;   /* Light slate for subtitles/icons */
    
    /* UI Elements */
    --border-light: #E0E5F2;     /* Very subtle border color */
    --hover-bg: #F4F7FE;
    --shadow-soft: 0px 18px 40px rgba(112, 144, 176, 0.12); /* Large, diffused shadow */
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

p {
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* Custom Text/Background Colors */
.text-navy { color: var(--text-main) !important; }
.text-purple { color: var(--primary-purple) !important; }
.bg-navy { background-color: var(--text-main) !important; }
.bg-purple { background-color: var(--primary-purple) !important; }

/* ==========================================
   Global Card UI (Matches image exactly)
   ========================================== */
.card {
    background-color: var(--surface-white);
    border-radius: 20px !important;
    border: none !important;
    box-shadow: var(--shadow-soft) !important;
    margin-bottom: 24px;
}

.card-header {
    background-color: transparent !important;
    border-bottom: 1px solid var(--border-light) !important;
    padding: 20px 24px !important;
}

.card-title {
    color: var(--text-main);
    font-weight: 700;
    font-size: 18px;
    margin: 0;
}

/* ==========================================
   Layout Structures (Fixed Components)
   ========================================== */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--surface-white);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: var(--transition-smooth);
}

.top-header {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    height: var(--header-height);
    background: var(--bg-body); /* Header blends into body bg */
    border-bottom: none;
    z-index: 1030;
    transition: var(--transition-smooth);
    padding: 0 30px;
}

.main-content {
    margin-top: var(--header-height);
    margin-left: var(--sidebar-width);
    min-height: calc(100vh - var(--header-height));
    padding: 10px 30px 30px 30px;
    transition: var(--transition-smooth);
}

/* ==========================================
   Sidebar Styling Details
   ========================================== */
.sidebar .brand-title {
    height: var(--header-height);
    padding: 0 30px;
    background: var(--surface-white);
    display: flex;
    justify-content: flex-start;
    align-items: center;
    font-size: 24px;
    letter-spacing: -0.5px;
    margin-top: 20px;
}

.sidebar-nav { 
    padding: 20px 0; 
    overflow-y: auto; 
    flex-grow: 1; 
    scrollbar-width: thin;
}

.nav-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    margin: 30px 30px 10px 30px;
    letter-spacing: 0.5px;
}

.nav-item { 
    list-style: none; 
    margin-bottom: 8px; 
    padding: 0 16px; 
}

.nav-link {
    display: flex; 
    align-items: center; 
    padding: 12px 14px;
    color: var(--text-secondary); 
    border-radius: 12px; 
    text-decoration: none;
    font-weight: 600; 
    font-size: 15px;
    transition: var(--transition-smooth);
    position: relative;
}

.nav-link i { 
    width: 24px; 
    font-size: 18px; 
    margin-right: 14px; 
    text-align: center; 
    color: var(--text-secondary);
    transition: var(--transition-smooth);
}

/* Hover and Active States */
.nav-link:hover { 
    color: var(--text-main); 
}

.nav-link:hover i {
    color: var(--primary-purple);
}

.nav-item.active > .nav-link, 
.nav-link.active {
    color: var(--primary-purple);
    background-color: var(--hover-bg);
}

.nav-item.active > .nav-link i, 
.nav-link.active i {
    color: var(--primary-purple);
}

/* Right border accent for active link (like image) */
.nav-item.active > .nav-link::after, 
.nav-link.active::after {
    content: '';
    position: absolute;
    right: -16px; /* Push to edge of sidebar */
    top: 50%;
    transform: translateY(-50%);
    height: 30px;
    width: 4px;
    background-color: var(--primary-purple);
    border-radius: 4px 0 0 4px;
}

/* Sidebar Dropdown Menu */
.sidebar .dropdown-menu {
    background-color: transparent; 
    border: none; 
    padding: 0;
    margin-top: 5px; 
    position: static !important;
    transform: none !important; 
    box-shadow: none;
}

.sidebar .dropdown-menu li a {
    color: var(--text-secondary); 
    padding: 10px 15px 10px 52px; 
    display: flex;
    align-items: center; 
    text-decoration: none; 
    border-radius: 10px; 
    font-size: 14px;
    font-weight: 500;
}

.sidebar .dropdown-menu li a:hover, 
.sidebar .dropdown-menu li a.active {
    color: var(--text-main); 
    background-color: transparent;
}

/* ==========================================
   Header Search & Components
   ========================================== */
.header-search {
    background: var(--surface-white);
    border-radius: 30px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    width: 350px;
    box-shadow: 0px 2px 10px rgba(112, 144, 176, 0.05);
}

.header-search input {
    border: none;
    background: transparent;
    outline: none;
    box-shadow: none;
    font-size: 14px;
    color: var(--text-main);
    width: 100%;
}

.header-search input::placeholder {
    color: var(--text-secondary);
}

/* ==========================================
   Tables & Data
   ========================================== */
.table-responsive {
    scrollbar-width: thin;
}

.table {
    margin-bottom: 0;
}

.table th {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-light);
    padding: 16px 24px;
    background-color: transparent !important;
}

.table td {
    padding: 16px 24px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.875rem;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background-color: rgba(244, 247, 254, 0.5);
}

/* Specific text muted overrides for table data */
.table td.text-muted {
    color: var(--text-secondary) !important;
    font-weight: 500;
}

/* ==========================================
   Buttons & Badges
   ========================================== */
.btn {
    font-weight: 600;
    border-radius: 12px;
    padding: 10px 20px;
    font-size: 0.875rem;
    transition: var(--transition-smooth);
}

.btn-sm{
    padding: 8px 16px;
    font-size: 0.75rem;
}

.btn-primary, .bg-primary {
    background-color: var(--primary-purple) !important;
    border-color: var(--primary-purple) !important;
}

.btn-primary:hover {
    background-color: #5c1bb8 !important; /* Darker purple */
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(112, 38, 226, 0.3);
}

.badge {
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 12px;
}

.badge.bg-success {
    background-color: #05CD99 !important;
    color: #fff;
}

.badge.bg-warning {
    background-color: #FFCE20 !important;
    color: #fff;
}

/* ==========================================
   Dashboard Widgets (Top Row Cards)
   ========================================== */
.stat-icon-circle {
    width: 56px;
    height: 56px;
    border-radius: 16px; 
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background-color: var(--primary-purple-light) !important;
    color: var(--primary-purple) !important;
}

/* ==========================================
   Mobile Responsive Rules
   ========================================== */
.sidebar-overlay {
    display: none; position: fixed; top: 0; left: 0;
    width: 100vw; height: 100vh; background: rgba(11, 20, 55, 0.5);
    backdrop-filter: blur(4px); z-index: 1030;
}

@media (max-width: 992px) {
    .sidebar { left: calc(-1 * var(--sidebar-width)); }
    .sidebar.show { left: 0; }
    .sidebar-overlay.show { display: block; }
    
    .top-header { left: 0; }
    .main-content { margin-left: 0; padding: 20px 15px; }
}

@media (max-width: 768px) {
    #toast-container > .toast {
        width: 90% !important;
        margin: 10px auto !important;
        border-radius: 16px;
    }
    
    .header-search {
        display: none !important;
    }
}


/* ==========================================
   Select2 Modern UI Fixes
   ========================================== */
/* Fix container height and border to match modern inputs */
.select2-container--default .select2-selection--multiple {
    border: 1px solid #E0E5F2 !important; /* Matches your border-light */
    border-radius: 12px !important;
    min-height: 45px;
    padding: 4px 8px !important;
    background-color: #ffffff !important;
    transition: all 0.2s ease;
}

/* Fix Focus state */
.select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: var(--primary-purple) !important;
    box-shadow: 0 0 0 0.25 cold-purple-transparent; /* Optional subtle glow */
}

/* Style the Tags (Pills) */
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: var(--primary-navy) !important; /* Soft navy background */
    color: #fff !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 4px 10px 4px 24px !important; /* Extra left padding for the X icon */
    margin: 4px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    position: relative;
}

/* Style and position the 'X' (Remove) icon */
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: rgba(255, 255, 255, 0.8) !important;
    border-right: none !important;
    padding: 0 8px !important;
    position: absolute !important;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    font-weight: bold !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    background-color: transparent !important;
    color: #fff !important;
}

/* Adjust the search input inside the box */
.select2-container--default .select2-selection--multiple .select2-search__field {
    margin-top: 7px !important;
    font-size: 14px !important;
    color: var(--text-main) !important;
}