/**
 * Kafraty — two-size search for the Tyresaddict finders (homepage + header popup).
 *
 * The toggle is styled as the same primary pill as «أبحث عن إطارك» so the two
 * controls read as one set. The front/rear fields are wrapped into their own
 * groups so opening the second axle stacks the rows instead of squeezing every
 * select into the finder's original single flex row.
 */

.twf-finder form.js-tyre-size.kf-two-enabled {
    position: relative;
    float: none; /* the finder plugin floats the form, which otherwise collapses its wrapper */
    display: flex !important;
    flex-flow: row wrap !important;
    align-items: center !important;
    gap: 20px !important;
    direction: rtl;
}

/* First row: front fields + toggle + search button. */
.twf-finder .kf-two-front-group {
    order: 1;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.twf-finder .kf-two-toggle-row {
    order: 2;
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: auto;
    min-width: 0;
    margin: 0;
    padding: 0;
    direction: rtl;
}

.twf-finder .kf-two-button-row {
    order: 3;
    flex: 0 0 auto;
    min-width: 0;
}

/* Second row: rear fields, only when the second size is open. */
.twf-finder .kf-two-rear-group {
    order: 4;
    display: flex;
    flex: 0 0 100%;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    width: 100%;
}

/* The header popup is narrower than the homepage widget: give the fields a
   full row and split the two actions underneath so nothing is squeezed. */
.twf-finder form.kaf-fp-finder .kf-two-front-group {
    flex: 0 0 100%;
}

.twf-finder form.kaf-fp-finder .kf-two-toggle-row,
.twf-finder form.kaf-fp-finder .kf-two-button-row {
    flex: 1 1 calc(50% - 10px);
}

.twf-finder form.kaf-fp-finder .kf-two-toggle,
.twf-finder form.kaf-fp-finder .kf-two-button-row .tyre-filter {
    width: 100%;
}

/* Same pill as the search button. */
.twf-finder .kf-two-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 50px !important;
    min-height: 50px;
    margin: 0;
    padding: 5px 20px !important;
    color: #fff !important;
    font: 500 17px/20.4px Almarai, Arial, Helvetica, sans-serif !important;
    text-align: center;
    text-decoration: none;
    background: #d3020e !important;
    border: 0 !important;
    border-radius: 10px !important;
    box-shadow: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: background .15s ease;
}

.twf-finder .kf-two-toggle:hover,
.twf-finder .kf-two-toggle.is-open {
    color: #fff !important;
    background: #b9020c !important;
}

.twf-finder .kf-two-toggle:focus-visible {
    outline: 2px solid rgba(211, 2, 14, .3);
    outline-offset: 2px;
}

.twf-finder .kf-two-toggle-icon {
    display: inline;
    flex: 0 0 auto;
    width: auto;
    height: auto;
    padding: 0;
    color: inherit;
    font: 700 19px/1 Arial, Helvetica, sans-serif;
    background: none;
    border: 0;
    border-radius: 0;
}

/* Axle titles sit above their own row, never beside the selects. */
.twf-finder .kf-two-axle-title {
    margin: 0 0 2px;
    color: #555;
    font: 400 13px/1.6 Almarai, Arial, Helvetica, sans-serif;
    text-align: right;
}

.twf-finder [hidden] {
    display: none !important;
}

/* Revealed rear row: match the front row's rhythm. */
.twf-finder .finder-compact-form.js-tyre-size-rear.is-open {
    display: flex;
    width: 100%;
    margin: 0;
}

/* The shop finder keeps its own toggle handler, but uses the same pill style. */
.twf-finder .finder-compact-form.kf-two-legacy .js-finder-tyre-separate {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 50px;
    margin: 0;
    padding: 5px 20px;
    color: #fff !important;
    font: 500 17px/20.4px Almarai, Arial, Helvetica, sans-serif;
    text-decoration: none;
    background: #d3020e;
    border-radius: 10px;
}

.twf-finder .finder-compact-form.kf-two-legacy .js-finder-tyre-separate:hover {
    color: #fff;
    background: #b9020c;
}

.twf-finder .finder-compact-form.kf-two-legacy .js-finder-tyre-separate .fa {
    width: auto;
    height: auto;
    color: inherit;
    font: 700 19px/1 Arial, Helvetica, sans-serif;
    background: none;
    border: 0;
    border-radius: 0;
}

@media screen and (max-width: 1024px) {
    .twf-finder form.js-tyre-size.kf-two-enabled {
        gap: 12px !important;
    }

    .twf-finder .kf-two-front-group {
        flex: 0 0 100%;
    }

    .twf-finder .kf-two-toggle-row,
    .twf-finder .kf-two-button-row {
        flex: 1 1 45%;
    }

    .twf-finder .kf-two-toggle,
    .twf-finder .kf-two-button-row .tyre-filter {
        width: 100%;
    }
}

@media screen and (max-width: 600px) {
    .twf-finder .kf-two-front-group,
    .twf-finder .kf-two-toggle-row,
    .twf-finder .kf-two-button-row {
        flex: 0 0 100%;
    }
}
