/* =================================================================
   FINAL STYLESHEET with Polished Search Form
   ================================================================= */

/* --- Global & Core --- */
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
.hidden { display: none !important; }

/* --- Floating Tray Placement Classes --- */
#floating-tray { position: fixed; z-index: 999; display: flex; gap: 8px; background-color: rgba(255, 255, 255, 0.85); backdrop-filter: blur(10px); padding: 8px; border-radius: 50px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); border: 1px solid rgba(0,0,0,0.05); }
#floating-tray.position-bottom-right { bottom: 20px; right: 20px; }
#floating-tray.position-top-center { top: 20px; left: 50%; transform: translateX(-50%); }
#floating-tray.position-top-left { top: 20px; left: 20px; }
.action-btn { width: 48px; height: 48px; border-radius: 50%; background-color: #f0f2f5; display: flex; justify-content: center; align-items: center; cursor: pointer; border: none; }
.action-btn:hover { background-color: #e4e6eb; }
.action-btn svg, .action-btn .custom-icon { width: 22px; height: 22px; }

/* --- Main Chat Pop-up --- */
#chat-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.6); backdrop-filter: blur(8px); display: flex; justify-content: center; align-items: center; z-index: 1000; padding: 20px; }
#chat-popup { background: #f9fafb; border-radius: 16px; width: 100%; max-width: 520px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); display: flex; flex-direction: column; overflow: hidden; height: 80vh; max-height: 720px; }
#chat-header { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid #e5e7eb; background: #fff; flex-shrink: 0; }
#agent-avatar { width: 40px; height: 40px; border-radius: 50%; margin-right: 12px; object-fit: cover; }
#header-title-area { flex-grow: 1; }
#chat-title { font-weight: 600; font-size: 1.1em; color: #111827; }
#close-chat-btn { background: #f0f2f5; border-radius: 50%; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border: none; cursor: pointer; color: #6b7280; }
#chat-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* --- Search View & Slide Animation --- */
#search-view { position: relative; overflow: hidden; flex: 1; }
#search-filters-panel, #search-results-panel { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; flex-direction: column; overflow-y: auto; transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1); background-color: #f9fafb; }
#search-results-panel { transform: translateX(100%); padding: 0; }
#search-view.show-results #search-filters-panel { transform: translateX(-100%); }
#search-view.show-results #search-results-panel { transform: translateX(0); }

/* --- NEW: Polished Search Filters Layout --- */
#search-filters-panel {
    padding: 24px;
    justify-content: space-between; /* Pushes button to bottom on mobile */
}
#search-filters-container {
    display: flex;
    flex-direction: column; /* Mobile-first: stacked */
    gap: 16px;
}
.filter-card { flex-grow: 1; }
.filter-label { display: block; font-weight: 500; font-size: 0.9em; margin-bottom: 8px; color: #6b7280; }
.filter-select { width: 100%; padding: 12px 16px; border-radius: 8px; border: 1px solid #d1d5db; background-color: #fff; font-size: 1em; -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 0.7rem center; background-size: 1.5em 1.5em; }
#perform-search-btn {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 16px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    width: 100%; /* Full width on mobile */
    margin-top: 24px; /* Space above button */
}

/* Desktop layout: makes filters and button a single row */
@media (min-width: 768px) {
    #search-filters-panel {
        flex-direction: row;
        align-items: flex-end; /* Align items to the bottom */
        gap: 16px;
    }
    #search-filters-container {
        flex-direction: row;
        flex-grow: 1; /* Allows filter cards to take up available space */
    }
    #perform-search-btn {
        margin-top: 0;
        width: auto; /* Let the button size to its content */
        flex-shrink: 0; /* Prevent button from shrinking */
        padding-left: 30px;
        padding-right: 30px;
    }
}

/* --- Search Results & Cards --- */
#search-results-header { display: flex; align-items: center; gap: 15px; padding: 16px 20px; border-bottom: 1px solid #e5e7eb; background: #fff; }
#back-to-filters-btn { background: #e5e7eb; border: none; border-radius: 50%; width: 36px; height: 36px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
#search-results-list { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.listing-card-search { display: flex; gap: 12px; padding: 10px; background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; text-decoration: none; color: inherit; }
.listing-card-search img { width: 70px; height: 70px; border-radius: 6px; object-fit: cover; }
.listing-card-search-info { font-weight: 600; }
#search-results-list .placeholder { text-align: center; padding: 40px; color: #9ca3af; }

/* --- Chat View --- */
#chat-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#chat-messages { flex: 1; overflow-y: auto; padding: 20px; }
#chat-input-container { padding: 8px 16px 16px 16px; border-top: 1px solid #e5e7eb; }
#chat-input { width: 100%; padding: 12px 16px; border-radius: 25px; border: 1px solid #d1d5db; }