/*========================================================================================
|
| ?? CSS STYLESHEET: OPTIMIZED AND HIERARCHICAL ORDER
|
| 1. GLOBAL VARIABLES & BASE LAYOUT
| 2. TOP BAR (NAVBAR)
| 3. SIDEBAR LAYOUT & RESPONSIVENESS (Structure)
| 4. SIDEBAR MENU ITEMS (Styling & States)
| 5. USER DROPDOWN (Styling & Transitions)
| 6. MISCELLANEOUS (Footer, Tooltip, Page Title)
| 7. MEDIA QUERIES (Desktop Overrides)
| 
|
========================================================================================*/


/*----------------------------------------------------------------------------------------
| 1. GLOBAL VARIABLES & BASE LAYOUT
----------------------------------------------------------------------------------------*/

/* Define Global CSS Variables (Custom Properties) */
:root {
    --sidebar-width: 295px;
    --sidebar-min-width: 80px;
    --header-height: 60px; /* Fixed Height for Top Bar */
    --footer-height: 60px; /* Define fixed footer height */
    --primary-color: #007bff; /* Primary Blue */
    --primary-light: #f8f9fa; /* Light Gray/Off-White */
    --bg-main: #f2f2fa; /* Main content background color (light purple/gray) */
    
    /* Global Text Color */
    --bs-body-color: #515152;
}

/* Base Page Setup */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-size:0.95em ;
    color: var(--bs-body-color); /* Apply body text color */
    font-family: 'Inter', sans-serif;
    background-color: var(--portal-bg);
    color: #1e293b;

}

@media (max-width: 768px) {
    html, body {
        font-size:0.9em ;
    }
}

/* Base body padding for fixed header */
body {
    padding-top: var(--header-height);
    padding-bottom: var(--footer-height);
}



/*----------------------------------------------------------------------------------------
| 2. TOP BAR (NAVBAR)
----------------------------------------------------------------------------------------*/

.navbar {
    height: var(--header-height);
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    margin-top: 0 !important;
    padding-top: 0 !important;
    z-index: 1050 !important; /* High Z-index to sit above sidebar */
    /*border-bottom: 1px solid var(--primary-light);*/ /* Separator line */
}

/*----------------------------------------------------------------------------------------
| 3. SIDEBAR LAYOUT & RESPONSIVENESS (Structure)
----------------------------------------------------------------------------------------*/

#sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    transition: width 0.3s ease, transform 0.3s ease; /* Smooth transition for expand/collapse */
    height: calc(100vh - var(--header-height));
    position: fixed;
    top: var(--header-height);
    z-index: 1020;
    overflow-x: hidden;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    background-color: var(--primary-light) !important;
    
    /* Mobile: Default state is off-screen */
    transform: translateX(calc(0px - var(--sidebar-width)));
}

/* Main content wrapper */
/* --- STRICT WRAPPER CONSTRAINTS FOR DATAGRIDS --- */
.main-wrapper {
    overflow-x: hidden; 
    box-sizing: border-box;
    /* Animate BOTH the push (margin) and the squish (width) */
    transition: margin-left 0.3s ease, width 0.3s ease !important; 
    padding-bottom: calc(var(--footer-height) + 20px) !important;
}

/* Mobile Constraint (Full Width) */
@media (max-width: 991.98px) {
    .main-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }
}

/* Desktop Constraints (Calculated Math) */
@media (min-width: 992px) {
    /* 1. Default Desktop Expanded */
    .main-wrapper {
        margin-left: var(--sidebar-width) !important;
        width: calc(100% - var(--sidebar-width)) !important;
    }
    
    /* 2. Desktop Collapsed */
    .sidebar-collapsed .main-wrapper {
        margin-left: var(--sidebar-min-width) !important;
        width: calc(100% - var(--sidebar-min-width)) !important;
    }
    
    /* 3. Desktop Hover Expanded (The squish action) */
    body.sidebar-collapsed.sidebar-hover .main-wrapper {
        margin-left: var(--sidebar-width) !important;
        width: calc(100% - var(--sidebar-width)) !important;
    }
}

/* Mobile: Sidebar shown */
.sidebar-show-mobile #sidebar {
    transform: translateX(0); /* Bring into view */
}
.sidebar-show-mobile .main-wrapper {
    pointer-events: none; /* Disable interaction with main content when menu is open */
}


/* Sidebar Toggle Icon Styling */
#sidebarToggle {
    border: none !important;
    background-color: transparent !important;
    box-shadow: none !important;
}

#sidebarToggle i {
    font-size: 1.5rem; /* Icon Size */
    color: #0056b3 !important; /* Icon Color */
}

/*----------------------------------------------------------------------------------------
| 4. SIDEBAR MENU ITEMS (Styling & States)
----------------------------------------------------------------------------------------*/

/* Professional Sidebar Link Base Styling */
.sidebar-link {
    white-space: nowrap;
    transition: background-color 0.2s, color 0.2s;
    border-left: 3px solid transparent;
}

/* Default Link Text Color (Slightly faded dark gray) */
#sidebar > ul > li > a.sidebar-link {
    color: #3a3a3b !important;
}

/* Link Icon Styling */
#sidebar a.sidebar-link i {
    font-size: 1.2rem;
    color: #888 !important; /* Faded dark gray color */
    vertical-align: middle;
    opacity: 0.3 !important; /* Further fade the icons */
}

/* Sub-menu link icons */
#sidebar .collapse a.nav-link i {
    color: #999 !important;
}

/* Link Hover and Active States */
#sidebar a.sidebar-link:hover,
#sidebar a.sidebar-link.active {
    color: #343a40 !important;
    background-color: #f2f2fa;
    border-left-color: var(--primary-color);
    border-radius: 0.4rem;
}

/* Icon Hover and Active State Color */
#sidebar a.sidebar-link:hover i,
#sidebar a.sidebar-link.active i {
    color: #343a40 !important;
}

/* General Link Color Inheritance */
#sidebar a.nav-link {
    color: inherit !important;
}

/* Collapsed State: Hide Text and Arrow */
.sidebar-collapsed #sidebar span,
.sidebar-collapsed #sidebar .arrow-icon {
    display: none;
    opacity: 0;
    transition: opacity 0.1s;
}

/* Submenu Arrow Rotation */
.sidebar-link:not(.collapsed) .arrow-icon {
    transform: rotate(180deg);
}

/* Submenu Text Opacity/Size */
.multi-menu-state{
	opacity:0.3;
	font-size: 0.7rem !important;
}

/* Submenu Item Dot */
.dot{
	font-size:0.5rem !important;
}


/* Submenu Vertical Connector Line (Complex CSS) */
#sidebar .nav-item {
    position: relative;
    margin-top: 0.1rem;
    margin-bottom: 0.1rem;
}
#sidebar .nav-item::before {
    content: '';
    position: absolute;
    top: 40px; /* Start below the main link */
    left: 17px; /* Align with submenu icons */
    width: 5px; /* Line thickness */
    background-color: #F7F2FA; /* Line color */
    z-index: 1;
    display: none;
}
#sidebar .nav-item:has(> .collapse:not(.collapsed))::before {
    display: block; /* Show the line when submenu is open */
    height: calc(100% - 40px); /* Height to bottom of parent LI */
}

#sidebar .collapse ul.nav.flex-column {
    margin-left: 20px; /* Ensure space for the vertical line */
}

/* --- Styling for the Parent Link when a Submenu is Active --- */

/* 1. Make the text BOLD and increase prominence */
#sidebar a.sidebar-link.parent-active {
    font-weight: bold !important;
    /* Optional: Slightly darker color than default links but lighter than true active */
    color: #303030 !important;
}

/* 2. Highlight the icon (increase opacity/brightness) */
#sidebar a.sidebar-link.parent-active i {
    opacity: 1 !important; /* Full opacity */
    color: #444 !important; /* Clearer color */
}

/* 3. Ensure the active sub-link still gets the full styling (already handled, but reinforcing) */
#sidebar a.sidebar-link.active,
#sidebar .collapse a.nav-link.active {
    /* Retains background, primary border, and dark text for the actual active page */
    background-color: #f2f2fa !important;
    border-left-color: var(--primary-color) !important;
    font-weight: bold !important; /* Keep active sub-link text bold */
    color: #343a40 !important;
}

/* 4. Ensure the parent-active styling doesn't override the hover styling */
#sidebar a.sidebar-link.parent-active:hover {
    background-color: #f2f2fa !important; /* Use hover background */
    border-left-color: var(--primary-color) !important;
}







/* Hover expand sidebar when collapsed */

body.sidebar-collapsed.sidebar-hover #sidebar {
    width: var(--sidebar-width);
}

body.sidebar-collapsed.sidebar-hover .main-wrapper {
    margin-left: var(--sidebar-width);
}

/* Show text again when hovering */

body.sidebar-collapsed.sidebar-hover #sidebar span,
body.sidebar-collapsed.sidebar-hover #sidebar .arrow-icon {
    display: inline !important;
    opacity: 1 !important;
}


/* Default expanded sidebar */
#sidebar{
    overflow-y: auto;
}

/* When sidebar is collapsed */
.sidebar-collapsed #sidebar{
    overflow-y: hidden;
}

/* When collapsed but hovering (expanded temporarily) */
.sidebar-collapsed.sidebar-hover #sidebar{
    overflow-y: auto;
}





/*----------------------------------------------------------------------------------------
| 5. USER DROPDOWN (Styling & Transitions)
----------------------------------------------------------------------------------------*/

/* User Image in Header (Trigger) */
.user-image-trigger {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--primary-color);
}

/* User Image inside Dropdown Header */
.user-image-header {
    width: 90px;
    height: 90px;
    max-width: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
}

.dropdown-menu img {
    height: auto;
}

/* Dropdown Panel Header Background */
.user-header {
    background-color: var(--primary-color) !important;
}

/* Dropdown Menu Positioning and Transition */
.navbar .dropdown-menu {
    z-index: 1060 !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
    
    /* Initial state for transition */
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    
    /* Ensure display:block and visibility is handled by JS/Bootstrap */
    display: block;
    visibility: hidden;
}

/* Open state for transition */
.navbar .dropdown-menu.show {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}

/* Hide Bootstrap default arrow */
.navbar .nav-link.dropdown-toggle::after {
    content: none !important;
}

/*----------------------------------------------------------------------------------------
| 6. MISCELLANEOUS (Footer, Tooltip, Page Title)
----------------------------------------------------------------------------------------*/

/* Footer Fix */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--footer-height);
    z-index: 1010;
    background-color: #fafbfc !important;
}

/* Tooltip Decoration */
.sidebar-tooltip .tooltip-inner {
    background-color: #0056b3;
    color: #fff;
    font-weight: bold;
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}
.sidebar-tooltip .tooltip-arrow::before {
    background-color: #0056b3;
}

/* Page Title Bar Styling */
.page-title{
    max-height:7rem;
    padding : 2rem;
    background-color: #F7F2FA !important;
    box-shadow: 0 4px 6px -2px rgba(0, 0, 0, 0.01); /* Subtle bottom shadow */
}

/*----------------------------------------------------------------------------------------
| 7. MEDIA QUERIES (Desktop Overrides)
----------------------------------------------------------------------------------------*/

/* Desktop Layout (min-width: 992px) */
@media (min-width: 992px) {
    /* Sidebar is always visible on desktop */
    #sidebar {
        transform: translateX(0) !important;
    }

    /* Content margin for initial expanded state */
    .main-wrapper {
        margin-left: var(--sidebar-width);
    }
    
    /* Desktop Collapsed State */
    .sidebar-collapsed #sidebar {
        width: var(--sidebar-min-width);
    }

    .sidebar-collapsed .main-wrapper {
        margin-left: var(--sidebar-min-width);
    }
}

/* Mobile Dropdown Position Fix */
@media (max-width: 991.98px) {
    .navbar .nav-item.dropdown .dropdown-menu {
        position: absolute !important;
        right: 0 !important;
        left: auto !important;
        z-index: 1060 !important;
    }
}


/* Hide text "Search" from search box in dataTable */
/* Hide default DataTables label text */
.dt-search label {
    display: none !important;
}

/* Style search input with left icon */
.dt-search .input-group-text {
    background: transparent;
    border-right: 0;
}

.dt-search .form-control {
    border-left: 0;
}

.card-header.sticky-header {
    position: sticky;
    top: 60px;
    z-index: 50; /* keep above table rows */
    background: #fff; /* must have background */
    border-bottom: 1px solid #dee2e6;
}

/* On mobile, expand width */
@media (max-width: 768px) {
    .dt-search {
        width: 100% !important;
    }
    .dt-search .input-group {
        width: 100%;
	height: 50px;
    }

    label[for^="dt-length-"] {
        display: none !important; width: 0;
        height: 0;
        padding: 0;
        margin: 0;
        overflow: hidden; 
    }
    .dt-layout-table{
	margin-top: -2rem !important;
    }
}


.overlay {
    position: fixed;             /* cover full viewport */
    inset: 0; /* Ensures it covers all four corners of the viewport */
    width: 100%;
    height: 100%;                
    background: rgba(255, 255, 255, 0.7); /* semi-transparent overlay */
    display: flex; /* Force Flexbox over any conflicting Bootstrap display utilities */
    justify-content: center !important; /* Force Horizontal Center */
    align-items: center !important;   /* Force Vertical Center */
    z-index: 9999;               
}

.overlay-flex {
    display: flex !important;
    justify-content: center;
    align-items: center;
}

.custom-height {
    height: 50px;       /* Set desired height */
    padding: 0 0.75rem; /* Keep horizontal padding consistent */
    font-size: 1rem;    /* Keep font size normal */
}

.dropdown-icon {
  font-size: 1.25rem; 
}

@media (min-width: 992px) { /* desktop */
  .dropdown-icon {
    font-size: 0.95rem; 
  }
}

@media (max-width: 768px) {
    table.dataTable thead.hide-on-mobile {
	display: none !important;
    }

    table.dataTable thead.hide-on-mobile th {
        padding: 0 !important;
        margin: 0 !important;
        border: 0 !important;
    }
}
.input-group:focus-within {
    border: 2px solid #86b7fe !important;   /* Bootstrap primary color */
    border-radius: 0.375rem  !important;     /* match Bootstrap input radius */
}
.input-group .form-control:focus,
.input-group .form-select:focus {
    box-shadow: none !important;
    border-color: transparent !important;
    outline: none !important;
}

@media (max-width: 767.98px) {
    .small-mobile {
        font-size: 0.875em; /* same as .small */
    }
}

/* Ripple effect */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: "";
    position: absolute;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 50%;
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.4s, opacity 0.8s;
}

.ripple:active::after {
    transform: scale(3);
    opacity: 1;
    transition: 0s;
}

/* Make li look tappable */
a > li {
    cursor: pointer;
}


/* datatable when contains large no of fields prevent main-wrapper to expand unlimited *//* 1. Target the element wrapping the main content area */

/* Target the container that holds your main content */
.main-wrapper {
    /* Critical constraint */
    overflow-x: hidden; 
    width: 100%;
    box-sizing: border-box;
}

/* The element that contains the actual wide content (e.g., a wide table) */

/* --------------------------------------------- */

/* ==========================================================================
   APP-LIKE MODAL STANDARDIZATION (PWA READY)
   Forces all modals to have fixed headers/footers and a scrolling body.
   On mobile: Full screen like a native app view.
   On desktop: Centered box with max-height constraints.
   ========================================================================== */

/* 1. Desktop Constraints (Centered, Max Height) */
.modal-dialog {
    display: flex;
    max-height: calc(100vh - 3.5rem); /* Keeps modal from touching the top/bottom of the desktop screen */
}

/* 2. The Flexbox Core */
.modal-content {
    display: flex;
    flex-direction: column;
    max-height: 100%; /* Constrain to dialog height */
    overflow: hidden; /* Hide outer scroll */
    border: none;
    box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.15);
}

/* 3. Fixed Header */
.modal-header {
    flex-shrink: 0; /* Prevent shrinking */
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); /* Subtle shadow over body */
}

/* 4. Independent Scrollable Body */
.modal-body {
    flex-grow: 1; /* Takes up all remaining space */
    overflow-y: auto; /* Scroll only this section */
    -webkit-overflow-scrolling: touch; /* Silky smooth momentum scrolling for iOS */
    padding: 1.5rem;
}

/* 5. Fixed Footer */
.modal-footer {
    flex-shrink: 0; /* Prevent shrinking */
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    z-index: 10;
    padding: 1rem 1.5rem;
}

/* 6. PWA Mobile View (Strict Fullscreen) */
@media (max-width: 767.98px) {
    .modal-dialog {
        margin: 0 !important;
        max-width: 100vw !important;
        
        /* FIX: Dynamic Viewport Height prevents the browser UI from hiding the footer */
        max-height: 100dvh !important; 
        height: 100dvh !important; 
    }
    .modal-content {
        height: 100dvh !important; 
        border-radius: 0 !important;
    }
}

.btn {
    border-radius: var(--bs-border-radius-pill)!important;
}

    .border-danger {
        animation: pulse-border 2s infinite;
    }

    @keyframes pulse-border {
        0% { opacity: 1; }
        50% { opacity: 0.5; }
        100% { opacity: 1; }
    }
    
    
 

/* Min-height for Desktop/Tablet (screens 768px and wider) */
    
    .tabulator {font-size: inherit !important;}
    

        .tabulator-row .tabulator-cell {padding: 5px; border-right: none;}
        .tabulator .tabulator-header .tabulator-col .tabulator-col-content {padding: 5px;}
        .tabulator-tree-level-0 { font-weight: 400; color: #262625; }
        .tabulator-tree-level-1 {  color: #80807d; }
        
    .tabulator .tabulator-row {
        min-height: 50px!important;
        padding-top:10px!important;
    }
    
    
    .tabulator-row { border-bottom: 1px solid #f8f9fa !important; }
    .tabulator .tabulator-placeholder {
        position: sticky!important; 
        left: 0!important; 
        width: 100%!important;  
        display: flex!important; 
        justify-content: center!important;
        align-items: center!important; /* Centers vertically */
    }
    .tabulator .tabulator-placeholder .tabulator-placeholder-contents{
        font-size: 1rem!important;
        font-weight: 500!important;
        margin: 3rem !important;
    }
    


    /* ðŸš€ The Ultimate Glass Tooltip */
    #super-tooltip {
        position: absolute;
        z-index: 99999;
        background: rgba(33, 37, 41, 0.95); /* Dark Bootstrap gray with slight transparency */
        backdrop-filter: blur(4px); /* Premium glass blur effect */
        color: #ffffff;
        padding: 6px 12px;
        border-radius: 6px;
        font-size: 0.75rem;
        font-weight: 500;
        letter-spacing: 0.3px;
        pointer-events: none; /* Prevents the tooltip from blocking mouse clicks */
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        text-align: center;
        
        /* Animation setup */
        opacity: 0;
        transform: translateY(8px) scale(0.95);
        transition: opacity 0.2s ease-out, transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }
    
    /* The active state that triggers the pop animation */
    #super-tooltip.visible {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    
    /* The little triangle arrow pointing down */
    #super-tooltip::after {
        content: '';
        position: absolute;
        top: 100%;
        left: 50%;
        margin-left: -5px;
        border-width: 5px;
        border-style: solid;
        border-color: rgba(33, 37, 41, 0.95) transparent transparent transparent;
    }
    
    /* Style the headers */
    .tabulator-col-title {
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: #64748b !important;
        font-weight: 700 !important;
    }
    /* Beautiful row hover effect */
    .tabulator-row {
        border-bottom: 1px solid #f1f5f9 !important;
        transition: background-color 0.2s ease, transform 0.1s ease;
    }
    .tabulator-row:hover {
        background-color: #ffffff !important;
        box-shadow: 0 4px 12px rgba(0,0,0,0.05) !important;
        transform: translateY(-1px);
        z-index: 10;
    }