/*
|--------------------------------------------------------------------------
| App-Wide Responsive Overrides
|--------------------------------------------------------------------------
| Loaded after the legacy dashboard styles so we can safely improve the
| backend/client/guest/auth experience on tablets and phones.
*/

:root {
    --app-shell-padding: clamp(14px, 2.4vw, 30px);
}

html,
body {
    max-width: 100%;
}

body,
.page-container,
.main-content,
.main-content-inner,
.container-fluid,
.row,
[class*="col-"],
.card,
.card-body,
.modal-dialog,
.modal-content {
    min-width: 0;
}

.header-area,
.page-title-area,
.main-content-inner {
    padding-left: var(--app-shell-padding);
    padding-right: var(--app-shell-padding);
}

.main-content-inner > .container-fluid {
    padding-left: 0;
    padding-right: 0;
}

.single-table,
.table-responsive,
.table-shell,
.invoice-form-card,
.purchase-form-card,
.sidebar-card,
.discount-sidebar,
.document-control-card,
.document-controls-row,
.totals-section,
.purchase-form-body,
.invoice-form-card,
.purchase-form-card {
    max-width: 100%;
}

.table-responsive,
.table-shell,
.single-table,
.single-table .dataTables_wrapper,
.modal-body {
    -webkit-overflow-scrolling: touch;
}

.table-responsive,
.table-shell {
    overflow-x: auto;
}

.table-shell table,
.table-responsive table,
.single-table table {
    min-width: 640px;
}

.table td,
.table th,
.product-table td,
.product-table th,
.items-table td,
.items-table th {
    word-break: keep-all;
}

.notification-area,
.notification-area li,
.user-profile,
.user-name,
.user-name.dropdown-toggle,
.notification-area .dropdown-toggle,
.notify-text,
.header-area .row > div {
    min-width: 0;
}

.notification-area {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
}

.notification-area li {
    margin-left: 0;
}

.notify-box {
    max-width: min(92vw, 350px);
}

.user-profile {
    margin-right: 0;
    max-width: 100%;
}

.user-name {
    display: flex;
    align-items: center;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-profile .dropdown-menu,
.notification-area .dropdown-menu {
    max-width: min(92vw, 360px);
}

.modal-dialog {
    max-width: calc(100vw - 1.5rem);
}

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

.select2-container .select2-selection--single,
.select2-container .select2-selection--multiple {
    max-width: 100%;
}

.dataTables_wrapper > .row {
    margin-left: 0;
    margin-right: 0;
}

.dataTables_wrapper > .row:nth-child(2) .col-sm-12 {
    padding-left: 0;
    padding-right: 0;
}

.invoice-form .input-lg,
.invoice-form .input-md,
.invoice-form .input-sm,
.invoice-form .input-xs,
.invoice-form .input-xxs {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.guest .container {
    max-width: min(100%, 1140px);
}

body #app main.py-4 {
    padding-left: 16px;
    padding-right: 16px;
}

body .card-signin {
    overflow: hidden;
}

@media (max-width: 1199.98px) {
    body .invoice-create-header,
    body .invoice-edit-header,
    body .purchase-create-header,
    body .purchase-edit-header,
    body .document-controls-row,
    body .invoice-form-card .form-header,
    body .purchase-form-card .purchase-form-header,
    body .invoice-form-card .customer-dates-row,
    body .invoice-form-card .date-fields,
    body .purchase-form-card .vendor-dates-row,
    body .purchase-form-card .date-fields {
        grid-template-columns: 1fr !important;
        align-items: stretch;
    }

    body .invoice-create-header,
    body .invoice-edit-header,
    body .purchase-create-header,
    body .purchase-edit-header {
        display: flex;
        flex-wrap: wrap;
        gap: 14px;
    }

    body .invoice-form-card {
        padding: 20px;
    }

    body .purchase-form-body {
        padding: 20px;
    }

    body .invoice-form-card .form-header,
    body .purchase-form-card .purchase-form-header {
        gap: 18px;
    }

    body .sidebar-card,
    body .discount-sidebar {
        margin-top: 24px;
        position: static;
    }
}

@media (max-width: 991.98px) {
    .page-container {
        position: relative;
    }

    .page-container::before {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        opacity: 0;
        visibility: hidden;
        transition:
            opacity 0.25s ease,
            visibility 0.25s ease;
        z-index: 998;
    }

    .page-container:not(.sbar_collapsed)::before {
        opacity: 1;
        visibility: visible;
    }

    .sidebar-menu {
        position: fixed !important;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100vh;
        min-height: 100vh;
        width: min(86vw, 320px);
        max-width: min(86vw, 320px);
        transform: translateX(0);
        margin-left: 0 !important;
        transition: transform 0.3s ease;
        z-index: 999;
    }

    .sbar_collapsed .sidebar-menu {
        transform: translateX(calc(-100% - 16px));
        margin-left: 0 !important;
    }

    .nav-btn {
        position: relative !important;
        left: auto !important;
        top: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
        z-index: 1000;
    }

    .nav-btn span,
    .sbar_collapsed .nav-btn span {
        background: #273c75 !important;
    }

    .header-area .row {
        min-height: 64px;
    }

    .main-content {
        width: 100%;
        flex-basis: auto;
    }

    .main-menu {
        padding-bottom: 24px;
    }
}

@media (max-width: 767.98px) {
    .header-area,
    .page-title-area,
    .main-content-inner {
        padding-left: 14px;
        padding-right: 14px;
    }

    .card-body {
        padding: 1rem;
    }

    .notify-box,
    .user-profile .dropdown-menu,
    .notification-area .dropdown-menu {
        max-width: calc(100vw - 24px);
    }

    .notification-area {
        gap: 8px 10px;
    }

    .user-profile {
        padding: 12px 14px;
        border-radius: 12px;
    }

    body .btn-back,
    body .btn-save-invoice,
    body .btn-save-purchase,
    body .btn-update-invoice,
    body .btn-sidebar-update {
        width: 100%;
        justify-content: center;
    }

    body .invoice-create-header h3,
    body .invoice-edit-header h3,
    body .purchase-create-header h3,
    body .purchase-edit-header h3 {
        width: 100%;
    }

    body .invoice-form-card,
    body .purchase-form-card,
    body .document-control-card,
    body .totals-section {
        border-radius: 14px;
    }

    body .invoice-form-card .product-table,
    body .invoice-form-card .items-table,
    body .purchase-form-card .product-table,
    body .purchase-form-card .items-table {
        min-width: 860px;
    }

    body .invoice-form-card td.product-cell,
    body .purchase-form-card td.product-cell {
        min-width: 280px !important;
    }

    body .invoice-form-card td.grade-cell,
    body .purchase-form-card td.grade-cell {
        min-width: 130px !important;
    }

    body .grade-select {
        min-width: 120px;
    }

    body .invoice-form-card .totals-row,
    body .purchase-form-card .total-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    body .invoice-form-card .totals-row input,
    body .purchase-form-card .total-row input {
        width: 100% !important;
        max-width: 100% !important;
        text-align: left !important;
        padding-left: 0;
    }

    body .form-submit-row {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    body .form-submit-hint {
        order: 2;
    }

    body textarea.form-control,
    body input.form-control,
    body select.form-control,
    body .modern-input,
    body .select2-container .select2-selection--single {
        font-size: 16px;
    }

    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        text-align: left !important;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100%;
        margin-left: 0;
        margin-top: 8px;
    }

    .dataTables_wrapper > .row > [class*="col-"] {
        margin-bottom: 10px;
    }

    .guest .container {
        padding-left: 12px;
        padding-right: 12px;
    }

    body #app .logo {
        max-width: 132px;
        margin-top: 0;
    }

    body .card-signin .card-body {
        padding: 1rem 1rem 1.25rem;
    }
}

@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0.5rem auto;
        max-width: calc(100vw - 1rem);
    }

    .notification-area {
        justify-content: flex-end;
    }

    .notify-title {
        padding: 14px 16px;
    }

    .nofity-list {
        padding: 8px 0;
    }

    .nofity-list a {
        padding: 0 12px 8px;
    }

    body .discount-input-group {
        grid-template-columns: 78px 1fr !important;
    }

    body .invoice-form-card {
        padding: 16px;
    }

    body .purchase-form-body {
        padding: 16px;
    }

    body .invoice-form-card .form-header,
    body .purchase-form-card .purchase-form-header {
        gap: 14px;
    }
}
