/**
 * Catalog search: mobile bar, fullscreen filter modal, responsive desktop form.
 */

.wp-schema-catalog-search {
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    min-width: 0;
}

.wp-schema-catalog-filters-layout {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
}

.wp-schema-catalog-search .wp-schema-applied-filters,
.wp-schema-catalog-search #result.result-filters-section,
.wp-schema-catalog-filters-layout .wp-schema-applied-filters,
.wp-schema-catalog-filters-layout #result {
    width: 100%;
    max-width: 100%;
    flex: 0 0 auto;
    min-width: 0;
}

/* Mobile bar + chips (hidden on desktop) */
.wp-schema-catalog-mobile-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
    width: 100%;
}

.wp-schema-refine-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
    color: #1a1a1a;
}

.wp-schema-open-filters-btn {
    flex-shrink: 0;
    white-space: nowrap;
}

.wp-schema-applied-filters {
    margin-bottom: 1rem;
    width: 100%;
}

/* Modal: keep out of page flow when closed */
.wp-schema-search-modal.modal {
    padding: 0 !important;
}

.wp-schema-search-modal.modal:not(.show) {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.wp-schema-search-modal.modal.show {
    display: block !important;
    visibility: visible !important;
}

.wp-schema-search-modal .modal-dialog {
    margin: 0 !important;
    max-width: none !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 100dvh;
    transform: none !important;
    position: relative;
}

.wp-schema-search-modal.show .modal-dialog {
    transform: none !important;
}

.wp-schema-search-modal-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
    overflow: hidden;
}

.wp-schema-search-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #d9dadb;
    background: #fff;
}

.wp-schema-modal-clear-filters,
.wp-schema-modal-close-btn {
    font-weight: 600;
    text-decoration: none;
    padding: 0.25rem 0;
    flex-shrink: 0;
}

.wp-schema-modal-close-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.wp-schema-modal-close-icon {
    font-size: 1.35rem;
    line-height: 1;
}

.wp-schema-search-modal-body {
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 1.25rem;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.wp-schema-search-modal-footer {
    flex: 0 0 auto;
    padding: 1rem 1.25rem;
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #d9dadb;
    background: #fff;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
}

/* Expanded filter sections in modal */
.wp-schema-filter-section {
    margin-bottom: 1.5rem;
}

.wp-schema-filter-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #5c6f82;
    margin: 0 0 0.75rem;
}

.wp-schema-filter-section-options {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.wp-schema-filter-option {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin: 0;
    font-size: 1rem;
    line-height: 1.35;
    cursor: pointer;
    max-width: 100%;
}

.wp-schema-filter-option .form-check-input {
    margin-top: 0.2rem;
    flex-shrink: 0;
}

.wp-schema-mobile-keyword-wrap {
    position: relative;
    max-width: 100%;
}

.wp-schema-mobile-search-icon {
    position: absolute;
    left: 0;
    bottom: 0.5rem;
    color: #5c6f82;
    pointer-events: none;
    display: flex;
    align-items: center;
}

.wp-schema-mobile-keyword-wrap .form-control {
    width: 100%;
    border: 0;
    border-bottom: 1px solid #5c6f82;
    border-radius: 0;
    padding-left: 1.75rem;
    padding-right: 0;
    background: transparent;
}

.wp-schema-mobile-keyword-wrap .form-control:focus {
    box-shadow: none;
    border-bottom-color: #0066cc;
}

.wp-schema-filter-empty {
    color: #5c6f82;
    font-size: 0.9rem;
}

/* Chips */
#result.wp-schema-applied-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

#result .chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.75rem;
    border: 2px solid #0066cc;
    border-radius: 200px;
    background: #fff;
    color: #0066cc;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25;
    max-width: min(100%, 22rem);
    min-width: 0;
    box-sizing: border-box;
    cursor: default;
    overflow: hidden;
}

#result .chip-label {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1 1 auto;
    color: #0066cc;
}

#result .chip:hover .chip-label,
#result .chip:focus-within .chip-label {
    color: #fff !important;
}

#result .chip:hover,
#result .chip:focus-within {
    background-color: #0066cc !important;
    border-color: #0066cc !important;
    color: #fff !important;
}

#result .chip .close-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
    min-width: 1.25rem;
    min-height: 1.25rem;
    cursor: pointer;
    font-weight: 700;
    font-size: 1.125rem;
    line-height: 1;
    border: 0;
    background: none;
    color: inherit;
}

#result .chip:hover .close-button,
#result .chip:focus-within .close-button {
    color: #fff !important;
}

#result .chip .close-button:hover,
#result .chip .close-button:focus {
    color: #fff !important;
}

#result .reset-filters,
.wp-schema-clear-filters-link {
    margin: 0;
    padding: 0;
    color: #0066cc;
    font-weight: 600;
    text-decoration: underline;
    background: none;
    border: 0;
    cursor: pointer;
    font-size: 0.95rem;
}

#result .reset-filters:hover,
.wp-schema-clear-filters-link:hover {
    color: #004d99;
}

/* Mobile catalog UX */
@media (max-width: 989.98px) {
    .wp-schema-catalog-filters-layout #result.result-filters-section,
    .wp-schema-catalog-filters-layout .wp-schema-applied-filters {
        order: 1;
        margin-top: 0;
        margin-bottom: 0.75rem;
    }

    #result .chip {
        max-width: 100%;
    }

    .wp-schema-catalog-mobile-bar {
        display: flex;
    }

    #search-form-box .wp-schema-search-desktop {
        display: none !important;
        visibility: hidden !important;
        position: absolute !important;
        width: 1px !important;
        height: 1px !important;
        overflow: hidden !important;
        clip: rect(0, 0, 0, 0) !important;
        white-space: nowrap !important;
        border: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .wp-schema-columns-picker {
        display: none !important;
    }

    .wp-schema-results-toolbar .results-count {
        flex: 1 1 auto;
        max-width: 100%;
    }

    /* Fullscreen modal — escape Oxygen/transformed ancestors when teleported to body */
    .wp-schema-search-modal.modal.show {
        position: fixed !important;
        inset: 0 !important;
        z-index: 1055 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100% !important;
        overflow: hidden !important;
    }

    .wp-schema-search-modal.show .modal-dialog {
        position: fixed !important;
        inset: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        min-height: 100dvh !important;
        transform: none !important;
    }

    .wp-schema-search-modal.show .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        left: 0 !important;
        right: 0 !important;
    }
}

@media (min-width: 990px) {
    .wp-schema-search-modal {
        display: none !important;
    }

    /* Override Oxygen/flex parents: chips above, filter bar full width below */
    #search-form-box.wp-schema-catalog-search,
    .wp-schema-catalog-search {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
    }

    #search-form-box .wp-schema-applied-filters,
    .wp-schema-catalog-search .wp-schema-applied-filters,
    .wp-schema-catalog-search #result.result-filters-section {
        order: 2;
        margin-top: 0.75rem;
        margin-bottom: 1rem;
        width: 100% !important;
        max-width: 100% !important;
    }

    .wp-schema-catalog-search .wp-schema-search-desktop {
        order: 1;
    }

    .wp-schema-catalog-search .wp-schema-search-desktop {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: flex-end !important;
        gap: 1rem !important;
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 auto !important;
    }

    .wp-schema-catalog-search .wp-schema-search-desktop > .cnd-src-col {
        flex: 1 1 180px;
        min-width: 160px;
        max-width: 100%;
        display: flex;
        flex-direction: column;
        gap: 0.35rem;
    }

    .wp-schema-catalog-search .wp-schema-search-desktop > .cnd-src-col-lts {
        flex: 0 0 auto;
        min-width: 6rem;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
    }

    .wp-schema-catalog-search .SearchSelTitle {
        display: block;
        font-weight: 600;
        font-size: 0.95rem;
        line-height: 1.3;
        color: #1a1a1a;
        white-space: normal;
    }

    .wp-schema-catalog-search .SearchByText,
    .wp-schema-catalog-search .select-container {
        width: 100%;
    }

    .wp-schema-catalog-search .select-box {
        display: block;
        width: 100%;
        min-height: 2.5rem;
        padding: 0.5rem 2rem 0.5rem 0.75rem;
        border: 1px solid #d9dadb;
        border-radius: 4px;
        background: #fff;
        cursor: pointer;
        text-align: left;
        line-height: 1.35;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        box-sizing: border-box;
    }

    .wp-schema-catalog-search .SearchByText .form-control {
        width: 100%;
        box-sizing: border-box;
    }

    .wp-schema-catalog-search .wp-schema-search-desktop .checkbox-container {
        left: 0;
        right: 0;
        width: 100%;
        min-width: 100%;
    }
}

body.wp-schema-modal-open {
    overflow: hidden;
}
