.tdb-catalog-toolbar,
.tdb-catalog-field-panel,
.tdb-catalog-sort-options,
.tdb-catalog-dialog:not([open]) {
    display: none;
}

.tdb-catalog-result-status {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

@media (max-width: 767px) {
    /* Keep the theme's clipping without making the layout a scroll container. */
    body:has(.tdb-catalog-toolbar-ready),
    body.dokan-store:has(.tdb-catalog-toolbar-ready) {
        overflow-x: clip !important;
    }

    #layout:has(.tdb-catalog-toolbar-ready),
    .tdbo.tdb-catalog-toolbar-ready .tdbo-shell {
        overflow: clip;
    }

    .tc9.tdb-catalog-toolbar-ready .tc9-open,
    .tc9.tdb-catalog-toolbar-ready .tc9-fab,
    .tc9.tdb-catalog-toolbar-ready .tc9-layout > .tc9-filter,
    .t8.tdb-catalog-toolbar-ready .t8-open,
    .t8.tdb-catalog-toolbar-ready .t8-fab,
    .t8.tdb-catalog-toolbar-ready .t8-layout > .t8-filter,
    .tdb-catalog-toolbar-ready .tdb-catalog-legacy-filter {
        display: none !important;
    }

    .tc9.tdb-catalog-toolbar-ready .tc9-phead,
    .t8.tdb-catalog-toolbar-ready .t8-phead {
        position: relative;
        z-index: auto;
        grid-template-columns: minmax(0, 1fr);
        margin-bottom: 8px;
    }

    .tdb-catalog-toolbar {
        position: sticky;
        top: var(--tdb-catalog-header-bottom, 0px);
        z-index: 20;
        display: grid;
        gap: 8px;
        margin: 0 0 12px;
        padding: 8px;
        border: 1px solid #e4e6ea;
        border-radius: 12px;
        background: #fff;
        direction: rtl;
    }

    .tdb-catalog-actions,
    .tdb-catalog-footer-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .tdb-catalog-actions:has(> :only-child) {
        grid-template-columns: 1fr;
    }

    .tdb-catalog-shortcuts,
    .tdb-catalog-chips {
        display: flex;
        gap: 6px;
    }

    .tdb-catalog-chips {
        flex-wrap: wrap;
        max-height: min(25vh, 120px);
        margin: 0;
        padding: 8px 0 0;
        overflow-y: auto;
        border-top: 1px solid #e4e6ea;
        list-style: none;
    }

    .tdb-catalog-toolbar button,
    .tdb-catalog-dialog button.tdb-catalog-dismiss,
    .tdb-catalog-dialog-footer button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 5px;
        min-height: 44px;
        min-width: 44px;
        padding: 4px 8px;
        border: 1px solid #dadde3;
        border-radius: 12px;
        background: #fff;
        color: #171717;
        font: inherit;
        font-size: 13px;
        font-weight: 700;
        cursor: pointer;
    }

    .tdb-catalog-shortcuts button {
        flex: 1 1 auto;
        min-width: 0;
        padding-inline: 6px;
        line-height: 1.4;
        white-space: normal;
    }

    .tdb-catalog-toolbar svg,
    .tdb-catalog-dialog-header svg {
        width: 18px;
        height: 18px;
        flex: none;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .tdb-catalog-toolbar .tdb-catalog-filter-button,
    .tdb-catalog-dialog-footer .tdb-catalog-apply-button {
        border-color: #ffc400;
        background: #ffc400;
    }

    .tdb-catalog-toolbar button.is-active:not(.tdb-catalog-filter-button),
    .tdb-catalog-toolbar button[aria-pressed="true"],
    .tdb-catalog-toolbar .tdb-catalog-chip {
        border-color: #b86a00;
        background: #fff3d6;
    }

    .tdb-catalog-chip {
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    .tdb-catalog-badge {
        min-width: 21px;
        padding: 0 4px;
        border-radius: 20px;
        background: #171717;
        color: #fff;
        font-size: 12px;
        font-variant-numeric: tabular-nums;
        text-align: center;
    }

    .tdb-catalog-toolbar [hidden],
    .tdb-catalog-dialog [hidden] {
        display: none !important;
    }

    html:has(.tdb-catalog-dialog[open]) {
        overflow: hidden;
    }

    .tdb-catalog-toolbar-ready .tdb-catalog-dialog[open] {
        position: fixed;
        inset: auto 0 0;
        display: flex;
        flex-direction: column;
        width: 100%;
        max-width: none;
        max-height: 90vh;
        max-height: 90dvh;
        margin: 0;
        padding: 0;
        overflow: hidden;
        border: 0;
        border-radius: 16px 16px 0 0;
        background: #fff;
        color: #171717;
        direction: rtl;
    }

    .tdb-catalog-dialog::backdrop {
        background: rgb(10 17 28 / 55%);
    }

    .tdb-catalog-dialog-header {
        display: flex;
        flex: none;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        padding: 8px 16px;
        border-bottom: 1px solid #e4e6ea;
    }

    .tdb-catalog-dialog-header h3 {
        margin: 0;
        color: #171717;
        font-size: 16px;
        text-wrap: balance;
    }

    .tdb-catalog-dialog-content {
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .tdb-catalog-toolbar-ready .tdb-catalog-dialog .tdb-catalog-filter-panel {
        position: static !important;
        max-height: none !important;
        padding: 12px 16px 0;
        overflow: visible;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        transform: none;
        transition: none;
    }

    .tdb-catalog-dialog .tdb-catalog-field-panel {
        display: block;
    }

    .tdb-catalog-dialog .tc9-ftitle,
    .tdb-catalog-dialog .tc9-filter-actions,
    .tdb-catalog-dialog .t8-ftitle,
    .tdb-catalog-dialog .t8-filter-actions,
    .tdb-catalog-dialog .tdb-catalog-group-hidden {
        display: none !important;
    }

    .tdb-catalog-dialog :is(.tc9-group, .t8-group, .tdb-catalog-field) {
        background: #fff;
    }

    .tdb-catalog-dialog .tdb-catalog-field {
        margin-bottom: 12px;
        padding: 12px;
        border: 1px solid #e4e6ea;
        border-radius: 12px;
    }

    .tdb-catalog-dialog .tdb-catalog-field h3 {
        margin: 0 0 8px;
        font-size: 14px;
    }

    .tdb-catalog-dialog .tdb-catalog-field :is(input:not([type="radio"]), select) {
        box-sizing: border-box;
        width: 100%;
        min-height: 44px;
        padding-inline: 8px;
        border: 1px solid #dadde3;
        border-radius: 8px;
        font-size: 16px;
    }

    .tdb-catalog-dialog .tdb-catalog-field :is(input, select) + input {
        margin-block-start: 8px;
    }

    .tdb-catalog-dialog .tdb-catalog-sort-options + [data-sort],
    .tdb-catalog-dialog[data-mode="sort"] .tdb-catalog-sort-group > h3 {
        display: none;
    }

    .tdb-catalog-dialog[data-mode="sort"] .tdb-catalog-sort-group {
        margin-bottom: 12px;
        padding: 0;
        border: 0;
        box-shadow: none;
    }

    .tdb-catalog-dialog .tdb-catalog-sort-options {
        display: grid;
        min-width: 0;
        margin: 0;
        padding: 0;
        overflow: hidden;
        border: 1px solid #e4e6ea;
        border-radius: 12px;
    }

    .tdb-catalog-dialog .tdb-catalog-sort-options:has(> label:nth-child(9)) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tdb-catalog-sort-options:has(> label:nth-child(9)) label:nth-child(even) {
        border-inline-start: 1px solid #e4e6ea;
    }

    .tdb-catalog-sort-options label {
        display: flex;
        align-items: center;
        gap: 10px;
        min-height: 44px;
        margin: 0;
        padding: 6px 12px;
        color: #171717;
        font-size: 14px;
        cursor: pointer;
    }

    .tdb-catalog-sort-options label + label {
        border-top: 1px solid #e4e6ea;
    }

    .tdb-catalog-sort-options:has(> label:nth-child(9)) label:nth-child(2) {
        border-top: 0;
    }

    .tdb-catalog-sort-options label:has(:checked) {
        background: #fff3d6;
        font-weight: 700;
    }

    .tdb-catalog-sort-options label:has(:focus-visible) {
        outline: 2px solid #171717;
        outline-offset: -2px;
    }

    .tdb-catalog-sort-options input[type="radio"] {
        width: 18px;
        height: 18px;
        flex: none;
        margin: 0;
        appearance: auto;
        accent-color: #9b5900;
    }

    .tdb-catalog-dialog-footer {
        flex: none;
        padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
        border-top: 1px solid #e4e6ea;
        background: #fff;
    }

    .tdb-catalog-footer-actions {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }

    .tdb-catalog-dialog-message {
        margin: 0 0 8px;
        color: #9b2c10;
        font-size: 14px;
    }

    .tdb-catalog-dialog-footer button:disabled {
        cursor: wait;
        opacity: .65;
    }

    .tdb-catalog-toolbar button[data-loading],
    .tdb-catalog-dialog-footer button[data-loading] {
        cursor: wait;
        opacity: 1;
        white-space: nowrap;
    }

    .tdb-catalog-toolbar button[data-loading]::before,
    .tdb-catalog-dialog-footer button[data-loading]::before {
        content: "";
        box-sizing: border-box;
        flex: none;
        width: 13px;
        height: 13px;
        border: 2px solid currentColor;
        border-inline-end-color: transparent;
        border-radius: 50%;
    }

    @media (prefers-reduced-motion: no-preference) {
        .tdb-catalog-toolbar button[data-loading]::before,
        .tdb-catalog-dialog-footer button[data-loading]::before {
            animation: tdb-catalog-loading .75s linear infinite;
        }
    }

    @keyframes tdb-catalog-loading {
        to { transform: rotate(360deg); }
    }

    .tdb-catalog-toolbar button:focus-visible,
    .tdb-catalog-dialog button:focus-visible {
        outline: 2px solid #171717;
        outline-offset: 2px;
    }
}

@media (max-width: 360px) {
    .tdb-catalog-shortcuts button {
        gap: 3px;
        font-size: 12px;
    }

    .tdb-catalog-shortcuts svg {
        width: 14px;
        height: 14px;
    }
}
