/* Mobile form fields */
@media (max-width: 575.98px) {
    .form-control-wrapper.row > .col-sm-3,
    .form-control-wrapper.row > .col-sm-9,
    form .row > .col-sm-3,
    form .row > .col-sm-9,
    .container-fluid .col-sm-3,
    .container-fluid .col-sm-9 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        -ms-flex: 0 0 100% !important;
    }

    .form-control-wrapper .col-form-label,
    form label.col-form-label,
    .container-fluid label.col-form-label {
        text-align: left !important;
        padding-top: 0;
        padding-bottom: 0.25rem;
    }
}

/* Tablet and mobile page width */
@media (max-width: 991.98px) {
    #page-wrapper {
        max-width: 100%;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

/* Mobile header */
@media (max-width: 767.98px) {
    #header {
        height: auto !important;
        padding-bottom: 0.5rem;
    }

    #header .banner {
        padding-top: 0.5rem;
    }

    #header .site-logo img {
        height: 72px !important;
        width: auto !important;
    }

    body.topMenu,
    body.admin {
        padding-top: 0;
    }
}

/* Mobile images */
@media (max-width: 767.98px) {
    .card-img-top {
        height: auto;
        aspect-ratio: 16 / 9;
        object-fit: cover;
        width: 100%;
    }
}

/* Mobile dropdowns */
@media (max-width: 575.98px) {
    .dropdown-menu-xl {
        min-width: 95vw;
    }
}

/* Mobile admin layout */
@media (max-width: 767.98px) {
    .left_col {
        width: 0;
        max-width: 0;
        overflow: hidden;
    }

    .right_col_wrapper {
        margin-left: 0;
    }

    .right_col {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* Mobile modals */
@media (max-width: 575.98px) {
    .modal .modal-dialog-aside {
        width: 100%;
        max-width: 100%;
    }

    .modal-xl,
    .modal-wide {
        margin: 0;
    }

    #modalBar #modal-window-url {
        width: 100%;
        word-break: break-all;
    }
}

/* Mobile footer */
@media (max-width: 575.98px) {
    .footer-container {
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.35rem;
        width: 100%;
        text-align: center;
    }

    .footer-copyright,
    .footer-disclaimer {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        text-align: center !important;
        margin: 0 !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
        word-break: normal;
    }

    body:not(.admin):not(.externalForm):not(.external-form) {
        padding-bottom: 120px;
    }

    body:not(.admin):not(.externalForm):not(.external-form) > .footer,
    body:not(.admin):not(.externalForm):not(.external-form) #footer {
        position: relative;
        height: auto;
    }
}

/* Mobile layout for public external forms */
@media (max-width: 575.98px) {
    body.externalForm,
    body.external-form {
        padding-bottom: 0 !important;
        overflow-x: hidden;
    }

    body.externalForm #page-wrapper,
    body.externalForm .container-fluid,
    body.externalForm #dynamic-form-wrapper,
    body.externalForm #form-header,
    body.externalForm form,
    body.externalForm .nested-1,
    body.externalForm .card,
    body.external-form #page-wrapper,
    body.external-form .container-fluid,
    body.external-form #dynamic-form-wrapper,
    body.external-form #form-header,
    body.external-form form,
    body.external-form .nested-1,
    body.external-form .card {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    body.externalForm .right_col,
    body.externalForm .container-fluid,
    body.externalForm .card-body,
    body.external-form .right_col,
    body.external-form .container-fluid,
    body.external-form .card-body {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    body.externalForm .card,
    body.external-form .card {
        box-shadow: none !important;
    }

    body.externalForm #footer,
    body.externalForm .footer,
    body.external-form #footer,
    body.external-form .footer {
        position: relative !important;
        height: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden;
    }

    body.externalForm #footer .footer-container,
    body.external-form #footer .footer-container {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.4rem;
        width: 100%;
        text-align: center;
    }

    body.externalForm #footer .footer-copyright,
    body.externalForm #footer .footer-disclaimer,
    body.external-form #footer .footer-copyright,
    body.external-form #footer .footer-disclaimer {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        text-align: center !important;
        margin: 0 !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
        word-break: normal;
        font-size: 0.75rem;
    }
}

/* Mobile search result header */
@media (max-width: 767.98px) {
    .search-result-container .page-title {
        position: relative;
    }

    .search-result-container .page-title .d-flex.justify-content-end {
        position: absolute;
        top: 0;
        right: 0;
        z-index: 2;
    }

    .search-result-container .page-title .row.align-items-center {
        padding-right: 90px;
        min-height: 60px;
        margin-top: 0;
    }

    .search-result-container .page-title .row.align-items-center .col-md-2 {
        flex: 0 0 auto;
        width: auto;
        max-width: none;
        padding-right: 0.5rem;
    }

    .search-result-container .page-title .row.align-items-center .col-md-10 {
        flex: 1 1 auto;
        width: auto;
        max-width: none;
    }

    .search-result-container .page-title .row.align-items-center .fa-stack {
        font-size: 1.5em;
    }

    .search-result-container {
        border-bottom: 1px solid #dee2e6;
        padding-bottom: 1rem;
        margin-bottom: 0.5rem;
    }
}

/* Mobile controls */
@media (max-width: 767.98px) {
    .form-control,
    .form-select,
    .btn {
        font-size: 16px;
        min-height: 44px;
    }

    .card-container-button-bar .btn,
    div.button-bar input[type="submit"],
    div.button-bar-2 input[type="submit"] {
        width: 100%;
        margin: 0.25rem 0;
    }
}

/* Mobile tables */
@media (max-width: 767.98px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Mobile card headers */
@media (max-width: 575.98px) {
    .card-header.h5 {
        white-space: normal;
        word-break: break-word;
    }
}

/* Mobile accessibility button */
@media (max-width: 575.98px) {
    #a11y-fab {
        bottom: 130px;
    }
}

/* Mobile card spacing */
@media (max-width: 575.98px) {
    .cardStyle {
        margin-top: 15% !important;
    }
}

/* Mobile typography */
@media (max-width: 575.98px) {
    h2.py-3 {
        font-size: 1.4rem;
    }

    .card-title {
        font-size: 1.1rem;
    }
}

/* Mobile subform tables */
@media (max-width: 767.98px) {
    table.subform-container {
        display: block;
        border: 0;
        width: 100%;
    }

    table.subform-container thead,
    table.subform-container tbody,
    table.subform-container tr,
    table.subform-container td,
    table.subform-container th {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    table.subform-container tr.sf-tbl-header-container {
        background: transparent;
        border: 0;
        padding: 0;
    }

    table.subform-container tr.sf-tbl-header-container th {
        display: none;
    }

    table.subform-container tr.sf-tbl-header-container th.add-row {
        display: block;
        text-align: center;
        padding: 0.75rem 0;
        background: transparent;
        border: 0;
    }

    table.subform-container tr.sf-tbl-header-container th.add-row .add-row-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: auto;
        min-width: 160px;
        padding: 0.5rem 1rem;
    }

    table.subform-container tr.sf-tbl-header-container th.add-row .add-row-btn::after {
        content: " Add Entry";
        margin-left: 0.5rem;
        font-weight: 500;
    }

    table.subform-container tr.sf-tbl-container {
        display: block;
        background: #fff;
        border: 1px solid #dee2e6;
        border-radius: 6px;
        margin-bottom: 1rem;
        padding: 0.75rem 3rem 0.75rem 0.75rem;
        position: relative;
    }

    table.subform-container tr.sf-tbl-container.has-data {
        border-left: 4px solid #0d6efd;
    }

    table.subform-container tr.sf-tbl-container td {
        border: 0;
        padding: 0.4rem 0;
        text-align: left;
    }

    table.subform-container tr.sf-tbl-container td.delete-row {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
        width: 36px;
        height: 36px;
        padding: 0;
        background: transparent;
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    table.subform-container tr.sf-tbl-container td.delete-row .delete-row-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        min-height: 36px;
        padding: 0;
        margin: 0 !important;
        line-height: 1;
        font-size: 14px;
    }

    table.subform-container tr.sf-tbl-container td.delete-row .delete-row-btn svg {
        width: 16px;
        height: 16px;
    }

    table.subform-container tr.sf-tbl-container td.cellDisabled {
        display: none;
    }

    table.subform-container tr.sf-tbl-container td:not(.delete-row)::before {
        content: attr(data-label);
        display: block;
        font-weight: 600;
        font-size: 0.85rem;
        color: #495057;
        margin-bottom: 0.25rem;
        text-transform: none;
    }

    table.subform-container tr.sf-tbl-container td .form-control,
    table.subform-container tr.sf-tbl-container td .form-select,
    table.subform-container tr.sf-tbl-container td .input-group {
        width: 100%;
        max-width: 100%;
    }

    table.subform-container tr.sf-tbl-container td .input-group {
        flex-wrap: nowrap;
    }
}
