/*
 * BR IMS responsive foundation
 * Shared by authenticated and standalone pages.
 */

:root {
    --app-page-gutter: clamp(0.75rem, 2.4vw, 1.5rem);
    --app-touch-target: 44px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

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

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

canvas {
    max-width: 100% !important;
}

.app-navbar-inner {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 1rem;
    width: 100%;
    min-width: 0;
    padding-inline: var(--app-page-gutter);
}

.app-navbar-inner .navbar-brand {
    grid-column: 2;
    position: static !important;
    min-width: 0;
    max-width: min(62vw, 760px);
    margin: 0 !important;
    padding: 0.5rem;
    overflow: hidden;
    color: #fff;
    font-size: clamp(1rem, 2.4vw, 1.5rem) !important;
    line-height: 1.2;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    transform: none !important;
}

.app-navbar-actions {
    grid-column: 3;
    justify-self: end;
    min-width: 0;
}

.app-navbar-actions .dropdown-menu {
    max-width: calc(100vw - 1rem);
}

.app-page-container {
    width: min(100%, 1320px);
    min-width: 0;
    margin-inline: auto;
    padding-inline: var(--app-page-gutter);
    padding-bottom: 2rem;
}

.app-page-container--wide {
    width: min(100%, 1600px);
}

.app-page-container > *,
.container,
.container-fluid,
.row,
.row > *,
.card,
.card-body,
.main-content,
.content,
.content-wrapper,
.modal-content,
form,
fieldset {
    min-width: 0;
}

.container,
.container-sm,
.container-md,
.container-lg,
.container-xl,
.container-xxl {
    width: 100%;
    padding-right: var(--app-page-gutter);
    padding-left: var(--app-page-gutter);
}

.card,
.alert,
.modal-content,
.dropdown-menu {
    overflow-wrap: anywhere;
}

.card-header,
.card-footer,
.btn-container,
.button-group,
.action-buttons,
.actions,
.form-actions,
.filter-actions,
.page-actions {
    gap: 0.5rem;
}

.btn-container,
.button-group,
.action-buttons,
.actions,
.form-actions,
.filter-actions,
.page-actions,
.btn-toolbar,
.card-header {
    flex-wrap: wrap;
}

.form-control,
.form-select,
input,
select,
textarea,
button {
    max-width: 100%;
}

textarea {
    resize: vertical;
}

.input-group {
    flex-wrap: nowrap;
    min-width: 0;
}

.input-group > .form-control,
.input-group > .form-select {
    min-width: 0;
}

.table-responsive,
.responsive-table-shell {
    width: 100%;
    max-width: 100%;
    margin: 1rem 0 !important;
    padding: 0 !important;
    overflow-x: auto;
    overflow-y: hidden;
    border-radius: 0.5rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

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

.table-responsive .dt-container,
.table-responsive .dataTables_wrapper,
.responsive-table-shell .dt-container,
.responsive-table-shell .dataTables_wrapper {
    min-width: 0;
}

.dt-container,
.dataTables_wrapper,
.dt-layout-row,
.dt-layout-cell {
    max-width: 100%;
    min-width: 0;
}

.dt-container .dt-search input,
.dataTables_wrapper .dataTables_filter input {
    max-width: 100%;
}

.pagination {
    flex-wrap: wrap;
}

.modal-dialog {
    max-width: min(var(--bs-modal-width, 720px), calc(100vw - 1rem));
    margin-inline: auto;
}

.toast,
.toast-container {
    max-width: calc(100vw - 1.5rem);
}

.dashboard-mobile-toggle {
    display: none;
}

@media screen and (max-width: 991.98px) {
    .dashboard-container {
        display: block !important;
        width: 100% !important;
        min-width: 0;
    }

    .dashboard-container .dashboard-mobile-toggle {
        display: flex;
        position: sticky;
        top: 0.5rem;
        z-index: 1040;
        align-items: center;
        justify-content: space-between;
        width: calc(100% - 1rem);
        min-height: var(--app-touch-target);
        margin: 0.5rem;
        padding: 0.65rem 0.9rem;
        border: 0;
        border-radius: 0.5rem;
        background: #212529;
        color: #fff;
        font-weight: 600;
        box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.18);
    }

    .dashboard-container > .sidebar {
        position: relative !important;
        inset: auto !important;
        width: 100% !important;
        height: auto !important;
        max-height: 0;
        margin: 0 !important;
        padding: 0 1rem !important;
        overflow: hidden !important;
        transition: max-height 0.25s ease, padding 0.25s ease;
    }

    .dashboard-container.mobile-sidebar-open > .sidebar {
        max-height: 75vh;
        padding-block: 1rem !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;
    }

    .dashboard-container > .main-content,
    .dashboard-container > main,
    .dashboard-container > .content {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        padding: var(--app-page-gutter) !important;
    }

    .dashboard-container .sidebar-menu a {
        min-height: var(--app-touch-target);
    }

    .dt-container .dt-layout-row,
    .dataTables_wrapper .row {
        display: flex;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .dt-container .dt-layout-cell,
    .dataTables_wrapper .row > * {
        width: 100%;
        max-width: 100%;
    }

    .dt-container .dt-search,
    .dt-container .dt-length,
    .dt-container .dt-info,
    .dt-container .dt-paging,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        width: 100%;
        justify-content: flex-start !important;
        text-align: left !important;
    }

    .dt-container .dt-search input,
    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        margin: 0 !important;
    }
}

@media screen and (max-width: 767.98px) {
    :root {
        --app-page-gutter: 0.75rem;
    }

    body {
        font-size: 0.9375rem;
    }

    h1 {
        font-size: clamp(1.45rem, 7vw, 2rem);
    }

    h2 {
        font-size: clamp(1.25rem, 6vw, 1.7rem);
    }

    h3 {
        font-size: clamp(1.1rem, 5vw, 1.4rem);
    }

    .navbar {
        min-height: 60px;
        padding-block: 0.35rem !important;
    }

    .app-navbar-inner {
        grid-template-columns: minmax(var(--app-touch-target), 1fr) minmax(0, auto) minmax(var(--app-touch-target), 1fr);
        gap: 0.35rem;
    }

    .app-navbar-inner .navbar-brand {
        grid-column: 2;
        justify-self: center;
        max-width: calc(100vw - 120px);
        padding-inline: 0.25rem;
        text-align: center;
        letter-spacing: 0.06em !important;
    }

    .app-navbar-actions {
        grid-column: 3;
        justify-self: end;
    }

    .app-navbar-actions .profile-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }

    .app-navbar-actions .nav-link {
        display: flex !important;
        align-items: center;
        justify-content: center;
        min-width: var(--app-touch-target);
        min-height: var(--app-touch-target);
        padding: 0.5rem !important;
    }

    .app-navbar-actions .profile-icon {
        margin: 0;
        font-size: 1.35rem;
    }

    .app-navbar-actions .dropdown-menu {
        position: fixed !important;
        top: 58px !important;
        right: 0.5rem !important;
        left: auto !important;
        width: min(320px, calc(100vw - 1rem));
        transform: none !important;
    }

    .app-page-container {
        margin-top: 1rem !important;
    }

    .container,
    .container-fluid,
    .card-body,
    .card-header,
    .card-footer {
        padding-right: var(--app-page-gutter) !important;
        padding-left: var(--app-page-gutter) !important;
    }

    .row {
        margin-right: calc(-0.5 * var(--app-page-gutter));
        margin-left: calc(-0.5 * var(--app-page-gutter));
    }

    .row > * {
        padding-right: calc(0.5 * var(--app-page-gutter));
        padding-left: calc(0.5 * var(--app-page-gutter));
    }

    .form-control,
    .form-select,
    input:not([type="checkbox"]):not([type="radio"]),
    select,
    textarea {
        min-height: var(--app-touch-target);
        font-size: 16px !important;
    }

    textarea {
        min-height: 96px;
    }

    .btn,
    button,
    [role="button"] {
        min-height: var(--app-touch-target);
    }

    .btn-sm {
        min-height: 40px;
        padding: 0.45rem 0.7rem;
    }

    .btn-container,
    .button-group,
    .action-buttons,
    .actions,
    .form-actions,
    .filter-actions,
    .page-actions {
        display: flex;
        width: 100%;
    }

    .btn-container > .btn,
    .button-group > .btn,
    .action-buttons > .btn,
    .actions > .btn,
    .form-actions > .btn,
    .filter-actions > .btn,
    .page-actions > .btn {
        flex: 1 1 10rem;
        margin: 0 !important;
    }

    .table-responsive,
    .responsive-table-shell {
        margin: 0.75rem 0 !important;
        border: 1px solid #dee2e6;
        box-shadow: none !important;
    }

    table:not(.no-responsive-table) {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive table,
    .responsive-table-shell table,
    table.wide-table {
        width: max-content !important;
        min-width: 100%;
    }

    th,
    td,
    .table th,
    .table td {
        padding: 0.65rem !important;
    }

    .modal-dialog {
        width: calc(100vw - 1rem);
        margin: 0.5rem;
    }

    .modal-body {
        max-height: calc(100vh - 10rem);
        overflow-y: auto;
    }

    .nav-tabs,
    .nav-pills {
        flex-wrap: nowrap;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
    }

    .nav-tabs .nav-link,
    .nav-pills .nav-link {
        min-height: var(--app-touch-target);
    }

    .toast {
        right: 0.75rem !important;
        bottom: 0.75rem !important;
        left: 0.75rem !important;
        width: auto !important;
        min-width: 0 !important;
    }
}

@media screen and (max-width: 479.98px) {
    .app-navbar-inner .navbar-brand {
        max-width: calc(100vw - 120px);
        font-size: 0.95rem !important;
    }

    .card {
        border-radius: 0.5rem;
    }

    .card-body {
        padding-block: 0.85rem !important;
    }

    .btn:not(.btn-sm) {
        padding-right: 0.85rem;
        padding-left: 0.85rem;
    }

    .user-info-item {
        align-items: flex-start;
        gap: 0.5rem;
    }

    .user-info-value {
        max-width: 60%;
        overflow-wrap: anywhere;
    }
}

@media print {
    html,
    body {
        overflow: visible !important;
    }

    .responsive-table-shell,
    .table-responsive {
        overflow: visible !important;
        border: 0 !important;
        box-shadow: none !important;
    }

    .dashboard-mobile-toggle {
        display: none !important;
    }
}
