/* ============================================
   offlead Search Page Styles
   ============================================ */

/* Search Header */
.search-header {
    position: sticky;
    top: 60px; /* Below navbar */
    background: var(--white);
    border-bottom: 1px solid var(--border-grey);
    padding: 20px 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.search-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    gap: 16px;
    align-items: center;
}

/* Search Bar */
.search-bar-wrapper {
    flex: 1;
    position: relative;
    max-width: 600px;
}

.search-input-group {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--light-grey);
    border-radius: 12px;
    padding: 12px 16px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.search-input-group:focus-within {
    border-color: var(--spruce-green);
    background: var(--white);
    box-shadow: 0 4px 12px rgba(59, 124, 100, 0.15);
}

.search-icon {
    color: var(--text-grey);
    margin-right: 12px;
    flex-shrink: 0;
}

#searchInput {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px;
    color: var(--dark-grey);
    outline: none;
}

#searchInput::placeholder {
    color: var(--text-grey-light);
}

.clear-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-grey);
    transition: color 0.2s;
}

.clear-btn:hover {
    color: var(--dark-grey);
}

/* Search Suggestions */
.search-suggestions {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
}

.suggestion-group {
    padding: 8px 0;
}

.suggestion-group:not(:last-child) {
    border-bottom: 1px solid var(--border-grey);
}

.suggestion-group-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-grey);
    text-transform: uppercase;
    padding: 8px 16px;
}

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.suggestion-item:hover {
    background: var(--light-grey);
}

.suggestion-icon {
    color: var(--spruce-green);
    flex-shrink: 0;
}

.suggestion-text {
    flex: 1;
    font-size: 14px;
    color: var(--dark-grey);
}

.suggestion-count {
    font-size: 12px;
    color: var(--text-grey);
}

/* Filter Button */
.filter-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--white);
    border: 2px solid var(--border-grey);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--dark-grey);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.filter-btn:hover {
    border-color: var(--spruce-green);
    color: var(--spruce-green);
}

.filter-btn.active {
    background: var(--spruce-green);
    border-color: var(--spruce-green);
    color: var(--white);
}

.clear-filters-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.clear-filters-btn:not(:disabled):hover {
    border-color: var(--spruce-green-light);
    background: var(--spruce-green-lightest, #f0f7f4);
}

.location-badge-container {
    position: absolute;
    top: -32px;
    left: 0;
    height: 24px;
    z-index: 10;
}

.location-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--spruce-green);
    color: var(--white);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(59, 124, 100, 0.3);
}

.filter-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--spruce-green);
    color: var(--white);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

/* View Toggle */
.view-toggle {
    display: flex;
    gap: 4px;
    background: var(--light-grey);
    border-radius: 12px;
    padding: 4px;
}

.view-toggle-btn {
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-grey);
    transition: all 0.2s;
}

.view-toggle-btn:hover {
    color: var(--dark-grey);
}

.view-toggle-btn.active {
    background: var(--white);
    color: var(--spruce-green);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Hide text labels on desktop (icons only) */
.view-toggle-label {
    display: none;
}

/* Active Filters */
.active-filters {
    background: var(--light-grey);
    padding: 12px 0;
    border-bottom: 1px solid var(--border-grey);
}

.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--white);
    border: 1px solid var(--border-grey);
    border-radius: 20px;
    font-size: 14px;
    color: var(--dark-grey);
}

.filter-pill-remove {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    color: var(--text-grey);
    transition: color 0.2s;
}

.filter-pill-remove:hover {
    color: var(--dark-grey);
}

/* Search Layout */
.search-layout {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    gap: 24px;
    padding: 24px;
    min-height: calc(100vh - 200px);
}

.search-layout.view-list .map-view {
    display: none;
}

.search-layout.view-list .list-view {
    flex: 1;
}

.search-layout.view-map .list-view {
    display: none;
}

.search-layout.view-map .map-view {
    flex: 1;
}

/* List View */
.list-view {
    flex: 0 0 40%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.results-info h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--dark-grey);
}

.sort-dropdown {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sort-dropdown label {
    font-size: 14px;
    color: var(--text-grey);
    white-space: nowrap;
}

.sort-dropdown select {
    padding: 8px 12px;
    border: 1px solid var(--border-grey);
    border-radius: 8px;
    font-size: 14px;
    color: var(--dark-grey);
    background: var(--white);
    cursor: pointer;
}

/* Field Cards */
.field-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    max-height: calc(100vh - 300px);
    padding-right: 8px;
}

.field-cards::-webkit-scrollbar {
    width: 6px;
}

.field-cards::-webkit-scrollbar-track {
    background: var(--light-grey);
    border-radius: 3px;
}

.field-cards::-webkit-scrollbar-thumb {
    background: var(--text-grey-light);
    border-radius: 3px;
}

.field-cards::-webkit-scrollbar-thumb:hover {
    background: var(--text-grey);
}

.field-card {
    display: flex;
    background: var(--white);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-grey);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.field-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
    border-color: var(--spruce-green-light);
}

.field-card-image {
    position: relative;
    width: 200px;
    height: 150px;
    flex-shrink: 0;
}

.field-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.distance-badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--dark-grey);
}

.field-card-content {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark-grey);
    margin: 0;
}

.field-card-rating {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.rating-stars {
    color: #FFA500;
}

.rating-number {
    font-weight: 600;
    color: var(--dark-grey);
}

.rating-count {
    color: var(--text-grey);
}

.field-card-location {
    font-size: 14px;
    color: var(--text-grey);
}

.field-card-features {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.feature-tag {
    padding: 4px 8px;
    background: var(--light-grey);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-grey);
}

.field-card-price {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-top: auto;
}

.price-amount {
    font-size: 20px;
    font-weight: 700;
    color: var(--spruce-green);
}

.price-unit {
    font-size: 14px;
    color: var(--text-grey);
}

/* Map View */
.map-view {
    flex: 1;
    min-width: 400px; /* Prevent flex collapse to 0 width */
    position: relative;
    border-radius: 16px;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
    min-height: 600px;
    position: relative;
    z-index: 1; /* Lower than mini card */
}

.map-container {
    width: 100%;
    height: 100%;
    min-height: 600px;
    position: relative;
    z-index: 1; /* Lower than mini card */
}

.map-control {
    position: absolute;
    background: var(--white);
    border: none;
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s;
}

.map-control:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.current-location-btn {
    bottom: 24px;
    right: 24px;
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--light-grey);
    border-top-color: var(--spruce-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 20px;
    text-align: center;
}

.empty-state svg {
    color: var(--text-grey-light);
}

.empty-state h3 {
    font-size: 24px;
    font-weight: 600;
    color: var(--dark-grey);
    margin: 0;
}

.empty-state p {
    font-size: 16px;
    color: var(--text-grey);
    margin: 0;
}

/* Filter Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border-radius: 24px;
    max-width: 650px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25),
                0 8px 24px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: modalSlideUp 0.3s ease-out;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid var(--border-grey);
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--dark-grey);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    color: var(--text-grey);
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--dark-grey);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.filter-section {
    margin-bottom: 40px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--grey-200);
}

.filter-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.filter-section h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--black);
    margin: 0 0 20px 0;
    letter-spacing: -0.02em;
}

.distance-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--grey-50);
    border: 2px solid var(--grey-200);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.radio-option:hover {
    background: var(--grey-100);
    border-color: var(--spruce-green-light);
    transform: translateY(-1px);
}

.radio-option input[type="radio"]:checked + span {
    font-weight: 600;
    color: var(--spruce-green);
}

.radio-option input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--spruce-green);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.feature-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--grey-50);
    border: 2px solid var(--grey-200);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    font-size: 13px; /* Smaller font to prevent wrapping */
}

.feature-checkbox span {
    font-size: 13px; /* Ensure label text is smaller */
    line-height: 1.4;
}

.feature-checkbox:hover {
    background: var(--grey-100);
    border-color: var(--spruce-green-light);
    transform: translateY(-1px);
}

.feature-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--spruce-green);
}

.feature-checkbox.checked {
    background: var(--spruce-green-light);
    color: var(--white);
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 24px;
    border-top: 1px solid var(--border-grey);
}

.modal-footer .btn {
    flex: 1;
}

/* Mini Card Popup (Glassmorphism) - Fixed at bottom of viewport */
.mini-card-popup {
    position: fixed !important;
    bottom: 24px !important;
    left: 50% !important;
    width: 360px;
    max-width: calc(100vw - 48px);
    
    /* Glassmorphism */
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12),
                0 4px 16px rgba(0, 0, 0, 0.08);
    
    overflow: hidden;
    z-index: 999999 !important; /* Extremely high z-index to ensure visibility */
    pointer-events: auto !important; /* Allow clicks on the card */
    
    /* Hidden by default */
    display: none;
    transform: translateX(-50%) translateY(100%);
    opacity: 0;
    visibility: hidden;
}

/* Visible state with animation */
.mini-card-popup.show {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: translateX(-50%) translateY(0) !important;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100%) !important;
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0) !important;
        opacity: 1;
    }
}

[data-theme="dark"] .mini-card-popup {
    background: rgba(30, 30, 30, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.mini-card-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
}

.mini-card-close:hover {
    background: var(--white);
    transform: scale(1.1);
}

/* Mobile Responsive */
@media (max-width: 968px) {
    .search-header {
        top: 50px;
    }
    
    .search-container {
        flex-wrap: wrap;
        padding: 0 16px;
        gap: 12px;
    }
    
    .search-bar-wrapper {
        order: 1;
        flex: 1 1 100%;
        max-width: none;
    }
    
    .filter-btn {
        order: 2;
    }
    
    /* List/Map toggle: own row, full width, always visible */
    .view-toggle {
        order: 3;
        flex: 1 1 100%;
        width: 100%;
        justify-content: stretch;
        padding: 6px;
        margin-top: 4px;
        background: var(--grey-100, #f5f5f5);
        border-radius: 12px;
    }
    
    .view-toggle-btn {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 12px 16px;
        min-height: 44px;
        font-size: 15px;
        font-weight: 600;
    }
    
    .view-toggle-btn .view-toggle-label {
        display: inline;
    }
    
    /* Hide Split on mobile – only List and Map */
    .view-toggle-btn[data-view="split"] {
        display: none;
    }
    
    .search-layout {
        flex-direction: column;
        padding: 16px;
    }
    
    .list-view {
        flex: 1;
    }
    
    .list-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .field-card {
        flex-direction: column;
    }
    
    .field-card-image {
        width: 100%;
        height: 200px;
    }
    
    /* Map in flow on mobile – no full-screen overlay; header stays normal at top */
    .map-view {
        position: relative;
        width: 100%;
        height: 60vh;
        min-height: 320px;
        border-radius: 0;
        z-index: 1;
    }
    
    .map-view .map-container,
    .map-view #map {
        height: 100%;
        min-height: 0;
    }
    
    .search-layout.view-split .map-view {
        display: none;
    }
    
    /* No floating overlay controls – header is the toggle */
    .search-layout.view-map .map-view-close,
    .search-layout.view-map .view-toggle-mobile {
        display: none !important;
    }
    
    .mini-card-popup {
        width: calc(100vw - 32px);
        max-width: calc(100% - 32px);
        bottom: 16px;
    }
}

