/**
 * ============================================================================
 * ILMLI Professional Theme - "Classic Navy Enterprise"
 * Unified Mobile-First CSS (Bootstrap 5 Compliant)
 * ============================================================================
 */

/* ==========================================================================
   1. GLOBAL COLOR VARIABLES (Pure Navy Palette)
   ========================================================================== */
:root {
    /* THE NAVY PALETTE */
    --primary-dark: #040169c4;     /* Deepest Navy - For Sidebar & Top Banners */
    --primary-main: #003366;       /* YOUR THEME COLOR - Classic Navy for Buttons & Links */
    --primary-medium: #004C99;     /* Medium Navy - For hover states */
    --primary-light: #b2c9fbfd;    /* Soft Slate-Blue - For visible borders */
    --primary-lighter: #E6F0FA;    /* Crisp Icy Navy - Distinct color for Table Headers */
    --primary-lightest: #F5F9FD;   /* Barely-there Navy tint - For table row hovers */
    
    /* TEXT COLORS */
    --text-dark: #0A192F;          /* Deepest blue-black for highest text readability */
    --text-muted: #5C7080;         /* Navy-tinted gray for secondary text */
    --text-white: #FFFFFF;
    
    /* NEUTRAL BACKGROUNDS */
    --bg-light: #F8FAFC;           /* Page background (slightly cool off-white) */
    --border-color: #D5E1EA;
    --border-light: #EBF0F5;

    /* LAYOUT SIZING */
    --sidebar-width: 280px; 
    --sidebar-collapsed-width: 80px;
    --header-height: 62px;
}

body {
    background-color: var(--bg-light);
    color: var(--text-dark);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    height: calc(100vh - var(--header-height));
    overflow-x: hidden;
    width: 100%;
}

/* ==========================================================================
   2. GLOBAL OVERRIDES (Replacing Black with Deep Navy)
   ========================================================================== */
.bg-dark {
    background-color: var(--primary-main) !important;
    color: var(--text-white) !important;
    border-color: var(--primary-main) !important;
}

body .bg-dark,
body div.bg-dark,
body nav.bg-dark,
body header.bg-dark,
.card-header.bg-dark {
    background-color: var(--primary-main) !important;
    color: #FFFFFF !important;
    border-color: var(--primary-main) !important;
}

.card-header {
    background-color: var(--primary-light) !important;
    color: var(--primary-dark) !important;
}

/* Primary Buttons */
.btn-primary {
    background-color: var(--primary-main) !important;
    border-color: var(--primary-main) !important;
    box-shadow: 0 2px 4px rgba(0, 51, 102, 0.2) !important;
}
.btn-primary:hover {
    background-color: var(--primary-medium) !important;
    border-color: var(--primary-medium) !important;
}
.btn-outline-primary {
    color: var(--primary-main) !important;
    border-color: var(--primary-main) !important;
}
.btn-outline-primary:hover {
    background-color: var(--primary-main) !important;
    color: var(--text-white) !important;
}



/* Hover Utilities */
.custom-hover-opacity:hover { opacity: 1 !important; transform: scale(1.1); transition: all 0.2s; }
.custom-hover-bg:hover { background-color: rgba(255,255,255,0.1); border-radius: 8px; transition: all 0.2s; }

/* ==========================================================================
   3. DESKTOP SIDEBAR & NAVIGATION (Standard Layout)
   ========================================================================== */
.sidebar-wrapper { 
    background: linear-gradient(180deg, #002244 0%, #003366 100%);
    min-width: var(--sidebar-width); 
    max-width: var(--sidebar-width);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1050;
    white-space: nowrap; 
    overflow-x: hidden;
}

.sidebar-menu-btn { 
    color: rgba(255,255,255,0.85); 
    background: transparent; 
    border: none; 
    text-align: left; 
    padding: 12px 15px; 
    border-radius: 8px; 
    font-weight: 500; 
    transition: all 0.2s; 
    width: 100%; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    cursor: pointer; 
}
.sidebar-menu-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.sidebar-menu-btn.active { background: rgba(0, 149, 217, 0.2); color: #fff; font-weight: bold; border-left: 4px solid #0095D9; }
button.sidebar-menu-btn:not(.collapsed) { background: rgba(255,255,255,0.08); }

.sidebar-submenu { list-style: none; padding-left: 0; margin-bottom: 0; margin-top: 5px; background: rgba(0,0,0,0.15); border-radius: 8px; overflow: hidden; }
.sidebar-sub-link { color: rgba(255,255,255,0.7); text-decoration: none; padding: 10px 15px 10px 45px; display: block; font-size: 0.9rem; transition: all 0.2s; }
.sidebar-sub-link:hover { color: #fff; background: rgba(255,255,255,0.05); padding-left: 50px; }
.sidebar-sub-link.active { color: #fff; background: rgba(0, 149, 217, 0.2); font-weight: 600; border-left: 2px solid #0095D9; }

.sidebar-menu-btn .bi-chevron-down { transition: transform 0.3s; font-size: 0.8rem; }
.sidebar-menu-btn:not(.collapsed) .bi-chevron-down { transform: rotate(180deg); }



/*========================================================================
   4. TABS & SWIPEABLE NAVIGATION
   ========================================================================== */
.nav-tabs { border-bottom: 2px solid var(--primary-main) !important; }
.nav-tabs .nav-link.active, .nav-pills .nav-link.active {
    background-color: var(--primary-main) !important;
    color: var(--text-white) !important;
    border-color: var(--primary-main) !important;
    font-weight: bold !important;
}
.nav-tabs .nav-link, .nav-pills .nav-link {
    color: var(--text-muted) !important;
    font-weight: 600;
    transition: all 0.2s ease;
}
.nav-tabs .nav-link:hover, .nav-pills .nav-link:hover {
    color: var(--primary-main) !important;
    background-color: var(--primary-lighter) !important;
}

#financeTabs, .swipe-tabs, .custom-scrollbar {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
}
#financeTabs::-webkit-scrollbar, .swipe-tabs::-webkit-scrollbar, .custom-scrollbar::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

/* ==========================================================================
   5. TABLE ENHANCEMENTS
   ========================================================================== */
.card > .table-responsive > .table { margin-bottom: 0; }
.table-responsive { min-height: 270px; }

.table-light, .table-light > th, .table-light > td,
thead.table-light th, thead.table-light tr th {
    background-color: var(--primary-lighter) !important;
    color: var(--primary-dark) !important;
    border-bottom: 2px solid var(--primary-light) !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    vertical-align: middle;
}

.table-hover > tbody > tr:hover > td,
.table-hover > tbody > tr:hover > th {
    background-color: var(--primary-lightest) !important;
    color: var(--primary-dark) !important;
    transition: background-color 0.2s ease;
}

/* ==========================================================================
   6. RESPONSIVE BREAKPOINTS (MOBILE FIRST SCALING)
   ========================================================================== */

/* --- TABLETS & DESKTOPS (Min 768px) --- */
@media (min-width: 768px) {
    .app-desc { display: block; } /* Dashboard app cards description */
    .bottom-nav { display: none !important; } /* Hide bottom mobile nav completely on PC */
}

/* --- MOBILE & SMALL TABLETS (Max 767.98px - Standard Bootstrap 'md' breakpoint) --- */
@media (max-width: 767.98px) {
    /* Base Font Scaling */
    html { font-size: 14px !important; }
    .navbar h5 { font-size: 1.1rem !important; }
    .btn { padding: 0.375rem 0.75rem !important; font-size: 0.9rem !important; }
    
    /* Layout Adjustments */
    .container-fluid.px-4 { padding-left: 12px !important; padding-right: 12px !important; }
    
    /* Floating Right Sidebar (Mobile Only) */
    .sidebar-wrapper { 
        position: fixed !important; 
        top: var(--header-height) !important; 
        bottom: 60px !important; /* Above bottom nav */
        height: auto !important; 
        right: -100% !important; /* Hidden off-screen right */
        left: auto !important; 
        margin: 0 !important; 
        z-index: 1055 !important; 
        border-top-left-radius: 16px; 
        border-bottom-left-radius: 16px;
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        box-shadow: none;
    }
    .sidebar-wrapper.mobile-show { 
        right: 0 !important; 
        box-shadow: -10px 0 30px rgba(0,0,0,0.5) !important; 
    }

    /* Fixed Bottom Mobile Navigation */
    .bottom-nav { 
        position: fixed; 
        bottom: 0; left: 0; right: 0; 
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        box-shadow: 0 -4px 12px rgba(0,0,0,0.08); 
        display: flex; 
        justify-content: space-around; 
        align-items: center; 
        padding: 8px 0; 
        z-index: 1040; 
        border-top: 1px solid #f1f1f1; 
        padding-bottom: max(env(safe-area-inset-bottom), 5px); /* iOS Home bar safe area */
    }
    .bottom-nav-item { 
        text-align: center; color: #6c757d; text-decoration: none; font-size: 0.7rem; 
        flex-grow: 1; transition: all 0.2s; display: flex; flex-direction: column; 
        align-items: center; justify-content: center; font-weight: 600;
    }
    .bottom-nav-item i { display: block; font-size: 1.3rem; margin-bottom: 2px; }
    .bottom-nav-item.active { color: var(--primary-main); }
    .bottom-nav-item.active i { font-weight: 900; transform: scale(1.1); }
    .bottom-nav-item:active { transform: scale(0.95); }

    /* Responsive Card Tables (Transforms tables into stacked cards) */
    .responsive-card-table thead { display: none; }
    .responsive-card-table tr {
        display: block; margin-bottom: 1rem; border: 1px solid var(--border-color);
        border-radius: 8px; background-color: #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }
    .responsive-card-table td {
        display: flex; justify-content: space-between; align-items: center;
        text-align: right; border-bottom: 1px solid var(--border-light); padding: 12px 15px;
    }
    .responsive-card-table td::before {
        content: attr(data-label); font-weight: 600; color: var(--primary-main);
        text-align: left; flex: 1; font-size: 0.85rem;
    }
    .responsive-card-table td:last-child {
        border-bottom: none; background-color: var(--bg-light);
        justify-content: center; border-radius: 0 0 8px 8px;
    }
}

/* Unified Button Strategy for ERP */
.btn-erp {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem; /* Comfortable for touch */
    font-weight: 600;
    transition: all 0.2s ease;
}

/* PC View: Compact and uniform */
@media (min-width: 992px) {
    .btn-erp {
        font-size: 0.85rem;
        padding: 0.4rem 0.8rem;
    }
}

/* Mobile View: High-touch surface area */
@media (max-width: 991.98px) {
    .btn-erp {
        padding: 0.75rem 1.25rem; /* Larger touch target */
        font-size: 1rem;
        width: 100%; /* Full width buttons for mobile input */
        margin-bottom: 0.5rem;
    }
}

/* --- EXTRA SMALL MOBILE (Max 575.98px - Bootstrap 'sm' breakpoint) --- */
@media (max-width: 575.98px) {
    .tab-content.p-4 { padding: 15px !important; }
}

/* --- VERY SMALL PHONES (Max 380px) --- */
@media (max-width: 380px) {
    html { font-size: 13px !important; }
    .bottom-nav-item { font-size: 0.6rem; }
    .bottom-nav-item i { font-size: 1.1rem; }
}

/* ==========================================================================
   7. PRINT OPTIMIZATIONS
   ========================================================================== */
@media print {
    body { background-color: #fff !important; zoom: 100% !important; transform: none !important; }
    .no-print { display: none !important; }
    .table th, .table td { 
        border: 1px solid #000 !important; 
        padding: 3px 4px !important; 
        color: #000 !important; 
        font-size: 10pt !important; 
    }
    .table-light, .bg-dark, thead { background-color: #f2f2f2 !important; color: #000 !important; }
}