html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body,
main,
.page-shell,
.container,
.container-fluid {
    min-width: 0;
    max-width: 100%;
}

img,
video,
canvas,
svg {
    max-width: 100%;
}

.table-responsive,
.overflow-x-auto {
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

.row > [class*="col-"],
.flex > *,
.grid > * {
    min-width: 0;
}

input,
select,
textarea,
button {
    max-width: 100%;
}

@media (min-width: 769px) and (max-width: 1024px) {
    nav#main-sidebar,
    nav.sidebar-modern {
        --sidebar-width: 15rem;
        width: 15rem !important;
        max-width: 15rem !important;
    }

    body > main {
        padding-inline-start: 15rem !important;
    }

    .page-shell,
    .container,
    .container-fluid {
        padding-inline: 1rem;
    }

    .row {
        --bs-gutter-x: 1rem;
    }

    .table-responsive,
    .overflow-x-auto {
        overflow-x: auto !important;
    }
}

@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }

    body > main {
        width: 100% !important;
        max-width: 100% !important;
        margin-inline: 0 !important;
        padding-inline: 0.75rem !important;
        padding-bottom: max(6rem, env(safe-area-inset-bottom)) !important;
    }

    .page-shell,
    .container,
    .container-fluid {
        width: 100%;
        max-width: 100%;
        padding-inline: 0.75rem !important;
    }

    .row {
        --bs-gutter-x: 0.75rem;
    }

    .row > [class*="col-"] {
        margin-bottom: 0.75rem;
    }

    .table-responsive,
    .overflow-x-auto {
        overflow-x: auto !important;
        overflow-y: hidden;
        border-radius: 0.5rem;
    }

    table {
        width: max-content;
        min-width: 100%;
        max-width: none;
    }

    table thead {
        display: table-header-group;
    }

    table tbody {
        display: table-row-group;
    }

    table tr {
        display: table-row;
    }

    table th,
    table td {
        display: table-cell;
        white-space: normal;
        overflow-wrap: anywhere;
        vertical-align: middle;
    }

    table td::before {
        content: none !important;
    }

    .grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .flex.flex-wrap,
    .btn-group,
    .button-group {
        flex-wrap: wrap;
    }

    .card,
    .glass-card,
    .card-modern {
        max-width: 100%;
    }

    .modal-dialog {
        width: calc(100% - 1rem);
        max-width: none;
        margin: 0.5rem auto;
    }

    .modal-content {
        max-height: calc(100dvh - 1rem);
        overflow-y: auto;
    }

    .form-row,
    .form-inline {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 0.75rem;
    }

    .form-inline .form-control,
    .form-inline .form-select {
        width: 100%;
    }

    .dropdown-menu {
        max-width: calc(100vw - 1.5rem);
    }

    .quick-navigation-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #floating-sidebar-toggle,
    #floating-quick-navigation,
    #floating-fullscreen-toggle,
    #floating-theme-toggle,
    #floating-logout-toggle,
    #floating-language-switcher {
        transform: scale(0.88);
        transform-origin: bottom left;
    }

    [dir="ltr"] #floating-sidebar-toggle,
    [dir="ltr"] #floating-quick-navigation,
    [dir="ltr"] #floating-fullscreen-toggle,
    [dir="ltr"] #floating-theme-toggle,
    [dir="ltr"] #floating-logout-toggle,
    [dir="ltr"] #floating-language-switcher {
        transform-origin: bottom right;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: clamp(1.35rem, 6vw, 1.8rem);
        line-height: 1.25;
    }

    h2 {
        font-size: clamp(1.2rem, 5vw, 1.55rem);
        line-height: 1.3;
    }

    .page-shell,
    .container,
    .container-fluid {
        padding-inline: 0.5rem !important;
    }

    .card,
    .glass-card,
    .card-modern {
        padding: 0.875rem !important;
    }

    .btn,
    button,
    a.btn {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    input,
    select,
    textarea {
        min-width: 0;
        font-size: 16px !important;
    }

    .quick-navigation-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.6rem;
    }

    .quick-navigation-item {
        min-height: 4rem;
        flex-direction: row;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
