/* 
 * Custom Styles for Cash Management System
 * This file should be included after bootstrap.min.css
 */

/* --- Main Layout & Sidebar --- */
body {
    background-color: #f8f9fa; /* A light grey background for the main content area */
}

.sidebar {
    width: 200px; /* Further reduced for maximum compactness */
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background-color: #1a1d21; /* Slightly darker for better contrast */
    transition: width 0.3s ease-in-out, transform 0.3s ease-in-out;
    z-index: 1031; /* Above main content and overlay, below modals */
    overflow-x: hidden; /* Prevent horizontal scrollbar */
    overflow-y: auto; /* Enable vertical scrolling if needed */
    box-shadow: 2px 0 4px rgba(0,0,0,0.1); /* Add subtle shadow */
}

.main-content-wrapper {
    transition: margin-left 0.3s ease-in-out;
    margin-left: 200px; /* Match new sidebar width */
    min-height: 100vh; /* Ensure wrapper is at least full screen height */
}

/* Compact sidebar styling */
.sidebar .d-flex {
    padding: 0.75rem 0.5rem; /* More compact padding */
}

.sidebar .nav-link {
    padding: 0.4rem 0.6rem; /* More compact padding */
    font-size: 0.8rem; /* Smaller font size */
    border-radius: 0.25rem; /* Smaller radius */
    margin-bottom: 0.0625rem; /* Minimal gap between items */
    transition: all 0.2s ease-in-out;
    font-weight: 500; /* Slightly bold for better readability */
}

.sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.15);
    transform: translateX(2px);
    color: #ffffff !important;
}

.sidebar .nav-link.active {
    background-color: #007bff;
    color: white !important;
    box-shadow: 0 2px 4px rgba(0,123,255,0.3);
}

.sidebar .nav-link i {
    font-size: 0.9rem; /* Smaller icon size */
    width: 1.1rem; /* Fixed width for alignment */
    text-align: center;
    margin-right: 0.4rem; /* Reduced margin */
}

/* Compact submenu styling */
.sidebar .nav.flex-column.ms-3 {
    margin-left: 1.2rem !important; /* More compact indentation */
    border-left: 2px solid rgba(255,255,255,0.1); /* Visual hierarchy line */
    padding-left: 0.5rem;
}

.sidebar .nav-link.small {
    padding: 0.3rem 0.5rem; /* More compact padding for submenu items */
    font-size: 0.75rem; /* Smaller font for submenu */
    margin-bottom: 0.03125rem; /* Minimal spacing */
    font-weight: 400; /* Normal weight for submenu */
}

/* Compact logo styling */
.sidebar .fs-4 {
    font-size: 1rem !important; /* Smaller logo text */
    font-weight: 600; /* Bold for prominence */
}

.sidebar .bi-cash-coin {
    font-size: 1.1rem !important; /* Smaller logo icon */
}

/* Compact dropdown in sidebar */
.sidebar .dropdown-toggle {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 500;
}

.sidebar hr {
    margin: 0.5rem 0; /* More compact margin for dividers */
    opacity: 0.2;
    border-color: rgba(255,255,255,0.2);
}

/* Disabled dropdown items */
.dropdown-item.disabled,
.dropdown-item:disabled {
    color: #6c757d;
    pointer-events: none;
    background-color: transparent;
    opacity: 0.6;
    cursor: not-allowed;
}

/* Style for text inside sidebar links to allow hiding */
.sidebar .nav-link .nav-link-text {
    transition: opacity 0.2s ease-in-out;
    opacity: 1;
}

/* --- Desktop Collapsed State --- */
body.sidebar-collapsed .sidebar {
    width: 55px; /* Ultra-compact collapsed width */
}

body.sidebar-collapsed .main-content-wrapper {
    margin-left: 55px; /* Match collapsed sidebar width */
}

/* Hide text, show only icons when collapsed */
body.sidebar-collapsed .sidebar .nav-link-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

body.sidebar-collapsed .sidebar .nav-link {
    justify-content: center;
    padding: 0.6rem 0.3rem; /* More compact collapsed padding */
    margin-bottom: 0.1rem;
}

body.sidebar-collapsed .sidebar .nav-link i {
    margin-right: 0 !important;
    font-size: 1rem; /* Slightly larger icon when collapsed for visibility */
}

/* Hide submenu items when collapsed */
body.sidebar-collapsed .sidebar .collapse {
    display: none !important;
}

/* Hide user info text when collapsed */
body.sidebar-collapsed .sidebar .dropdown-toggle strong {
    display: none;
}

body.sidebar-collapsed .sidebar .dropdown-toggle {
    justify-content: center;
}

/* --- Mobile Off-Canvas State (for screens smaller than 768px) --- */
@media (max-width: 767.98px) {
    .sidebar {
        width: 200px; /* Maintain compact width on mobile */
        transform: translateX(-100%); /* Hide off-screen by default */
        box-shadow: 0 0 20px rgba(0,0,0,0.3);
    }

    .main-content-wrapper {
        margin-left: 0; /* Full width content on mobile */
    }

    body.sidebar-mobile-open .sidebar {
        transform: translateX(0); /* Slide in when open */
    }

    /* Mobile overlay */
    body.sidebar-mobile-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0,0,0,0.5);
        z-index: 1030; /* Below sidebar, above content */
    }

    /* On mobile, the desktop 'collapsed' state should have no effect */
    body.sidebar-collapsed .sidebar {
        width: 200px;
    }
    body.sidebar-collapsed .main-content-wrapper {
        margin-left: 0;
    }
}

/* --- Table Sorting Styles --- */
.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 0.2s ease;
}

.sortable:hover {
    background-color: rgba(0, 123, 255, 0.1) !important;
}

.sortable .sort-icon {
    display: inline-block;
    margin-left: 5px;
    opacity: 0.5;
    font-size: 0.8em;
}

.sortable .sort-icon i {
    color: #007bff;
}

.sortable:hover .sort-icon {
    opacity: 1;
}

/* --- Performance Optimizations --- */
.invoice-grid {
    contain: layout;
    will-change: transform;
}

.invoice-card {
    contain: layout style;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* Pagination Controls */
#dashboard-pagination-controls,
#pagination-controls {
    position: sticky;
    bottom: 0;
    background: rgba(248, 249, 250, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid #dee2e6;
    padding: 1rem;
    margin-top: auto;
    z-index: 10;
}

#dashboard-record-info,
#record-info {
    font-weight: 500;
    color: #6c757d;
}

#dashboard-page-info,
#page-info {
    font-weight: 600;
    font-size: 0.875rem;
}

/* Loading states */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* Virtual scrolling container */
.virtual-scroll-container {
    height: 60vh;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
}

/* Smooth scrolling for better UX */
html {
    scroll-behavior: smooth;
}