/**
 * Homexty RealHomes Enhancer — Geo Search Widget Styles
 *
 * ARCHITECTURE:
 *   Every visual property is driven by a CSS custom property (--rhe-*).
 *   This means full customization via:
 *     1. Admin settings → Elementor style controls
 *     2. Child theme CSS → override --rhe-* variables
 *     3. Inline style attribute on the wrapper
 *
 * DESIGN VARIANTS:
 *   The wrapper receives a data-rhe-variant="classic|modern|ultra" attribute
 *   (set by PHP based on the active RealHomes variant). Each variant applies
 *   its own preset values to match the native search form look.
 *
 * LAYOUTS:
 *   .rhe-layout-vertical   — stacked (default, sidebar-friendly)
 *   .rhe-layout-horizontal — inline row (search bar style)
 *   .rhe-layout-compact    — minimal, no labels
 *
 * @package RealHomesEnhancer
 */

/* ═══════════════════════════════════════════════════════════
   1. CSS CUSTOM PROPERTIES — The customization system
   ═══════════════════════════════════════════════════════════ */

.rhe-geo-search-wrapper {
    /* ── Colors ── */
    --rhe-color-primary:       #1ea69a;
    --rhe-color-primary-hover: #178f84;
    --rhe-color-primary-light: rgba(30, 166, 154, 0.15);
    --rhe-color-text:          #333333;
    --rhe-color-text-light:    #999999;
    --rhe-color-label:         #1a1a2e;
    --rhe-color-bg:            #ffffff;
    --rhe-color-bg-disabled:   #f5f5f5;
    --rhe-color-border:        #dcdcdc;
    --rhe-color-border-hover:  #b0b0b0;
    --rhe-color-border-focus:  var(--rhe-color-primary);
    --rhe-color-btn-text:      #ffffff;
    --rhe-color-btn-bg:        var(--rhe-color-primary);
    --rhe-color-btn-bg-hover:  var(--rhe-color-primary-hover);

    /* ── Typography ── */
    --rhe-font-family:         inherit;
    --rhe-font-size-select:    14px;
    --rhe-font-size-label:     13px;
    --rhe-font-size-btn:       14px;
    --rhe-font-weight-label:   500;
    --rhe-font-weight-btn:     600;
    --rhe-line-height:         1.4;

    /* ── Spacing ── */
    --rhe-gap:                 12px;
    --rhe-padding-select:      10px 35px 10px 12px;
    --rhe-padding-btn:         12px 24px;
    --rhe-label-margin:        5px;

    /* ── Borders ── */
    --rhe-border-width:        1px;
    --rhe-border-style:        solid;
    --rhe-border-radius:       4px;
    --rhe-border-radius-btn:   4px;

    /* ── Focus ── */
    --rhe-focus-shadow:        0 0 0 2px var(--rhe-color-primary-light);

    /* ── Transitions ── */
    --rhe-transition-speed:    0.2s;
    --rhe-transition-easing:   ease;

    /* ── Loading spinner ── */
    --rhe-spinner-size:        16px;
    --rhe-spinner-border:      2px;
    --rhe-spinner-color:       var(--rhe-color-primary);
    --rhe-spinner-bg:          #ddd;

    /* ── Layout ── */
    --rhe-field-min-width:     150px;
    --rhe-btn-min-width:       120px;

    /* Base */
    position: relative;
    font-family: var(--rhe-font-family);
}

/* ═══════════════════════════════════════════════════════════
   2. BASE LAYOUT — Vertical (default)
   ═══════════════════════════════════════════════════════════ */

.rhe-geo-form {
    display: flex;
    flex-direction: column;
    gap: var(--rhe-gap);
}

/* ═══════════════════════════════════════════════════════════
   3. FIELD CONTAINERS
   ═══════════════════════════════════════════════════════════ */

.rhe-geo-field {
    position: relative;
    overflow: hidden;
}

.rhe-geo-label {
    display: block;
    font-size: var(--rhe-font-size-label);
    font-weight: var(--rhe-font-weight-label);
    margin-bottom: var(--rhe-label-margin);
    color: var(--rhe-color-label);
}

/* ═══════════════════════════════════════════════════════════
   4. SELECT STYLING
   ═══════════════════════════════════════════════════════════ */

.rhe-geo-select {
    width: 100%;
    padding: var(--rhe-padding-select);
    font-family: var(--rhe-font-family);
    font-size: var(--rhe-font-size-select);
    line-height: var(--rhe-line-height);
    color: var(--rhe-color-text);
    background-color: var(--rhe-color-bg);
    border: var(--rhe-border-width) var(--rhe-border-style) var(--rhe-color-border);
    border-radius: var(--rhe-border-radius);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    cursor: pointer;
    transition: border-color var(--rhe-transition-speed) var(--rhe-transition-easing),
                box-shadow var(--rhe-transition-speed) var(--rhe-transition-easing);
}

.rhe-geo-select:hover {
    border-color: var(--rhe-color-border-hover);
}

.rhe-geo-select:focus {
    outline: none;
    border-color: var(--rhe-color-border-focus);
    box-shadow: var(--rhe-focus-shadow);
}

.rhe-geo-select:disabled {
    background-color: var(--rhe-color-bg-disabled);
    color: var(--rhe-color-text-light);
    cursor: not-allowed;
}

/* ═══════════════════════════════════════════════════════════
   5. SEARCH BUTTON
   ═══════════════════════════════════════════════════════════ */

.rhe-geo-search-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: var(--rhe-padding-btn);
    font-family: var(--rhe-font-family);
    font-size: var(--rhe-font-size-btn);
    font-weight: var(--rhe-font-weight-btn);
    color: var(--rhe-color-btn-text);
    background-color: var(--rhe-color-btn-bg);
    border: none;
    border-radius: var(--rhe-border-radius-btn);
    cursor: pointer;
    transition: background-color var(--rhe-transition-speed) var(--rhe-transition-easing),
                transform 0.1s var(--rhe-transition-easing);
    line-height: 1;
}

.rhe-geo-search-btn:hover {
    background-color: var(--rhe-color-btn-bg-hover);
}

.rhe-geo-search-btn:active {
    transform: scale(0.98);
}

.rhe-geo-search-btn .rhe-btn-icon {
    display: flex;
    align-items: center;
}

.rhe-geo-search-btn .rhe-btn-icon svg {
    width: 16px;
    height: 16px;
}

/* ═══════════════════════════════════════════════════════════
   6. LOADING STATE
   ═══════════════════════════════════════════════════════════ */

.rhe-geo-field.rhe-loading::after {
    content: '';
    position: absolute;
    right: 40px;
    top: 50%;
    width: var(--rhe-spinner-size);
    height: var(--rhe-spinner-size);
    margin-top: 4px;
    border: var(--rhe-spinner-border) solid var(--rhe-spinner-bg);
    border-top-color: var(--rhe-spinner-color);
    border-radius: 50%;
    animation: rhe-spin 0.6s linear infinite;
}

@keyframes rhe-spin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════
   7. LAYOUT: HORIZONTAL (search bar style)
   ═══════════════════════════════════════════════════════════ */

.rhe-layout-horizontal .rhe-geo-form {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--rhe-gap);
}

.rhe-layout-horizontal .rhe-geo-field {
    flex: 1 1 var(--rhe-field-min-width);
    min-width: var(--rhe-field-min-width);
}

.rhe-layout-horizontal .rhe-geo-field-submit {
    flex: 0 0 auto;
}

.rhe-layout-horizontal .rhe-geo-search-btn {
    width: auto;
    min-width: var(--rhe-btn-min-width);
}

/* ═══════════════════════════════════════════════════════════
   8. LAYOUT: COMPACT (no labels, minimal)
   ═══════════════════════════════════════════════════════════ */

.rhe-layout-compact .rhe-geo-label {
    display: none;
}

.rhe-layout-compact .rhe-geo-form {
    gap: 8px;
}

.rhe-layout-compact .rhe-geo-select {
    padding: 8px 30px 8px 10px;
    font-size: 13px;
}

.rhe-layout-compact .rhe-geo-search-btn {
    padding: 8px 16px;
    font-size: 13px;
}

.rhe-layout-compact .rhe-geo-search-btn .rhe-btn-text {
    display: none;
}

/* ═══════════════════════════════════════════════════════════
   9. DESIGN VARIANT: RealHomes Modern
      Matches the modern search bar aesthetic
   ═══════════════════════════════════════════════════════════ */

.rhe-geo-search-wrapper[data-rhe-variant="modern"] {
    --rhe-border-radius:       0;
    --rhe-border-radius-btn:   0;
    --rhe-font-size-label:     14px;
    --rhe-font-weight-label:   400;
    --rhe-color-label:         #808080;
    --rhe-padding-select:      12px 35px 12px 15px;
    --rhe-color-border:        #dedede;
    --rhe-color-border-focus:  #b0b0b0;
    --rhe-focus-shadow:        none;
}

/* Modern: field underline style */
.rhe-geo-search-wrapper[data-rhe-variant="modern"] .rhe-geo-select {
    border-left: none;
    border-right: none;
    border-top: none;
    border-bottom: 2px solid var(--rhe-color-border);
    background-color: transparent;
}

.rhe-geo-search-wrapper[data-rhe-variant="modern"] .rhe-geo-select:focus {
    border-bottom-color: var(--rhe-color-primary);
}

/* ═══════════════════════════════════════════════════════════
   10. DESIGN VARIANT: RealHomes Classic
       Matches the classic framed look
   ═══════════════════════════════════════════════════════════ */

.rhe-geo-search-wrapper[data-rhe-variant="classic"] {
    --rhe-border-radius:       3px;
    --rhe-border-radius-btn:   3px;
    --rhe-font-size-select:    13px;
    --rhe-font-size-label:     12px;
    --rhe-font-weight-label:   600;
    --rhe-color-label:         #394044;
    --rhe-padding-select:      8px 30px 8px 10px;
    --rhe-padding-btn:         10px 20px;
    --rhe-color-border:        #b7b7b7;
    --rhe-color-bg:            #fcfcfc;
}

/* Classic: subtle inset shadow */
.rhe-geo-search-wrapper[data-rhe-variant="classic"] .rhe-geo-select {
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.07);
}

/* ═══════════════════════════════════════════════════════════
   11. DESIGN VARIANT: RealHomes Ultra
       Matches the Ultra rounded, spacious look
   ═══════════════════════════════════════════════════════════ */

.rhe-geo-search-wrapper[data-rhe-variant="ultra"] {
    --rhe-border-radius:       8px;
    --rhe-border-radius-btn:   8px;
    --rhe-font-size-select:    15px;
    --rhe-font-size-label:     13px;
    --rhe-font-weight-label:   500;
    --rhe-color-label:         #272727;
    --rhe-padding-select:      14px 40px 14px 16px;
    --rhe-padding-btn:         14px 28px;
    --rhe-gap:                 16px;
    --rhe-color-border:        #e0e0e0;
    --rhe-color-bg:            #f8f8f8;
    --rhe-focus-shadow:        0 0 0 3px var(--rhe-color-primary-light);
}

/* Ultra: elevated card feel */
.rhe-geo-search-wrapper[data-rhe-variant="ultra"] .rhe-geo-select:focus {
    background-color: #ffffff;
}

/* ═══════════════════════════════════════════════════════════
   12. THEME MATCH MODE — Let RealHomes CSS drive
   ═══════════════════════════════════════════════════════════ */

.rhe-geo-theme-match .rhe-geo-select {
    appearance: auto;
    -webkit-appearance: auto;
    -moz-appearance: auto;
    background-image: none;
    padding: revert;
    border: revert;
    border-radius: revert;
    box-shadow: revert;
}

.rhe-geo-theme-match .rhe-geo-search-btn {
    background-color: revert;
    border-radius: revert;
    padding: revert;
}

/* ═══════════════════════════════════════════════════════════
   13. RESPONSIVE
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
    .rhe-layout-horizontal .rhe-geo-form {
        flex-direction: column;
    }

    .rhe-layout-horizontal .rhe-geo-field {
        flex: 1 1 100%;
    }

    .rhe-layout-horizontal .rhe-geo-search-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .rhe-geo-search-wrapper {
        --rhe-font-size-select: 16px; /* Prevents iOS zoom */
        --rhe-padding-select:   12px 35px 12px 10px;
    }
}

/* ═══════════════════════════════════════════════════════════
   14. ELEMENTOR EDITOR PREVIEW
   ═══════════════════════════════════════════════════════════ */

.rhe-geo-elementor-preview {
    min-height: 60px;
}


/* ═══════════════════════════════════════════════════════════
   15. ULTRA SEARCH FORM — Full form replicating RealHomes Ultra
   ═══════════════════════════════════════════════════════════ */

.rhe-ultra-form-wrapper {
    font-family: var(--rhe-font-family, inherit);
}

.rhe-ultra-form-wrapper .rh-ultra-search-form-inner {
    border-radius: 30px;
    box-shadow: 0 0 7px -2px rgba(0, 0, 0, 0.19);
    background: var(--rhe-ultra-card-bg, #fff);
    padding: 30px;
}

/* ── TOP ROW: Keyword + Status Pills ── */
.rhe-ultra-top-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    flex-wrap: wrap;
}

.rhe-ultra-keyword-field {
    flex: 1 1 250px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 200px;
}

.rhe-ultra-keyword-field label {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    color: var(--rh-global-color-primary, #1db2ff);
    opacity: 0.6;
}

.rhe-ultra-keyword-field input[type="text"] {
    flex: 1;
    border: none;
    border-bottom: 2px solid rgba(0, 0, 0, 0.08);
    padding: 8px 0;
    font-size: 15px;
    font-weight: 500;
    color: var(--rh-global-color-headings, #1a1a2e);
    background: transparent;
    outline: none;
    transition: border-color 0.2s ease;
}

.rhe-ultra-keyword-field input[type="text"]:focus {
    border-bottom-color: var(--rh-global-color-primary, #1db2ff);
}

.rhe-ultra-keyword-field input[type="text"]::placeholder {
    color: #aaa;
    font-weight: 400;
}

/* ── Status Pills ── */
.rhe-ultra-status-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
}

.rhe-status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin: 0;
}

.rhe-status-pill input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.rhe-status-pill span {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 500;
    color: var(--rh-global-color-headings, #333);
    background: #f0f0f0;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.rhe-status-pill:hover span {
    background: #e0e0e0;
}

.rhe-status-pill.rhe-active span,
.rhe-status-pill input[type="radio"]:checked ~ span {
    background: var(--rh-global-color-primary, #1db2ff);
    color: #fff;
}

/* ── FIELDS ROW ── */
.rhe-ultra-fields-row {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 0;
}

.rhe-ultra-field {
    flex: 1 1 0;
    min-width: 130px;
    padding: 0 15px;
    position: relative;
}

.rhe-ultra-field + .rhe-ultra-field::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 1px;
    background: rgba(0, 0, 0, 0.08);
}

.rhe-ultra-field-divider {
    width: 2px;
    align-self: stretch;
    margin: 8px 0;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 1px;
    flex-shrink: 0;
}

.rhe-ultra-field > label {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: #999;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* BSP inside Ultra form — flat look */
.rhe-ultra-form-wrapper .bootstrap-select.rh-ultra-select-dropdown > .dropdown-toggle,
.rhe-ultra-form-wrapper .bootstrap-select > .dropdown-toggle {
    background: transparent;
    border: none;
    border-radius: 0;
    padding-left: 0;
    padding-right: 15px;
    line-height: 40px;
    font-weight: 600;
    font-size: 14px;
    color: var(--rh-global-color-headings, #333);
    box-shadow: none;
}

.rhe-ultra-form-wrapper .bootstrap-select > .dropdown-toggle:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* Native select fallback */
.rhe-ultra-form-wrapper .rhe-geo-select {
    width: 100%;
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding: 8px 25px 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--rh-global-color-headings, #333);
    background: transparent;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%231db2ff' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 4px center;
    background-size: 10px;
    cursor: pointer;
}

.rhe-ultra-form-wrapper .rhe-geo-select:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Location icon on country label */
.rhe-ultra-field.rhe-geo-field-country > label::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 5px;
    vertical-align: text-bottom;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='%231db2ff' opacity='0.7'%3E%3Cpath d='M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
}

/* ── BUTTONS ROW ── */
.rhe-ultra-form-wrapper .rhe-ultra-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 15px 30px 20px;
}

.rhe-ultra-advanced-btn a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--rh-global-color-headings, #333);
    text-decoration: none;
    border-radius: 25px;
    transition: background 0.2s ease;
}

.rhe-ultra-advanced-btn a:hover {
    background: rgba(0, 0, 0, 0.04);
}

.rhe-ultra-advanced-btn a svg {
    color: var(--rh-global-color-primary, #1db2ff);
}

.rhe-ultra-form-wrapper .rh_btn__prop_search {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: var(--rh-global-color-primary, #1db2ff);
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

.rhe-ultra-form-wrapper .rh_btn__prop_search:hover {
    background: var(--rh-global-color-primary-dark, #0a8fd8);
}

.rhe-ultra-form-wrapper .rh_btn__prop_search:active {
    transform: scale(0.97);
}

/* Loading spinner in Ultra form */
.rhe-ultra-form-wrapper .rhe-geo-field.rhe-loading::after {
    right: 30px;
    top: 50%;
    margin-top: 8px;
}

/* ═══════════════════════════════════════════════════════════
   16. RESPONSIVE — Ultra form
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 991px) {
    .rhe-ultra-fields-row {
        flex-wrap: wrap;
    }

    .rhe-ultra-field {
        flex: 1 1 45%;
        min-width: 45%;
        margin-bottom: 12px;
    }

    .rhe-ultra-field-divider {
        display: none;
    }

    .rhe-ultra-field + .rhe-ultra-field::before {
        display: none;
    }
}

@media (max-width: 600px) {
    .rhe-ultra-top-row {
        flex-direction: column;
        align-items: stretch;
    }

    .rhe-ultra-keyword-field {
        flex: 1 1 100%;
    }

    .rhe-ultra-status-pills {
        justify-content: center;
    }

    .rhe-ultra-field {
        flex: 1 1 100%;
        min-width: 100%;
        padding: 0 10px;
    }

    .rhe-ultra-form-wrapper .rh-ultra-search-form-inner {
        padding: 20px 15px;
        border-radius: 20px;
    }

    .rhe-ultra-form-wrapper .rhe-ultra-buttons {
        flex-direction: column;
        padding: 10px 15px 15px;
    }
}
