/* =====================================================================
   Global responsive overrides
   Loaded after the template CSS on every page. Selectors are prefixed
   with "html body" where needed so they win over the per-view <style>
   blocks that sit later in the document.
   ===================================================================== */

/* ---------- Base ---------- */
body {
    max-width: 100%;
    overflow-x: hidden;
}

img, video, canvas, iframe {
    max-width: 100%;
}

html body .content-wrapper input:not([type="checkbox"]):not([type="radio"]),
html body .content-wrapper select,
html body .content-wrapper textarea {
    max-width: 100%;
}

/* Long words / codes should never force the page wider */
.content-wrapper label,
.content-wrapper h1, .content-wrapper h2, .content-wrapper h3,
.content-wrapper h4, .content-wrapper h5, .content-wrapper h6 {
    overflow-wrap: anywhere;
}

/* ---------- Layout: use the full width on large screens ---------- */
html body .main-panel .content-wrapper > .container {
    max-width: 1800px;
    width: 100%;
}

/* Views wrap themselves in another .container – don't double the gutters */
html body .main-panel .content-wrapper .container .container {
    max-width: 100%;
    width: 100%;
    padding-left: 0;
    padding-right: 0;
}

.main-panel {
    min-width: 0;
}

/* ---------- Tables ---------- */
.table-responsive,
.rsp-table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.rsp-table > table {
    margin-bottom: 0;
}

/* DataTables controls */
.dataTables_wrapper {
    width: 100%;
    max-width: 100%;
}

    .dataTables_wrapper::after {
        content: "";
        display: table;
        clear: both;
    }

/* ---------- Mobile sidebar backdrop ---------- */
.rsp-sidebar-backdrop {
    display: none;
}

/* ---------- Header ---------- */
.navbar .navbar-brand-wrapper .brand-logo img {
    max-width: 100%;
}

.rsp-nav-info {
    max-width: 40vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* =====================================================================
   Tablets and below (sidebar becomes off-canvas)
   ===================================================================== */
@media (max-width: 991.98px) {
    html body .content-wrapper {
        padding: 1.5rem 1rem;
    }

    html body .main-panel .content-wrapper > .container {
        padding-left: 0;
        padding-right: 0;
    }

    /* Must stay above the backdrop (1030). Prefixed with "html body" because
       views reload admin-assets/css/style.css later in the page, and its
       ".sidebar { z-index: 11 }" would otherwise drop the sidebar below the
       backdrop - every tap on the menu then lands on the backdrop and closes it. */
    html body .sidebar.sidebar-offcanvas {
        z-index: 1031;
        box-shadow: -4px 0 16px rgba(0, 0, 0, .2);
    }

    .rsp-sidebar-backdrop.show {
        display: block;
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, .4);
        z-index: 1030;
    }
}

/* Print-style pages (A4 width) shrink on screen; print output is untouched */
@media screen and (max-width: 991.98px) {
    html body #parentDIV,
    html body #PrintDiv {
        width: auto !important;
        max-width: 100% !important;
    }
}

/* =====================================================================
   Phones
   ===================================================================== */
@media (max-width: 767.98px) {
    html body .content-wrapper {
        padding: 1rem .5rem;
    }

    html body .content-inner {
        padding: 12px;
    }

    html body .main-title-box h1 {
        font-size: 14px;
    }

    html body .card .card-body {
        padding: 1rem;
    }

    /* Header: keep only icons */
    .navbar .navbar-menu-wrapper {
        padding-left: 8px;
        padding-right: 8px;
    }

    /* Rows that put a button on the left and info on the right */
    html body .content-wrapper [style*="text-align:right"],
    html body .content-wrapper [style*="text-align: right"],
    html body .content-wrapper .text-right,
    html body .content-wrapper .text-md-right,
    html body .content-wrapper .text-end {
        text-align: left !important;
    }

    /* Buttons wrap instead of overflowing */
    html body .content-wrapper .btn,
    html body .content-wrapper .btn-default,
    html body .content-wrapper .btn-theme-red,
    html body .content-wrapper .btn-delete,
    html body .content-wrapper .btn-update {
        white-space: normal;
        margin-bottom: 6px;
    }

    /* Table cells: no squashed columns, scroll sideways instead */
    html body .content-wrapper table th,
    html body .content-wrapper table td {
        white-space: nowrap;
        font-size: 13px;
    }

    html body .content-wrapper table th {
        padding: 8px;
    }

    html body .content-wrapper table td {
        padding: 6px 8px;
    }

    /* DataTables controls stack */
    html body .dataTables_wrapper .dataTables_length,
    html body .dataTables_wrapper .dataTables_filter,
    html body .dataTables_wrapper .dataTables_info,
    html body .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        text-align: left !important;
        width: 100%;
        margin-bottom: 8px;
    }

    html body .dataTables_wrapper .dataTables_filter label {
        display: flex;
        align-items: center;
        gap: 6px;
        width: 100%;
    }

    html body .dataTables_wrapper .dataTables_filter input {
        flex: 1;
        width: auto;
        margin-left: 0 !important;
    }

    html body .dataTables_wrapper .dataTables_paginate {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 2px;
    }

    /* Employee search suggestion lists use inline width:50% */
    html body #employeeList,
    html body .emp-search-result {
        width: 100% !important;
        left: 0 !important;
    }

    /* Modals */
    html body .modal-dialog {
        margin: .5rem;
        max-width: calc(100% - 1rem);
    }

    /* Footer */
    .footer {
        text-align: center;
        padding: 15px 10px;
    }

    .footer .container {
        padding: 0;
    }

    /* Dashboard counters */
    html body .start-number {
        max-width: 100%;
    }
}

/* =====================================================================
   Small phones
   ===================================================================== */
@media (max-width: 575.98px) {
    html body .content-wrapper {
        padding: .75rem .25rem;
    }

    html body .content-inner {
        padding: 10px;
    }

    .navbar .navbar-menu-wrapper {
        flex: 1;
        min-width: 0;
    }
}

/* =====================================================================
   Print – never apply screen-only helpers
   ===================================================================== */
@media print {
    .rsp-table,
    .table-responsive {
        overflow: visible !important;
    }

    .rsp-sidebar-backdrop {
        display: none !important;
    }
}
