/* ═══════════════════════════════════════════════════════ */
/* SEARCH BOX — Smart Layout + Fixed Spinner              */
/* Version: 2.1 — Full-width button on mobile             */
/* ═══════════════════════════════════════════════════════ */

.search { 
    margin-top: -42px; 
    position: relative; 
    z-index: 100; 
}

.search__box {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(26,35,50,.14);
    padding: 16px;
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr 1fr auto;
    gap: 12px;
    align-items: end;
}

.search__field {
    min-width: 0;
    display: flex;
    flex-direction: column;
    position: relative;
}

.search__field label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 700;
    color: #6B7280;
    margin-bottom: 6px;
    letter-spacing: .5px;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search__field label i {
    color: #E07A3F;
    font-size: 11px;
}

/* ─── Selects ─── */
.search__field select {
    width: 100%;
    min-width: 0;
    padding: 10px 32px 10px 12px;
    border: 1.5px solid #E5E7EB;
    border-radius: 10px;
    font-family: inherit;
    font-size: 13.5px;
    color: #1A2332;
    background: #FAF6F0;
    transition: all .22s ease;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    text-overflow: ellipsis;
}

.search__field select:focus {
    outline: none;
    border-color: #E07A3F;
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(224,122,63,.12);
}

/* ═══════════════════════════════════════════════════════ */
/* CITY PICKER — Autocomplete                             */
/* ═══════════════════════════════════════════════════════ */

.city-picker {
    position: relative;
    display: flex;
    align-items: center;
}

.city-picker__input {
    width: 100%;
    padding: 10px 34px 10px 12px;
    border: 1.5px solid #E5E7EB;
    border-radius: 10px;
    font-family: inherit;
    font-size: 13.5px;
    color: #1A2332;
    background: #FAF6F0;
    transition: all .22s ease;
    min-width: 0;
}

.city-picker__input:focus {
    outline: none;
    border-color: #E07A3F;
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(224,122,63,.12);
}

.city-picker__input::placeholder {
    color: #9CA3AF;
}

.city-picker__clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0,0,0,.06);
    color: #6B7280;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .2s;
    border: none;
    padding: 0;
}

.city-picker__clear:hover {
    background: #E07A3F;
    color: #fff;
}

.city-picker__dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(26,35,50,.18);
    border: 1px solid rgba(0,0,0,.06);
    overflow: hidden;
    z-index: 500;
    max-height: 320px;
    animation: cityDropIn .2s ease;
}

@keyframes cityDropIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.city-picker__list {
    max-height: 320px;
    overflow-y: auto;
    padding: 6px;
}

.city-picker__list::-webkit-scrollbar { width: 6px; }
.city-picker__list::-webkit-scrollbar-thumb {
    background: #E5E0D8;
    border-radius: 3px;
}

.city-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    border-radius: 9px;
    cursor: pointer;
    transition: background .15s ease;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.city-item:hover,
.city-item.is-active {
    background: #FAF6F0;
}

.city-item__icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: rgba(224,122,63,.1);
    color: #E07A3F;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

.city-item__body {
    flex: 1;
    min-width: 0;
}

.city-item__name {
    font-size: 13.5px;
    font-weight: 700;
    color: #1A2332;
    line-height: 1.2;
    margin: 0;
    display: block;
}

.city-item__name mark {
    background: rgba(224,122,63,.25);
    color: #C25A2A;
    padding: 0 1px;
    border-radius: 2px;
}

.city-item__region {
    font-size: 10.5px;
    color: #9CA3AF;
    margin: 2px 0 0;
    line-height: 1.2;
    display: block;
}

.city-item__popular {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #C25A2A;
    background: rgba(224,122,63,.12);
    padding: 2px 6px;
    border-radius: 100px;
    flex-shrink: 0;
}

.city-picker__empty {
    padding: 24px 16px;
    text-align: center;
    color: #9CA3AF;
    font-size: 13px;
}

.city-picker__empty i {
    font-size: 24px;
    display: block;
    margin-bottom: 8px;
    color: #E5DDD0;
}

/* ═══════════════════════════════════════════════════════ */
/* SEARCH BUTTON + SPINNER — FIXED                        */
/* ═══════════════════════════════════════════════════════ */

.search__btn {
    height: 42px;
    padding: 0 22px;
    border-radius: 10px;
    white-space: nowrap;
    font-size: 13.5px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    position: relative;
    overflow: hidden;
    transition: all .25s ease;
}

/* ─── حالة التحميل ─── */
.search__btn.is-loading {
    pointer-events: none;
    opacity: .9;
}

/* ✅ إخفاء الأيقونة والنص عند التحميل */
.search__btn.is-loading #searchSubmitIcon {
    display: none !important;
}

.search__btn.is-loading > span:not(.search__btn-spinner) {
    display: none !important;
}

/* ═══════════════════════════════════════════════════════ */
/* SPINNER — مخفي افتراضياً بشكل قاطع                     */
/* ═══════════════════════════════════════════════════════ */

.search__btn-spinner {
    display: none !important;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.35);
    border-top-color: #fff;
    animation: searchSpin .7s linear infinite;
    flex-shrink: 0;
}

.search__btn.is-loading .search__btn-spinner {
    display: inline-block !important;
}

.search__btn-spinner[hidden] {
    display: none !important;
}

@keyframes searchSpin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════ */
/* RESPONSIVE — TABLET (≤992px)                           */
/* ═══════════════════════════════════════════════════════ */
@media (max-width: 992px) {
    .search__box {
        grid-template-columns: 1fr 1fr;
        gap: 11px;
    }
    .search__btn {
        grid-column: 1 / -1;
        justify-self: stretch;   /* ✅ يمتد على كامل العرض */
        width: 100%;             /* ✅ عرض كامل */
        padding: 0 34px;
    }
}

/* ═══════════════════════════════════════════════════════ */
/* RESPONSIVE — MOBILE (≤640px)                           */
/* ═══════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    .search { margin-top: -28px; }

    .search__box {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px 8px;
        padding: 14px;
        border-radius: 14px;
    }

    .search__field { grid-column: span 1 !important; }

    .search__field label {
        font-size: 9.5px;
        letter-spacing: .2px;
        margin-bottom: 4px;
    }

    .search__field label i { font-size: 9px; }

    .search__field select,
    .city-picker__input {
        padding: 9px 26px 9px 9px;
        font-size: 12.5px;
        background-position: right 7px center;
        background-size: 9px;
        border-radius: 8px;
    }

    .city-picker__input { padding-right: 30px; }
    .city-picker__clear { right: 6px; width: 18px; height: 18px; font-size: 9px; }

    .city-picker__dropdown {
        max-height: 260px;
        border-radius: 10px;
    }

    .city-item { padding: 8px 9px; gap: 8px; }
    .city-item__icon { width: 26px; height: 26px; font-size: 11px; border-radius: 7px; }
    .city-item__name { font-size: 12.5px; }
    .city-item__region { font-size: 9.5px; }
    .city-item__popular { font-size: 8px; padding: 1px 5px; }

    /* ✅ زر Search يأخذ العرض الكامل على الهاتف */
    .search__btn {
        grid-column: 1 / -1 !important;
        justify-self: stretch !important;
        width: 100% !important;
        height: 40px;
        padding: 0 26px;
        font-size: 13px;
    }
}

/* ─── Very small (≤380px) ─── */
@media (max-width: 380px) {
    .search__box { gap: 8px 6px; padding: 12px; }
    .search__field label { font-size: 9px; }
    .search__field select,
    .city-picker__input { font-size: 11.5px; padding: 8px 22px 8px 7px; }

    /* ✅ زر Search يأخذ العرض الكامل */
    .search__btn {
        height: 38px;
        font-size: 12px;
        padding: 0 22px;
        width: 100%;
        justify-self: stretch;
    }
}

/* ═══════════════════════════════════════════════════════ */
/* REDUCED MOTION                                         */
/* ═══════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    .search__btn-spinner {
        animation-duration: 1.2s;
    }
    .city-picker__dropdown {
        animation: none;
    }
}

/* ═══════════════════════════════════════════════════════ */
/* VALIDATION ERROR MESSAGE                               */
/* ═══════════════════════════════════════════════════════ */

.search__error {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 12px 14px;
    background: linear-gradient(135deg, #FEF2F2 0%, #FEE2E2 100%);
    border: 1.5px solid #FECACA;
    border-radius: 10px;
    color: #991B1B;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    animation: searchErrorIn .35s cubic-bezier(.2,.9,.3,1);
    box-shadow: 0 4px 12px rgba(220,38,38,.08);
}

@keyframes searchErrorIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search__error--hiding {
    animation: searchErrorOut .25s ease forwards;
}

@keyframes searchErrorOut {
    to {
        opacity: 0;
        transform: translateY(-6px);
        margin-top: 0;
        padding: 0 14px;
        max-height: 0;
    }
}

.search__error > i:first-child {
    color: #DC2626;
    font-size: 16px;
    flex-shrink: 0;
    animation: searchErrorPulse 1.5s ease-in-out infinite;
}

@keyframes searchErrorPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.1); }
}

.search__error > span {
    flex: 1;
    min-width: 0;
}

.search__error-close {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(220,38,38,.1);
    color: #991B1B;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s ease;
    border: none;
    flex-shrink: 0;
}

.search__error-close:hover {
    background: #DC2626;
    color: #fff;
}

/* ═══════════════════════════════════════════════════════ */
/* SHAKE ANIMATION — عند الخطأ                            */
/* ═══════════════════════════════════════════════════════ */

.search__field--shake {
    animation: searchShake .5s cubic-bezier(.36,.07,.19,.97);
}

@keyframes searchShake {
    10%, 90% { transform: translate3d(-2px, 0, 0); }
    20%, 80% { transform: translate3d(4px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
    40%, 60% { transform: translate3d(6px, 0, 0); }
}

/* ═══════════════════════════════════════════════════════ */
/* MOBILE ADJUSTMENTS — Error Message                     */
/* ═══════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    .search__error {
        font-size: 12px;
        padding: 10px 12px;
        gap: 8px;
        margin-top: 10px;
    }
    .search__error > i:first-child {
        font-size: 14px;
    }
    .search__error-close {
        width: 20px;
        height: 20px;
        font-size: 9px;
    }
}

@media (max-width: 380px) {
    .search__error {
        font-size: 11px;
        padding: 9px 10px;
    }
}

/* ═══════════════════════════════════════════════════════ */
/* REDUCED MOTION — Error                                 */
/* ═══════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    .search__error,
    .search__error > i:first-child,
    .search__field--shake {
        animation: none !important;
    }
}