/* RESO Property Search Widget — Frontend Styles */

.reso-search-widget {
    font-family: inherit;
    max-width: 900px;
    margin: 0 auto;
}

/* ---- Form ---- */
.reso-search-form {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 24px 28px;
    margin-bottom: 24px;
}

.reso-search-form h2 {
    margin-top: 0;
    font-size: 1.25em;
    border-bottom: 2px solid #0073aa;
    padding-bottom: 10px;
    margin-bottom: 20px;
    color: #23282d;
}

.reso-field-groups {
    display: flex;
    flex-wrap: wrap;
    gap: 0 40px;
}

.reso-field-group {
    flex: 1 1 260px;
    min-width: 220px;
    margin-bottom: 20px;
}

.reso-field-group h3 {
    font-size: 0.85em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #666;
    margin: 0 0 10px;
    padding-bottom: 4px;
    border-bottom: 1px solid #e0e0e0;
}

.reso-field {
    margin-bottom: 12px;
}

.reso-field label {
    display: block;
    font-size: 0.875em;
    font-weight: 600;
    color: #444;
    margin-bottom: 4px;
}

.reso-field input[type="text"],
.reso-field input[type="number"],
.reso-field select {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9em;
    box-sizing: border-box;
    background: #fff;
    color: #23282d;
    transition: border-color 0.15s;
}

.reso-field input:focus,
.reso-field select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0,115,170,0.15);
}

.reso-field-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 0;
}

.reso-field-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
}

.reso-field-checkbox label {
    margin: 0;
    cursor: pointer;
}

/* ---- Form Actions ---- */
.reso-form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
}

.reso-btn-search {
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 10px 28px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.reso-btn-search:hover {
    background: #005177;
}

.reso-btn-reset {
    background: transparent;
    color: #0073aa;
    border: 1px solid #0073aa;
    border-radius: 4px;
    padding: 9px 20px;
    font-size: 0.9em;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.reso-btn-reset:hover {
    background: #0073aa;
    color: #fff;
}

/* ---- Spinner ---- */
.reso-spinner {
    display: inline-block;
    margin-left: 4px;
    vertical-align: middle;
}

.reso-spinner::after {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid #ddd;
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: reso-spin 0.7s linear infinite;
}

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

/* ---- Error ---- */
.reso-error {
    background: #fef0f0;
    color: #b71c1c;
    border: 1px solid #f5c6c6;
    border-radius: 4px;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 0.9em;
}

/* ---- Results ---- */
.reso-search-results {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 20px 24px;
}

/* Live-search refinement: dim results while a new request is in flight */
.reso-results-updating {
    opacity: 0.45;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

/* Result count pulsing during live update */
.reso-count-updating::after {
    content: ' — updating\2026';
    color: #0073aa;
    font-size: 0.85em;
    font-style: italic;
    animation: reso-pulse 0.9s ease-in-out infinite alternate;
}

@keyframes reso-pulse {
    from { opacity: 0.4; }
    to   { opacity: 1;   }
}

/* Debug JSON toggle */
.reso-json-container {
    position: relative;
}

.reso-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 4px 10px;
    font-size: 0.78em;
    cursor: pointer;
    color: #555;
    transition: background 0.1s;
}

.reso-copy-btn:hover {
    background: #f0f0f0;
}

#reso-json-output {
    background: #1e1e1e;
    color: #d4d4d4;
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 0.82em;
    line-height: 1.6;
    padding: 16px;
    border-radius: 4px;
    overflow-x: auto;
    white-space: pre;
    max-height: 600px;
    overflow-y: auto;
    margin: 0;
}

/* ── Autocomplete Dropdown ────────────────────────────────────────────────── */

.reso-ac-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #fff;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 220px;
    overflow-y: auto;
}

.reso-ac-dropdown li {
    padding: 8px 12px;
    font-size: 0.9em;
    color: #23282d;
    cursor: pointer;
    transition: background 0.1s;
}

.reso-ac-dropdown li:hover,
.reso-ac-dropdown li.reso-ac-active {
    background: #f0f7fb;
    color: #0073aa;
}

.reso-ac-dropdown li + li {
    border-top: 1px solid #f0f0f0;
}

/* ── Range widget (combined min/max + optional slider) ───────────────────── */

.reso-field-range .reso-range-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
}

.reso-field-range .reso-range-inputs input[type="number"] {
    flex: 1;
    min-width: 0;
}

.reso-range-sep {
    flex-shrink: 0;
    color: #888;
    font-size: 0.9em;
    padding: 0 2px;
}

/* Slider track container */
.reso-slider-wrap {
    position: relative;
    height: 28px;
    margin: 14px 8px 4px;
}

.reso-slider-track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 4px;
    margin-top: -2px;
    background: #ddd;
    border-radius: 2px;
    pointer-events: none;
}

.reso-slider-fill {
    position: absolute;
    height: 100%;
    background: #0073aa;
    border-radius: 2px;
}

/* Two range inputs layered over each other */
.reso-slider-handle {
    position: absolute;
    width: 100%;
    top: 0;
    height: 100%;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
    pointer-events: none;
    outline: none;
}

.reso-slider-handle::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #0073aa;
    border: 2px solid #fff;
    box-shadow: 0 1px 5px rgba(0,0,0,.3);
    pointer-events: all;
    cursor: pointer;
    position: relative;
    z-index: 2;
}

.reso-slider-handle::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #0073aa;
    border: 2px solid #fff;
    box-shadow: 0 1px 5px rgba(0,0,0,.3);
    pointer-events: all;
    cursor: pointer;
}

.reso-slider-handle:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px rgba(0,115,170,0.25);
}

.reso-slider-handle:focus::-moz-range-thumb {
    box-shadow: 0 0 0 3px rgba(0,115,170,0.25);
}

/* Labels below the slider */
.reso-range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75em;
    color: #666;
    padding: 0 4px;
    min-height: 1.2em;
    margin-top: 2px;
}

/* ── Chip / multi-select input ───────────────────────────────────────────── */

.reso-chip-input-wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    min-height: 36px;
    cursor: text;
    box-sizing: border-box;
    width: 100%;
    transition: border-color 0.15s;
}

.reso-chip-input-wrap:focus-within {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0,115,170,0.15);
    outline: none;
}

.reso-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.reso-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #e5f3fb;
    border: 1px solid #72aee6;
    border-radius: 12px;
    padding: 2px 8px 2px 10px;
    font-size: 0.82em;
    color: #0073aa;
    white-space: nowrap;
    line-height: 1.5;
}

.reso-chip-remove {
    background: none;
    border: none;
    color: #0073aa;
    cursor: pointer;
    font-size: 1.1em;
    line-height: 1;
    padding: 0;
    opacity: 0.65;
    display: flex;
    align-items: center;
}

.reso-chip-remove:hover {
    opacity: 1;
}

.reso-chip-text-input {
    border: none;
    outline: none;
    flex: 1;
    min-width: 80px;
    font-size: 0.9em;
    padding: 2px 0;
    background: transparent;
    color: #23282d;
}

/* Responsive */
@media ( max-width: 600px ) {
    .reso-search-form {
        padding: 16px;
    }
    .reso-field-groups {
        flex-direction: column;
    }
    .reso-form-actions {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ── Multi-select checkbox group ─────────────────────────────────────────── */
.reso-field-checkboxes .reso-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 6px;
}
.reso-checkbox-option {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 0.9em;
    color: #23282d;
    white-space: nowrap;
}
.reso-checkbox-option input[type="checkbox"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: #0073aa;
    margin: 0;
}
.reso-no-options-notice {
    font-size: 0.82em;
    color: #888;
    font-style: italic;
    margin: 4px 0 0;
}

/* ── Dropdown-chips multi-select ─────────────────────────────────────────── */

.reso-dropdown-chips-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Hide chips area until at least one chip exists */
.reso-chips--dropdown:empty {
    display: none;
}

/* Reuse .reso-chip styles — chips--dropdown just needs its own spacing */
.reso-chips--dropdown {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.reso-dropdown-select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    font-size: 0.9em;
    color: #23282d;
    cursor: pointer;
    box-sizing: border-box;
    transition: border-color 0.15s;
    -webkit-appearance: auto;
    appearance: auto;
}

.reso-dropdown-select:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0,115,170,0.15);
    outline: none;
}

.reso-dropdown-select option:disabled {
    color: #bbb;
}

/* ── Inline-then-modal: pre-search state ──────────────────────────────── */

/* Hide the toggle bar until the first search transitions us to modal mode */
.reso-pre-search-mode .reso-filter-bar {
    display: none;
}

/* The inline panel is always fully open in pre-search mode */
.reso-pre-search-mode .reso-inline-panel {
    grid-template-rows: 1fr;
}

/* ── Filter toggle bar ─────────────────────────────────────────────────── */

.reso-filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.reso-filter-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid #0073aa;
    color: #0073aa;
    padding: 5px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
}

.reso-filter-toggle-btn:hover {
    background: #0073aa;
    color: #fff;
}

.reso-filter-chevron {
    width: 16px;
    height: 16px;
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.reso-filters-collapsed .reso-filter-chevron {
    transform: rotate(-90deg);
}

.reso-filter-summary-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.reso-active-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fff8e1;
    border: 1px solid #f9a825;
    color: #5d4037;
    padding: 2px 6px 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
}

/* Close (×) button on active-filter summary chips */
.reso-chip-dismiss {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: #7b4f00;
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
}

.reso-chip-dismiss:hover {
    color: #b71c1c;
    background: rgba(183, 28, 28, 0.1);
}

/* ── Accordion collapse (CSS grid-row trick for smooth height animation) ── */

.reso-filter-panel-wrap {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.3s ease;
}

.reso-filter-panel-wrap > * {
    overflow: hidden;
}

.reso-filters-collapsed[data-filter-expand-style="accordion"] .reso-filter-panel-wrap {
    grid-template-rows: 0fr;
}

/* ── Filter modal overlay ──────────────────────────────────────────────── */

.reso-filter-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 99998;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px 16px;
    overflow-y: auto;
}

.reso-filter-modal-overlay[hidden] {
    display: none;
}

.reso-filter-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
}

.reso-filter-modal-inner {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 56px);
}

.reso-filter-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #e5e5e5;
    flex-shrink: 0;
}

.reso-filter-modal-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.reso-filter-modal-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    color: #666;
    padding: 2px 6px;
}

.reso-filter-modal-close:hover {
    color: #000;
}

.reso-filter-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Inside modal: the search form's bg/border is redundant — flatten it */
.reso-filter-modal-body .reso-search-form {
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
    margin-bottom: 0;
}

/* ── Results page toolbar ──────────────────────────────────────────────── */

.reso-results-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0 12px;
    border-bottom: 1px solid #e5e5e5;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.reso-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.reso-open-filter-modal-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #0073aa;
    color: #fff;
    border: none;
    padding: 7px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.15s;
}

.reso-open-filter-modal-btn:hover {
    background: #005177;
}

.reso-active-filter-badge {
    background: #fff;
    color: #0073aa;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
