/* ServeEase responsive overrides — keep after theme CSS */

html {
    -webkit-text-size-adjust: 100%;
}

img,
svg,
video,
canvas {
    max-width: 100%;
    height: auto;
}

.main-header .logo img {
    max-width: none;
    width: auto;
    max-height: 40px;
    height: auto;
}

.wrapper,
.content-wrapper,
.container-full,
.box,
.box-body,
.modal-body,
.table-responsive {
    max-width: 100%;
}

/* ---------- Layout: right-bar should not steal width when off-canvas ---------- */
@media (max-width: 1199.98px) {
    .content-wrapper,
    .main-header,
    .main-footer,
    .right-side {
        margin-right: 0.75rem !important;
    }
}

@media (max-width: 767.98px) {
    .content-wrapper,
    .main-footer,
    .right-side {
        margin-left: 0.75rem !important;
        margin-right: 0.75rem !important;
    }

    .main-header {
        z-index: 1050 !important;
        display: flex !important;
        align-items: center;
        flex-wrap: nowrap;
        max-height: none;
    }

    .main-header > .logo-box {
        display: flex !important;
        align-items: center;
        justify-content: flex-start;
        width: auto !important;
        float: none !important;
        flex: 0 0 auto;
        padding: 0 4px 0 6px;
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
    }

    .main-header .logo {
        height: auto !important;
        line-height: normal !important;
        padding: 0 4px 0 0;
    }

    .main-header .logo .logo-lg {
        display: inline-block !important;
        line-height: normal !important;
        padding-left: 0;
    }

    .main-header .logo img {
        max-height: 32px !important;
        width: auto !important;
    }

    .main-header .navbar {
        flex: 1 1 auto;
        width: auto !important;
        margin-left: 0 !important;
        min-height: 56px;
        padding-left: 0 !important;
    }

    .fixed .content-wrapper,
    .fixed .right-side {
        margin-top: 64px !important;
    }

    .content {
        padding-top: 0.5rem;
        border-width: 1px;
        padding-left: 8px;
        padding-right: 8px;
    }
}

/* ---------- Pages without Quick Access right bar ---------- */
@media (min-width: 768px) {
    body.no-right-bar .main-header,
    body.no-right-bar .content-wrapper,
    body.no-right-bar .main-footer,
    body.no-right-bar footer {
        margin-right: 0 !important;
    }
}

/* ---------- Submenu: icon and label on same line ---------- */
.sidebar-menu .treeview-menu > li > a {
    display: flex !important;
    align-items: center !important;
    line-height: 1.35 !important;
}

.sidebar-menu .treeview-menu > li > a > i,
.sidebar-menu .treeview-menu > li > a > i.icon-Commit,
.sidebar-menu .treeview-menu > li > a > .bi-dot {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 20px !important;
    box-sizing: content-box !important;
    padding: 0 20px 0 10px !important;
    margin: 0 !important;
    line-height: 1 !important;
    vertical-align: middle;
    position: relative !important;
    top: 0 !important;
}

.sidebar-menu .treeview-menu > li > a > .bi-dot {
    font-size: 1.4rem;
}

.sidebar-menu .treeview-menu > li > a > span:not(.pull-right-container):not(.path1):not(.path2):not(.path3) {
    flex: 1 1 auto;
    min-width: 0;
    position: static !important;
    top: 0 !important;
    line-height: 1.35;
}

.sidebar-menu .treeview-menu > li > a > .pull-right-container {
    position: absolute !important;
    right: 0;
    top: 50%;
    margin-top: -7px;
    width: auto !important;
}

/* ---------- Sidebar overlay sits under the header, like live site ---------- */
@media (max-width: 767.98px) {
    body.sidebar-open::before {
        content: "";
        position: fixed;
        top: 64px;
        right: 0;
        bottom: 0;
        left: 0;
        background: rgba(15, 23, 42, 0.25);
        z-index: 1030;
    }

    .main-sidebar,
    .sidebar-mini.sidebar-collapse .main-sidebar,
    .sidebar-open .main-sidebar {
        z-index: 1040 !important;
        margin-top: 64px !important;
        padding-top: 8px !important;
        width: min(280px, 82vw) !important;
        max-width: 82vw;
        height: calc(100dvh - 64px) !important;
        border-radius: 0 12px 12px 0;
        box-shadow: 8px 0 24px rgba(15, 23, 42, 0.12);
    }

    .sidebar-open .content-wrapper,
    .sidebar-open .main-footer {
        pointer-events: none;
    }

    .sidebar-menu,
    .sidebar-menu > li,
    .sidebar-menu li > a {
        white-space: normal !important;
        overflow: visible !important;
        line-height: 1.35;
    }

    .sidebar-menu .treeview-menu > li > a {
        white-space: normal !important;
        height: auto !important;
    }

    .sidebar-menu > li > .treeview-menu,
    .sidebar-menu > li > .treeview-menu .treeview-menu,
    .light-skin .sidebar-menu > li > .treeview-menu,
    .light-skin.sidebar-collapse .sidebar-menu > li > .treeview-menu,
    .light-skin.sidebar-collapse .sidebar-menu > li > .treeview-menu > .treeview .treeview-menu,
    .sidebar-mini.sidebar-collapse .sidebar-menu > li > .treeview-menu,
    .sidebar-mini:not(.sidebar-mini-expand-feature).sidebar-collapse .sidebar-menu > li:hover > .treeview-menu {
        background: transparent !important;
        box-shadow: none !important;
        border: 0 !important;
        border-radius: 0 !important;
        position: static !important;
        left: auto !important;
        width: auto !important;
        margin: 0 !important;
        padding: 0 0 0 12px !important;
    }

    .sidebar-mini.sidebar-collapse .sidebar-menu > li.menu-open > .treeview-menu,
    .sidebar-mini.sidebar-collapse .sidebar-menu > li.active > .treeview-menu {
        display: block !important;
    }

}

/* ---------- Header / topbar ---------- */
.main-header .search-box {
    width: min(300px, 100%) !important;
}

.mobile-search-dropdown {
    min-width: min(280px, 90vw);
    max-width: calc(100vw - 24px);
}

@media (max-width: 575.98px) {
    .main-header .logo-lg img {
        max-height: 32px;
        width: auto;
    }

    .navbar-custom-menu > .nav > li > a {
        padding-left: 8px;
        padding-right: 8px;
    }

    .user-image.avatar {
        width: 32px;
        height: 32px;
        margin-left: 4px !important;
        margin-right: 4px !important;
    }
}

/* ---------- Page headers wrap instead of overflowing ---------- */
.box-header.d-flex {
    flex-wrap: wrap;
    gap: 8px;
}

.box-header .box-title {
    margin-bottom: 0;
    word-break: break-word;
}

@media (max-width: 575.98px) {
    .box-header.d-flex {
        flex-direction: column;
        align-items: stretch !important;
    }

    .box-header .btn {
        width: 100%;
    }
}

/* ---------- Forms and filters / report pages ---------- */
@media (max-width: 767.98px) {
    .box-body .row.mb-3 > [class*="col-"],
    .box-body .row.g-2 > [class*="col-"],
    .box-body .row.mb-3.align-items-end > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
        width: 100%;
        margin-bottom: 1rem;
        padding-left: 12px;
        padding-right: 12px;
    }

    .box-body .row.mb-3 > [class*="col-"]:last-child,
    .box-body .row.g-2 > [class*="col-"]:last-child,
    .box-body .row.mb-3.align-items-end > [class*="col-"]:last-child {
        margin-bottom: 0;
    }

    .box-body .row.mb-3 > [class*="col-"] > label,
    .box-body .row.g-2 > [class*="col-"] > label,
    .box-body label.fw-bold {
        display: block;
        margin-bottom: 0.5rem;
    }

    .box-body .row.mb-3 > [class*="col-"].d-flex,
    .box-body .row.g-2 > [class*="col-"].d-flex {
        flex-wrap: wrap;
        align-items: stretch !important;
        justify-content: flex-start !important;
        gap: 0.75rem;
        margin-top: 0.25rem;
        padding-top: 0.25rem;
    }

    .box-body .row.mb-3 > [class*="col-"].d-flex .btn,
    .box-body .row.g-2 > [class*="col-"].d-flex .btn {
        flex: 1 1 calc(50% - 0.375rem);
        min-width: 120px;
    }

    .box-body .d-flex.justify-content-end.mb-3,
    .box-body .d-flex.justify-content-md-end.mb-3 {
        flex-wrap: wrap;
        justify-content: stretch !important;
        gap: 0.75rem;
        margin-top: 0.5rem;
    }

    .box-body .d-flex.justify-content-end.mb-3 .btn,
    .box-body .d-flex.justify-content-md-end.mb-3 .btn {
        flex: 1 1 calc(50% - 0.375rem);
        min-width: 120px;
    }

    .box-body .form-control,
    .box-body .form-select,
    .box-body .select2-container {
        width: 100% !important;
        max-width: 100%;
        margin-bottom: 0;
    }

    .form-control,
    .form-select,
    .select2-container {
        width: 100% !important;
        max-width: 100%;
    }
}

/* ---------- Tables ---------- */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 767.98px) {
    .table-responsive {
        overflow-x: auto;
    }

    .table th,
    .table td,
    .dataTables_wrapper th,
    .dataTables_wrapper td {
        white-space: nowrap !important;
        word-break: normal;
        font-size: 13px;
        padding: 0.5rem 0.65rem;
        vertical-align: middle;
    }

    .table .btn-sm {
        white-space: nowrap;
        margin-bottom: 4px;
    }

    .dataTables_wrapper .row {
        flex-wrap: wrap;
        --bs-gutter-x: 0.75rem;
    }

    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        width: 100%;
        text-align: left !important;
        float: none !important;
        margin-bottom: 0.5rem;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        margin-left: 0 !important;
        display: block;
        margin-top: 4px;
    }

    .dataTables_wrapper .dataTables_paginate .pagination {
        justify-content: flex-start;
        flex-wrap: wrap;
    }
}

#menuMaster {
    table-layout: auto;
}

@media (max-width: 991.98px) {
    #menuMaster {
        table-layout: auto !important;
        min-width: 720px;
    }
}

/* ---------- Modals ---------- */
@media (max-width: 991.98px) {
    .modal-fullwidth,
    .modal-dialog.modal-fullwidth,
    .modal-dialog.modal-xl,
    .modal-dialog.modal-lg {
        max-width: calc(100% - 16px) !important;
        width: calc(100% - 16px) !important;
        margin: 8px auto !important;
    }

    .modal .row > [class*="col-md-1"],
    .modal .row > [class*="col-md-2"],
    .modal .row > [class*="col-lg-1"],
    .modal .row > [class*="col-lg-2"] {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

@media (max-width: 767.98px) {
    .modal {
        padding: 12px !important;
    }

    .modal-dialog,
    .modal-fullwidth,
    .modal-dialog.modal-fullwidth,
    .modal-dialog.modal-xl,
    .modal-dialog.modal-lg,
    .modal-dialog.modal-sm,
    .modal-dialog.modal-dialog-centered,
    .modal-dialog.modal-dialog-scrollable {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 auto !important;
        min-height: 0 !important;
        height: auto !important;
    }

    .modal-dialog-centered {
        display: flex !important;
        align-items: center;
        min-height: calc(100% - 24px) !important;
    }

    .modal-dialog-scrollable {
        height: auto !important;
        max-height: calc(100dvh - 24px) !important;
    }

    .modal-content {
        min-height: 0 !important;
        height: auto !important;
        max-height: calc(100dvh - 24px) !important;
        border-radius: 12px !important;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .modal-body {
        max-height: calc(100dvh - 160px) !important;
        overflow-y: auto !important;
        padding: 12px 16px;
        flex: 1 1 auto;
    }

    .modal-footer {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: stretch;
    }

    .modal-footer .btn {
        flex: 1 1 auto;
    }

    .modal .row > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .modal .ms-4 {
        margin-left: 0 !important;
    }

    .modal .border-end {
        border-right: 0 !important;
        border-bottom: 1px solid #dee2e6;
        margin-bottom: 12px;
        padding-bottom: 12px;
    }

    .category-list,
    #categoryList,
    #menuItemsContainer,
    .menu-list {
        height: auto !important;
        max-height: 42vh !important;
    }
}

.modal .select2-container {
    width: 100% !important;
    max-width: 100%;
}

/* ---------- POS / takeaway / purchase item cards ---------- */
@media (max-width: 767.98px) {
    .item-card h6 {
        font-size: 0.95rem;
    }

    .scrollable-table {
        max-height: 240px;
    }
}

/* ---------- Quick access / control sidebar ---------- */
@media (max-width: 575.98px) {
    .quick-access-sidebar.control-sidebar,
    .quick-access-sidebar.control-sidebar + .control-sidebar-bg {
        width: min(320px, 92vw);
    }

    .quick-access-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .control-sidebar-open .content-wrapper,
    .control-sidebar-open .main-footer,
    .control-sidebar-open .right-side {
        margin-right: 0 !important;
    }
}

/* ---------- Dashboard cards ---------- */
@media (max-width: 575.98px) {
    .box-body .d-flex.align-items-start img.w-80 {
        width: 56px !important;
        margin-right: 12px !important;
    }

    .box-body h2 {
        font-size: 1.35rem;
    }
}

/* ---------- Auth ---------- */
@media (max-width: 575.98px) {
    .bg-white.rounded10.shadow-lg .p-40 {
        padding: 20px !important;
    }

    .content-top-agile h2,
    .content-top-agile h3 {
        font-size: 1.35rem;
    }

    .bg-white.rounded10 .btn {
        display: block;
        width: 100%;
        margin: 8px 0 0;
    }
}

/* ---------- Print stays as designed ---------- */
@media print {
    .main-sidebar,
    .main-header,
    .right-bar,
    .control-sidebar,
    .main-footer {
        display: none !important;
    }

    .content-wrapper,
    .main-header,
    .main-footer {
        margin: 0 !important;
    }
}
