:root {
    --app-page-gap: clamp(0.75rem, 2vw, 1.5rem);
    --app-radius: 0.75rem;
    --app-border: #dee2e6;
    --app-surface: #ffffff;
}

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

body {
    min-width: 0;
    overflow-x: hidden;
}

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

.container,
.container-fluid {
    min-width: 0;
}

.card,
.card-body,
.row > * {
    min-width: 0;
}

.table-responsive {
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

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

.table-responsive > .order-entry-table {
    min-width: 1180px !important;
}

.table th,
.table td {
    vertical-align: middle;
}

.table code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.form-control,
.form-select,
.btn {
    max-width: 100%;
}

.modal-content {
    border: 0;
    border-radius: var(--app-radius);
}

.dashboard-toolbar {
    gap: 0.75rem;
    flex-wrap: wrap;
}

.dashboard-toolbar .dashboard-search {
    flex: 1 1 16rem;
    max-width: 26rem;
}

.dashboard-toolbar .dashboard-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.user-filter-form .form-label {
    margin-bottom: 0.25rem;
    font-size: 0.8125rem;
    font-weight: 600;
}

.user-table-scroll {
    position: relative;
    max-height: calc(100vh - 21rem);
    min-height: 18rem;
    overflow: auto;
}

.user-table {
    min-width: 1050px;
}

.user-table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    color: #fff;
    background-color: #212529;
    box-shadow: inset 0 -2px 0 rgba(255, 255, 255, 0.15);
    white-space: nowrap;
}

.user-table tbody td {
    background-clip: padding-box;
}

.user-table-scroll:focus-visible {
    outline: 3px solid rgba(13, 110, 253, 0.35);
    outline-offset: 2px;
}

@media (min-width: 768px) {
    body.user-management-page {
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    .user-management-shell {
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    .user-management-shell .user-table-scroll {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
    }
}

.sidebar .text-muted {
    color: #adb5bd !important;
}

@media (max-width: 991.98px) {
    .container,
    .container-fluid {
        padding-left: var(--app-page-gap);
        padding-right: var(--app-page-gap);
    }

    .table-responsive > .table {
        min-width: 760px;
    }

    .table-permission {
        min-width: 1320px;
    }

    .sidebar {
        min-height: auto !important;
        border-radius: 0 0 var(--app-radius) var(--app-radius);
    }

    .sidebar .summary-box {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 1rem;
    }

    .sidebar .summary-box h6,
    .sidebar .summary-box small {
        grid-column: 1 / -1;
    }
}

@media (min-width: 992px) {
    .sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        overflow-y: auto;
    }
}

@media (max-width: 767.98px) {
    .user-table-scroll {
        max-height: 60vh;
    }

    body {
        font-size: 0.9375rem;
    }

    h1,
    .h1 {
        font-size: clamp(1.65rem, 8vw, 2rem);
    }

    h2,
    .h2 {
        font-size: clamp(1.4rem, 7vw, 1.75rem);
    }

    h3,
    h4,
    .h3,
    .h4 {
        font-size: clamp(1.2rem, 6vw, 1.5rem);
    }

    .container,
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .container > .d-flex:first-child,
    .container-fluid > .d-flex:first-child {
        align-items: stretch !important;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .container > .d-flex:first-child > .d-flex,
    .container-fluid > .d-flex:first-child > .d-flex {
        flex-wrap: wrap;
    }

    .card-body {
        padding: 1rem;
    }

    .table-responsive {
        width: 100%;
    }

    table.table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive table.table {
        display: table;
        overflow: visible;
    }

    .table-responsive > .table {
        min-width: 720px;
    }

    .form-control,
    .form-select {
        min-height: 44px;
        font-size: 1rem;
    }

    .btn {
        min-height: 42px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    form.d-flex {
        flex-wrap: wrap;
    }

    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-body,
    .modal-content.p-4 {
        padding: 1rem !important;
    }

    .summary-item {
        gap: 0.75rem;
    }

    .dashboard-toolbar .dashboard-search {
        flex-basis: 100%;
        max-width: none !important;
    }

    .dashboard-toolbar .dashboard-actions {
        width: 100%;
    }

    .dashboard-toolbar .dashboard-actions .btn {
        flex: 1 1 8rem;
    }

    .sticky-order {
        bottom: 0;
        padding-bottom: calc(0.65rem + env(safe-area-inset-bottom));
    }

    .dashboard-main {
        padding-bottom: calc(4.75rem + env(safe-area-inset-bottom)) !important;
    }

    .login-card {
        margin: 0.75rem;
        border-radius: var(--app-radius);
    }

    .login-card .right {
        padding: clamp(1.25rem, 7vw, 2rem);
    }

    .login-card .logo {
        width: min(12rem, 70vw);
        margin-bottom: 1.5rem;
    }
}

@media (max-width: 575.98px) {
    body.p-3,
    body.p-4 {
        padding: 0.75rem !important;
    }

    .py-4 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    .d-flex.gap-2 {
        flex-wrap: wrap;
    }

    .sidebar .summary-box {
        grid-template-columns: 1fr;
    }

    .sidebar .summary-box h6,
    .sidebar .summary-box small {
        grid-column: auto;
    }

    .table-responsive > .table {
        min-width: 680px;
    }

    .table-permission {
        min-width: 1200px;
    }

    .modal-dialog {
        width: auto;
        max-width: none;
    }
}

@media (hover: none) and (pointer: coarse) {
    button,
    .btn,
    input,
    select,
    textarea {
        touch-action: manipulation;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
