/* ============================================================
   GLOBAL LAYOUT FIXES (ALWAYS KEEP THESE)
============================================================ */

/* Prevent Spruha vertical centering bugs */
html, body {
    height: 100% !important;
    margin: 0;
    padding: 0;
}

body {
    display: flex !important;
    flex-direction: column !important;
    min-height: 100vh !important;
}

/* Footer pinned to bottom */
.footer {
    margin-top: auto !important;
}

/* Page content layout */
.page {
    flex: 1 0 auto;
    display: block !important;
    min-height: auto !important;
    justify-content: flex-start !important;
}



/* ============================================================
   FIX HEADER OVERLAP
============================================================ */

/* Push content down below the fixed header */
.app.sidebar-mini.ltr {
    padding-top: 80px !important; /* Adjust if header height changes */
}



/* ============================================================
   TABLET + MOBILE (Your required: min-height: 55vh)
============================================================ */

@media (max-width: 991.98px) {

    /* Your required height */
    .page {
        min-height: 55vh !important;
    }

    .page-header,
    .page-header-breadcrumb {
        margin-top: 50px !important;
    }

    .main-content.app-content {
        padding: 10px !important;
    }

    .container-fluid {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    /* Header alignment */
    .page-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }

    .page-header h2 {
        font-size: 18px !important;
    }

    .page-header .breadcrumb {
        font-size: 12px !important;
    }

    .page-header .d-flex {
        width: 100% !important;
        gap: 10px !important;
        justify-content: flex-start !important;
    }

    .page-header button {
        padding: 8px 12px !important;
        font-size: 13px !important;
        white-space: nowrap !important;
    }
}



/* ============================================================
   MOBILE (< 576px)
============================================================ */

@media (max-width: 576px) {

    /* Keep same height rule on mobile */
    .page {
        min-height: 55vh !important;
    }

    .main-content.app-content {
        padding: 5px !important;
    }

    .container-fluid {
        padding-left: 5px !important;
        padding-right: 5px !important;
    }

    /* Page header compact */
    .page-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
        padding-top: 5px !important;
        padding-bottom: 5px !important;
    }

    .page-header h2 {
        font-size: 17px !important;
    }

    .page-header .breadcrumb {
        font-size: 10.5px !important;
        margin-bottom: 0 !important;
    }

    /* Two-column button layout */
    .page-header .d-flex {
        width: 100% !important;
        justify-content: space-between !important;
        gap: 8px !important;
    }

    .page-header button {
        width: 48% !important;
        padding: 6px !important;
        font-size: 11px !important;
    }

    .accordion-button {
        font-size: 13px !important;
        padding: 6px 10px !important;
    }
}



/* ============================================================
   UNIVERSAL DATATABLE SCROLL (TABLET + MOBILE)
============================================================ */

@media (max-width: 991px) {

    .dataTables_wrapper {
        overflow-x: auto !important;
        width: 100% !important;
        -webkit-overflow-scrolling: touch !important;
    }

    table.dataTable {
        min-width: 900px !important;
        width: 100% !important;
        display: block !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
    }

    table.dataTable th,
    table.dataTable td {
        padding: 6px 10px !important;
        font-size: 12px !important;
        white-space: nowrap !important;
    }
}


/* Phones < 375px */
@media (max-width: 375px) {

    table.dataTable {
        min-width: 700px !important;
    }

    table.dataTable th,
    table.dataTable td {
        padding: 3px 4px !important;
        font-size: 11px !important;
    }

    .page-header,
    .page-header-breadcrumb {
        margin-top: 0 !important;
    }
}



/* ============================================================
   FIX: Override Spruha's mobile padding (63px bug)
============================================================ */

@media (max-width: 767px) {
    /* Stronger selector wins over Spruha SCSS */
    html body .main-content.app-content .page-header {
        padding-top: 15px !important;
    }
}
