/*
=================================================
    Sticky Layout Enhancements
    Makes TABLE headers sticky while content scrolls
    Applied globally without modifying individual pages
=================================================
*/

/* NOTE: Site navigation (top-bar, logo-bar) is NOT sticky - only table headers */

/* ========================================
   Sticky Table Headers (GridView)
   ======================================== */

/* Enhanced sticky table headers - works for all GridViews globally */
.table-responsive {
    position: relative;
    max-height: 600px; /* Default max height for scrollable tables */
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Make table headers sticky within their container */
.table-responsive thead th,
.table-responsive .data-table thead th,
.table-responsive .upload-table thead th,
.table-responsive .gridView thead th,
.table-responsive table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #292929 !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* Ensure header stays on top during scroll */
.table-responsive thead::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -2px;
    height: 2px;
    background: rgba(0, 0, 0, 0.1);
}

/* ========================================
   Scrollable Content Area
   ======================================== */

/* Main content should scroll independently */
.main-content {
    overflow-y: auto;
    flex: 1;
    /* Add smooth scrolling */
    scroll-behavior: smooth;
}

/* ========================================
   Table Scroll Enhancements
   ======================================== */

/* Remove bottom margin/padding from table-responsive if it's causing spacing */
.table-responsive {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* Remove extra spacing from data-table */
.data-table {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* Smooth scrollbar styling */
.table-responsive::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ========================================
   Optional: Sticky Section Headers
   ======================================== */

/* Make form-section headers sticky if desired */
.form-section h3 {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--light-bg, #F8F9FA);
    padding: 15px 0;
    margin: 0 0 20px 0;
    border-bottom: 2px solid var(--border-color, #E0E8F0);
}

/* ========================================
   Responsive Adjustments
   ======================================== */

@media (max-width: 768px) {
    /* Reduce table height on mobile */
    .table-responsive {
        max-height: 400px;
    }
    
    /* Adjust sticky positioning for mobile */
    .logo-bar {
        position: relative;
        top: auto;
    }
}

/* ========================================
   Utility Classes for Custom Heights
   ======================================== */

/* Allow pages to override table scroll height if needed */
.table-responsive.scroll-sm {
    max-height: 300px;
}

.table-responsive.scroll-md {
    max-height: 500px;
}

.table-responsive.scroll-lg {
    max-height: 800px;
}

.table-responsive.scroll-full {
    max-height: calc(100vh - 250px); /* Full viewport minus headers/footer */
}

/* Remove scroll height restriction */
.table-responsive.no-scroll {
    max-height: none;
    overflow-y: visible;
}
