/* Swiss Flats Search Widget Styles - Enhanced Version */
:root {
    --sfs-primary: #ef4444;
    --sfs-primary-hover: #dc2626;
    --sfs-white: #ffffff;
    --sfs-gray-50: #f9fafb;
    --sfs-gray-100: #f3f4f6;
    --sfs-gray-200: #e5e7eb;
    --sfs-gray-300: #d1d5db;
    --sfs-gray-500: #6b7280;
    --sfs-gray-700: #374151;
    --sfs-gray-900: #111827;
    --sfs-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --sfs-shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --sfs-chatbox-opacity: 0.98;
    --sfs-selection-color: #fef3c7; /* Light yellow for selection */
    --sfs-selection-border: #f59e0b; /* Orange border for selection */
}

/* Rule to freeze background scrolling */
body.sfs-modal-open {
    overflow: hidden;
}

/* Dark theme support */
[data-theme="dark"] {
    --sfs-white: #1f2937;
    --sfs-gray-50: #374151;
    --sfs-gray-100: #4b5563;
    --sfs-gray-200: #6b7280;
    --sfs-gray-500: #d1d5db;
    --sfs-gray-900: #f9fafb;
    --sfs-selection-color: #451a03;
    --sfs-selection-border: #f59e0b;
}

#floating-tray {
    position: fixed;
    z-index: 999999;
    bottom: 24px;
    right: 24px;
}

.sfs-tray-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--sfs-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--sfs-shadow-lg);
    transition: all 0.3s ease;
    position: relative;
    overflow: visible; /* Allow waves to show outside button */
}

/* Animated waves effect */
.sfs-tray-btn::before,
.sfs-tray-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border: 2px solid var(--sfs-primary);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: sfsWaveAnimation 2s infinite ease-out;
    opacity: 0;
    pointer-events: none;
}

.sfs-tray-btn::after {
    animation-delay: 1s; /* Second wave starts 1 second later */
}

@keyframes sfsWaveAnimation {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }
    50% {
        opacity: 0.4;
    }
    100% {
        transform: translate(-50%, -50%) scale(2.5);
        opacity: 0;
    }
}

.sfs-tray-btn:hover {
    background: var(--sfs-primary-hover);
    transform: translateY(-3px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.15);
}

.search-icon {
    width: 300px !important;
    height: 300px !important;
    color: white;
}

#chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    transition: all 0.3s ease;
}

#chat-overlay.hidden {
    display: none;
}

#chat-popup {
    background: var(--sfs-white);
    border-radius: 16px;
    box-shadow: var(--sfs-shadow-lg);
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: var(--sfs-chatbox-opacity);
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center center;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Taller modal on desktop */
@media (min-width: 1024px) {
    #chat-popup {
        max-height: 92vh;
    }
    #search-view {
        height: 700px;
    }
}

/* Modal Minimization Animation */
#chat-popup.sfs-minimizing {
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center center;
    z-index: 1000001;
}

@keyframes slideUp {
    from {
        transform: translateY(30px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: var(--sfs-chatbox-opacity);
    }
}

#chat-header {
    background: var(--sfs-primary);
    color: var(--sfs-white);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

#chat-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

#close-chat-btn {
    background: none;
    border: none;
    color: var(--sfs-white);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

#close-chat-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

#search-view {
    position: relative;
    height: 600px;
    overflow: hidden;
    flex: 1;
}

#search-filters-panel {
    padding: 24px;
    height: 100%;
    overflow-y: auto;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#search-view.show-results #search-filters-panel {
    transform: translateX(-100%);
}

.filter-card {
    margin-bottom: 20px;
}

.filter-label {
    display: block;
    font-weight: 600;
    color: var(--sfs-gray-700);
    margin-bottom: 8px;
    font-size: 14px;
}

.filter-select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--sfs-gray-300);
    border-radius: 8px;
    font-size: 16px;
    background: var(--sfs-white);
    color: var(--sfs-gray-900);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-select:focus {
    outline: none;
    border-color: var(--sfs-primary);
    box-shadow: 0 0 0 3px rgba(var(--sfs-primary-rgb), 0.2);
}

.filter-select:disabled {
    background: var(--sfs-gray-100);
    color: var(--sfs-gray-500);
    cursor: not-allowed;
}

#perform-search-btn {
    width: 100%;
    background: var(--sfs-primary);
    color: var(--sfs-white);
    border: none;
    padding: 16px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}

#perform-search-btn:hover {
    background: var(--sfs-primary-hover);
    transform: translateY(-1px);
}

#search-results-panel {
    position: absolute;
    top: 0;
    left: 100%;
    width: 100%;
    height: 100%;
    background: var(--sfs-white);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

#search-view.show-results #search-results-panel {
    transform: translateX(-100%);
}

#search-results-header {
    display: flex;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--sfs-gray-200);
    background: var(--sfs-gray-50);
    flex-shrink: 0;
    justify-content: space-between;
}

#back-to-filters-btn {
    background: none;
    border: none;
    color: var(--sfs-gray-700);
    cursor: pointer;
    padding: 8px;
    margin-right: 12px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

#back-to-filters-btn:hover {
    background: var(--sfs-gray-200);
}

#search-results-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--sfs-gray-900);
    flex: 1;
}

#new-search-btn {
    background: var(--sfs-primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#new-search-btn:hover {
    background: var(--sfs-primary-hover);
    transform: translateY(-1px);
}

#search-results-list {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    scroll-behavior: smooth;
}

.sfa-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--sfs-gray-200);
    border-top: 3px solid var(--sfs-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.placeholder {
    color: var(--sfs-gray-500);
    font-size: 14px;
    margin: 0;
}

/* Enhanced Listing Cards with Selection Support */
.listing-card-search {
    display: flex;
    background: var(--sfs-white);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    border: 2px solid var(--sfs-gray-200);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    cursor: pointer;
}

.listing-card-search:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    border-color: var(--sfs-gray-300);
    text-decoration: none;
    color: inherit;
}

/* Selected Property Highlighting */
.listing-card-search.sfs-selected-property {
    background: var(--sfs-selection-color);
    border-color: var(--sfs-selection-border);
    box-shadow: 0 8px 25px rgba(245, 158, 11, 0.2);
    transform: translateY(-2px);
}

.listing-card-search.sfs-selected-property:hover {
    transform: translateY(-7px);
    box-shadow: 0 12px 30px rgba(245, 158, 11, 0.3);
}

/* Selection indicator */
.listing-card-search.sfs-selected-property::before {
    content: '✓';
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--sfs-selection-border);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    z-index: 10;
    animation: checkmarkPulse 0.3s ease-out;
}

@keyframes checkmarkPulse {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.listing-card-search-image {
    width: 40%;
    height: 160px;
    flex-shrink: 0;
    position: relative;
    background-color: var(--sfs-gray-100);
}

.listing-card-search-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.listing-card-search:hover .listing-card-search-image img {
    transform: scale(1.05);
}

.listing-card-search-price {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
}

.listing-card-search-info {
    padding: 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.listing-card-search-type {
    color: var(--sfs-primary);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 8px 0;
}

.listing-card-search-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--sfs-gray-900);
    margin: 0 0 12px 0;
    line-height: 1.3;
}

.listing-card-search-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 8px;
}

.listing-card-search-meta span {
    font-size: 13px;
    color: var(--sfs-gray-600);
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--sfs-gray-100);
    padding: 4px 8px;
    border-radius: 4px;
}

.listing-card-location {
    color: var(--sfs-primary) !important;
    font-weight: 500;
}

/* Loading Overlay Styles */
#sfs-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000002;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

#sfs-loading-overlay.sfs-loading-visible {
    opacity: 1;
    visibility: visible;
}

.sfs-loading-content {
    text-align: center;
    color: white;
    max-width: 300px;
    padding: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.sfs-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid var(--sfs-primary);
    border-radius: 50%;
    animation: sfsLoadingSpin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes sfsLoadingSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.sfs-loading-text {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: white;
}

.sfs-loading-subtext {
    font-size: 14px;
    margin: 0;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.4;
}

body.sfs-loading-active {
    overflow: hidden;
}

/* Mobile Responsive */
@media (max-width: 640px) {
    #floating-tray {
        bottom: 16px;
        right: 16px;
    }
    
    .sfs-tray-btn {
        width: 156px;
        height: 156px;
        overflow: visible !important; /* Force visible overflow */
    }
    
    .search-icon {
        width: 24px;
        height: 24px;
    }
    
    #chat-popup {
        width: 95%;
        max-height: 80vh; /* Shorter modal on mobile */
        margin: 16px;
    }
    
    #search-view {
        height: 500px; /* Reduced height for mobile */
    }
    
    #chat-header {
        padding: 16px 20px;
    }
    
    #chat-header h3 {
        font-size: 16px;
    }
    
    #search-filters-panel {
        padding: 20px;
    }
    
    #search-results-header {
        padding: 16px 20px;
    }
    
    #search-results-list {
        padding: 12px;
    }
    
    /* Compact listing cards on mobile */
    .listing-card-search {
        flex-direction: row;
        height: 160px;
        margin-bottom: 12px;
    }
    
    .listing-card-search-image {
        width: 35%;
        height: 100%;
    }
    
    .listing-card-search-info {
        padding: 12px;
        overflow: hidden;
    }
    
    .listing-card-search-title {
        font-size: 11px;
        margin-bottom: 6px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .listing-card-search-type {
        font-size: 10px;
        margin-bottom: 4px;
    }
    
    .listing-card-search-meta {
        gap: 4px;
        margin-bottom: 4px;
    }
    
    .listing-card-search-meta span {
        font-size: 10px;
        padding: 2px 4px;
    }
    
    .listing-card-search-price {
        font-size: 12px;
        padding: 4px 8px;
        bottom: 8px;
        left: 8px;
    }
}

/* Additional optimization for very small screens */
@media (max-width: 400px) {
    .listing-card-search {
        height: 120px;
    }
    
    .listing-card-search-info {
        padding: 8px;
    }
    
    .listing-card-search-title {
        font-size: 11px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .filter-select {
        border-width: 3px;
    }
    
    .listing-card-search {
        border-width: 3px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    #chat-popup.sfs-minimizing {
        transition: none !important;
    }
}




/* Add !important to override any inline styles */
.sfs-tray-btn .search-icon {
    width: 10px !important;
    height: 10px !important;
    min-width: 30px !important;
    min-height: 30px !important;
}

/* Disable any transforms that might be affecting size */
.sfs-tray-btn .search-icon {
    transform: none !important;
}


@media (max-width: 640px) {
  .sfs-tray-btn {
    width: 80px;              /* Adjust mobile size */
    height: 80px;             /* Must match width */
    border-radius: 50% !important; /* Force circle shape */
    overflow: visible !important; /* Ensure waves aren't clipped */
  }

  /* Fix for potential parent interference */
  #floating-tray {
    min-width: auto !important;
    min-height: auto !important;
    padding: 0 !important;
  }
}