/**
 * Ithemba Search Bar – base styles.
 *
 * These are intentionally minimal so Breakdance / your theme can own the
 * visual design.  Only functional / structural rules are included here.
 */

/* ── Search bar container ─────────────────────────────────────────────── */

.ithemba-search-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.isb-field {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.isb-field--area     { width: 250px; }
.isb-field--building { width: 165px; }
.isb-field--unit-type { width: 138px; }

.isb-field--budget {
    padding: 0px 35px;
}

/* ── Tablet / mobile: stack all fields full-width ─────────────────────── */
@media ( max-width: 768px ) {
    .ithemba-search-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .isb-field--area,
    .isb-field--building,
    .isb-field--unit-type {
        width: 100%;
    }

    .isb-field--area select,
    .isb-field--building select,
    .isb-field--unit-type select {
        width: 100%;
    }
}

.isb-field label {
    font-size: .875rem;
    font-weight: 600;
    color: #aac8a1;
}

.isb-field select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    background-color: transparent;
    border: 1.5px solid #aac8a1;
    border-radius: 999px;
    padding: 15px 45px 15px 25px;
    font-size: .95rem;
    color: #7f7f7f;
    cursor: pointer;
    /* custom chevron */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%23aac8a1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.isb-field select:hover {
    border-color: #aac8a1;
}

.isb-field select:focus {
    border-color: #aac8a1;
    box-shadow: 0 0 0 3px rgba(122, 171, 114, .25);
}

.isb-field select option {
    background-color: #000;
    color: #7f7f7f;
}

.isb-field select option:hover,
.isb-field select option:checked {
    background-color: #aac8a1;
    color: #000;
}

/* ── Multi-select dropdowns ──────────────────────────────────────────── */

.isb-multiselect {
    position: relative;
    width: 100%;
}

.isb-ms-toggle {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    background-color: transparent;
    border: 1.5px solid #aac8a1;
    border-radius: 999px;
    padding: 15px 45px 15px 25px;
    font-size: .95rem;
    color: #7f7f7f;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%23aac8a1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.isb-ms-toggle:hover {
    border-color: #aac8a1;
}

.isb-ms-toggle:focus {
    border-color: #aac8a1;
    box-shadow: 0 0 0 3px rgba(122, 171, 114, .25);
}

.isb-ms-toggle[aria-expanded="true"] {
    border-color: #aac8a1;
    box-shadow: 0 0 0 3px rgba(122, 171, 114, .25);
}

.isb-ms-toggle:disabled {
    opacity: .45;
    cursor: not-allowed;
    border-color: #555;
}

.isb-ms-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 100%;
    background: #1a1a1a;
    border: 1.5px solid #aac8a1;
    border-radius: 12px;
    padding: 8px 0;
    z-index: 100;
    max-height: 240px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,.5);
}

.isb-ms-option {
    display: block;
    padding: 9px 18px;
    font-size: .9rem;
    color: #7f7f7f;
    cursor: pointer;
    user-select: none;
    transition: background .15s ease, color .15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.isb-ms-option:hover {
    background: rgba(122, 171, 114, .12);
    color: #ccc;
}

.isb-ms-option.is-selected {
    background: rgba(122, 171, 114, .22);
    color: #aac8a1;
}

.isb-ms-option.is-selected:hover {
    background: rgba(122, 171, 114, .32);
}

.isb-ms-option--all {
    font-weight: 600;
    border-bottom: 1px solid rgba(122, 171, 114, .2);
    margin-bottom: 4px;
    padding-bottom: 10px;
}

.isb-ms-option--all.is-selected {
    color: #aac8a1;
}

/* ── Budget slider ───────────────────────────────────────────────────── */

.isb-field input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    margin: .75rem 0 .5rem;
}

/* Webkit (Chrome, Safari, Edge) thumb */
.isb-field input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #b22222;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 3px rgba(0, 0, 0, .5);
}

/* Firefox track */
.isb-field input[type="range"]::-moz-range-track {
    height: 2px;
    background: #fff;
    border-radius: 2px;
}

/* Firefox thumb */
.isb-field input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #b22222;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 3px rgba(0, 0, 0, .5);
}

.isb-budget-val {
    display: block;
    font-size: .875rem;
    color: #7f7f7f;
}

button.isb-search-btn {
    border-radius: 15px;
    background: #aac8a1;
    color: black;
    text-transform: uppercase;
    padding: 15px 25px;
    border: none;
}

/* ── Loading state ────────────────────────────────────────────────────── */

.ithemba-search-results.is-loading .isr-inner {
    opacity: .4;
    pointer-events: none;
    transition: opacity .2s ease;
}

/* ── Results grid ─────────────────────────────────────────────────────── */

/* Properties and unit types: single column */
.isr-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

/* ── Units grid (pricelists): 3 columns ──────────────────────────────── */

.ithemba-units-grid {
    display: grid;
    grid-template-columns: repeat( 3, 1fr );
    gap: 1.5rem;
}

@media ( max-width: 900px ) {
    .ithemba-units-grid {
        grid-template-columns: repeat( 2, 1fr );
    }
}

@media ( max-width: 600px ) {
    .ithemba-units-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Property unit types grid ────────────────────────────────────────── */
/* Items are percentage-width, centred; up to 5 per row, min 2.           */
/* Fewer than 4 items are capped at 250 px wide.                          */

.ithemba-property-unit-types {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

/* Default: 5 per row; flex-grow fills the row, max-width caps lone items */
.ithemba-property-unit-types > * {
    flex: 1 1 calc( 20% - 8px );
    max-width: 250px;
    box-sizing: border-box;
}

/* 3 per row on mid-sized screens */
@media ( max-width: 900px ) {
    .ithemba-property-unit-types > * {
        flex: 1 1 calc( 33.333% - 7px );
        max-width: 250px;
    }
}

/* 2 per row on small screens */
@media ( max-width: 500px ) {
    .ithemba-property-unit-types > * {
        flex: 1 1 calc( 50% - 5px );
        max-width: 250px;
    }
}

/* ── Card base ────────────────────────────────────────────────────────── */

/* Wrapper injected by query_and_render() — needed so the PHP-injected
   promotion badge (REST/AJAX context) can be positioned over the card. */
.ithemba-card-wrap {
    position: relative;
}

.ithemba-card {
    position: relative;
    overflow: hidden;
}

.ithemba-card__thumb img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.ithemba-card__specs {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.ithemba-card__badge {
    position: absolute;
    top: .75rem;
    left: .75rem;
    padding: .25rem .6rem;
    font-size: .75rem;
    font-weight: 700;
    border-radius: 4px;
    pointer-events: none;
}

.ithemba-card__badge--promo {
    background: #e84141;
    color: #fff;
}

.ithemba-card__badge--low-stock {
    background: #f59e0b;
    color: #fff;
    top: 2.25rem; /* stack below promo badge if both present */
}

/* ── Pagination ───────────────────────────────────────────────────────── */

.isr-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: 2rem;
    justify-content: center;
}

.isr-page-btn {
    min-width: 2.25rem;
    padding: .35rem .6rem;
    border: 1px solid currentColor;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    font-size: .875rem;
    line-height: 1;
}

.isr-page-btn.is-active {
    font-weight: 700;
    cursor: default;
}

/* ── Notices ──────────────────────────────────────────────────────────── */

.ithemba-notice,
.ithemba-no-results {
    padding: 1rem;
    border: 1px solid currentColor;
    border-radius: 4px;
    text-align: center;
}
