/* --- VEDIC THEME ENGINE (FIXED) --- */

:root {
    /* CORE BRAND COLOR (Saffron/Agni) - Visible in both modes */
    --tblr-primary: #f59e0b;
    --tblr-primary-rgb: 245, 158, 11;
    --tblr-primary-fg: #000000; 
}

/* --- DARK MODE (Brahmanda) --- */
/* We target the attribute [data-bs-theme="dark"] which Tabler uses */
[data-bs-theme="dark"] {
    --tblr-body-bg: #0f172a;        /* Deep Cosmic Blue */
    --tblr-bg-surface: #1e293b;     /* Lighter Slate Panels */
    --tblr-card-bg: #1e293b;
    --tblr-border-color: #334155;
    --tblr-border-color-translucent: rgba(51, 65, 85, 0.5);
    
    /* Logo Color in Dark Mode */
    --logo-text-color: #ffffff;
}

/* --- LIGHT MODE (Surya) --- */
[data-bs-theme="light"] {
    --tblr-body-bg: #f8fafc;        /* Soft White/Grey */
    --tblr-bg-surface: #ffffff;     /* Pure White Panels */
    --tblr-card-bg: #ffffff;
    --tblr-border-color: #e2e8f0;
    
    /* Logo Color in Light Mode */
    --logo-text-color: #0f172a;     /* Dark text */
}

/* --- UNIVERSAL FIXES --- */

/* 1. LOGO VISIBILITY FIX */
/* Uses the variable defined above so it swaps color automatically */
.navbar-brand, .navbar-brand a {
    color: var(--logo-text-color) !important;
}
.navbar-brand span {
    color: var(--tblr-primary) !important; /* The Saffron Diamond */
    margin-right: 5px;
}

/* 2. SIDEBAR SCROLL FIX */
.navbar-vertical.navbar-expand-lg {
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
}

/* 3. AVATAR PLACEHOLDER */
.avatar-placeholder {
    background-color: var(--tblr-primary) !important;
    color: #000 !important;
    font-weight: 700;
}

/* 4. BURGER MENU FIX */
/* Inverts the color of the burger icon in dark mode so it is visible */
[data-bs-theme="dark"] .navbar-toggler-icon {
    filter: invert(1);
}

/* FORCE VISIBLE BURGER MENU */
.navbar-toggler {
    border-color: rgba(255,255,255,0.1);
}
.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(245, 158, 11, 1)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
}

/* --- DESKTOP COLLAPSE LOGIC --- */

/* 1. Define the Collapsed State */
body.sidebar-collapsed {
    --tblr-sidebar-width: 4.5rem; /* Shrink from 15rem to 4.5rem */
}

/* 2. Hide Text Labels when Collapsed */
body.sidebar-collapsed .nav-link-title,
body.sidebar-collapsed .navbar-brand span {
    display: none;
}

/* 3. Center the Icons when Collapsed */
body.sidebar-collapsed .nav-link-icon {
    margin-right: 0 !important;
    text-align: center;
    width: 100%;
}

/* 4. Center the Logo Icon when Collapsed */
body.sidebar-collapsed .navbar-brand {
    justify-content: center;
    padding-left: 0;
}

/* 5. Ensure Burger Button is visible on Desktop */
/* Tabler hides .navbar-toggler on desktop by default, we force it back */
@media (min-width: 992px) {
    .navbar-toggler.d-lg-block {
        display: block !important;
    }
}

/* --- DESKTOP COLLAPSE ENGINE (FIXED) --- */

/* 1. Force the Variable Update */
body.sidebar-collapsed {
    --tblr-sidebar-width: 5rem !important; /* 80px width */
}

/* 2. FORCE The Sidebar Container to Shrink */
@media (min-width: 992px) {
    body.sidebar-collapsed .navbar-vertical {
        width: 5rem !important;
        transition: width 0.2s ease; /* Smooth animation */
    }

    /* 3. FORCE The Content Page to Move Left */
    body.sidebar-collapsed .page-wrapper {
        margin-left: 5rem !important;
        transition: margin-left 0.2s ease;
    }
}

/* 4. Hide The Text Labels */
body.sidebar-collapsed .nav-link-title, 
body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .badge {
    display: none !important;
}

/* 5. Center The Icons */
body.sidebar-collapsed .nav-link-icon {
    margin-right: 0 !important;
    text-align: center;
    width: 100%;
    font-size: 1.25rem;
}

/* 6. Center the Logo Diamond */
body.sidebar-collapsed .navbar-brand a {
    justify-content: center !important;
    padding: 0;
}
body.sidebar-collapsed .navbar-brand span.me-2 {
    margin-right: 0 !important;
}

/* 7. Hide Dropdown Arrows */
body.sidebar-collapsed .dropdown-toggle::after {
    display: none;
}

/* --- MOBILE MENU FIX (FINAL) --- */
@media (max-width: 991px) {
    /* 1. Target the collapsible menu inside the sidebar */
    .navbar-vertical .navbar-collapse {
        position: fixed;        /* Force it to float relative to screen, not parent */
        top: 3.5rem;            /* Push it down below the Header (approx 60px) */
        left: 0;
        width: 100%;
        max-height: calc(100vh - 3.5rem); /* Allow scrolling if menu is long */
        overflow-y: auto;
        z-index: 10000 !important; /* Force it ON TOP of everything */
        
        /* 2. Visual Style */
        background-color: var(--tblr-bg-surface-dark) !important;
        border-bottom: 1px solid var(--tblr-border-color);
        box-shadow: 0 10px 30px rgba(0,0,0,0.5);
        padding: 1rem;
    }
    
    /* 3. Ensure the menu items are visible */
    .navbar-vertical .navbar-nav {
        flex-direction: column;
        padding-left: 0;
        margin-bottom: 0;
    }
    
    /* 4. Fix Link Colors on Mobile */
    .navbar-vertical .nav-link {
        padding: 0.75rem 1rem;
        border-radius: 4px;
        color: rgba(255,255,255,0.7) !important;
    }
    .navbar-vertical .nav-link:hover,
    .navbar-vertical .nav-link.active {
        background: rgba(255,255,255,0.1);
        color: #ffffff !important;
    }
}