/* Swiss Flats Search Widget Styles */
: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: 1; /* MODIFIED: Reduced transparency */
}

/* NEW: 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;
}

#floating-tray {
    position: fixed;
    z-index: 999999;
    bottom: 24px;
    right: 24px;
}

.sfs-tray-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sfs-primary);
    border: none;
    box-shadow: var(--sfs-shadow);
    cursor: pointer;
    transition: all 0.3s ease;
}

.sfs-tray-btn:hover {
    background: var(--sfs-primary-hover);
    transform: translateY(-4px) scale(1.05);
    box-shadow: var(--sfs-shadow-lg);
}

.sfs-tray-btn .search-icon {
    width: 28px;
    height: 28px;
    color: white;
}

#chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    transition: opacity 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);
}

@keyframes slideUp {
    from {
        transform: translateY(30px) scale(0.98);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: var(--sfs-chatbox-opacity);
    }
}

#chat-header {
    background: var(--sfs-primary);
    color: var(--sfs-white);
    padding: 16px 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: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    line-height: 32px;
    text-align: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

#close-chat-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

#search-view {
    position: relative;
    height: 550px;
    overflow: hidden;
    flex-grow: 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: background-color 0.2s, transform 0.2s;
    margin-top: 8px;
}

#perform-search-btn:hover {
    background: var(--sfs-primary-hover);
    transform: translateY(-2px);
}

#search-results-panel {
    position: absolute;
    top: 0;
    left: 100%;
    width: 100%;
    height: 100%;
    background: var(--sfs-gray-50);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

#search-view.show-results #search-results-panel {
    transform: translateX(-100%);
}

#search-results-header {
    display: flex;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--sfs-gray-200);
    background: var(--sfs-white);
    position: sticky;
    top: 0;
    z-index: 10;
}

#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);
}

#search-results-list {
    padding: 24px;
}

.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;
}

/* MODIFIED: Increased box-shadow for more depth */
.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: 1px solid var(--sfs-gray-200);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08); /* MODIFIED SHADOW */
}

.listing-card-search:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1); /* MODIFIED HOVER SHADOW */
    border-color: var(--sfs-gray-300);
    text-decoration: none;
    color: inherit;
}

.listing-card-search-image {
    width: 40%;
    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-info {
    padding: 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.listing-card-search-type {
    font-size: 12px;
    font-weight: 600;
    color: var(--sfs-primary);
    text-transform: uppercase;
    margin: 0 0 4px 0;
}

.listing-card-search-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--sfs-gray-900);
    margin: 0 0 16px 0;
    line-height: 1.3;
}

.listing-card-search-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-bottom: 12px;
    align-items: center;
}

.listing-card-search-meta span {
    font-size: 14px;
    color: var(--sfs-gray-700);
    display: flex;
    align-items: center;
    gap: 8px;
}

.listing-card-location {
    width: 100%;
    margin-top: 8px;
}

.listing-card-search-price {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background-color: rgba(17, 24, 39, 0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 700;
    z-index: 1;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.1);
}

@media (max-width: 768px) {
    #chat-popup {
        max-height: 75vh;
    }
    #search-view {
        height: calc(75vh - 57px); /* Adjust height based on header */
    }
    .listing-card-search {
        flex-direction: column;
    }
    .listing-card-search-image {
        width: 100%;
        height: 180px;
    }
    .listing-card-search-info {
        padding: 16px;
    }
    .listing-card-search-title {
        font-size: 16px;
        margin-bottom: 12px;
    }
    .listing-card-search-meta {
        gap: 10px;
    }
    .listing-card-search-meta span {
        font-size: 13px;
        gap: 6px;
    }
    .listing-card-search-price {
        font-size: 14px;
        padding: 5px 10px;
    }
    #search-results-list {
        padding: 16px;
    }
}