/* =============================================
   CARD-BASED SEARCH UI
   ============================================= */

/* Override parent container - search on top */
@media (max-width: 768px) {
    #results .container {
        display: flex !important;
        flex-direction: column !important;
    }
    .colLeft.listingRightCol {
        width: 100% !important;
        float: none !important;
        padding: 0 !important;
        margin: 0 !important;
        order: -1 !important;
    }
    .colRight {
        width: 100% !important;
        float: none !important;
        order: 1 !important;
    }
    #searchModule { margin-bottom: 10px; }
    .searchModuleLinkMobile { display: none !important; }
}

/* -------------------------
   SEARCH HEADER
   ------------------------- */

.search-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px 12px 0 0;
    padding: 10px 16px;
    color: #fff;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.search-header-title {
    font-size: 14px;
    font-weight: 500;
    color: #fff;
}

.search-header-title i {
    font-size: 12px;
    margin-right: 4px;
    opacity: 0.8;
}

.header-clear-btn {
    background: #fff;
    border: none;
    color: #764ba2;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-clear-btn:hover {
    background: #f0f0f0;
}

/* -------------------------
   SEARCH CARD
   ------------------------- */

.search-card {
    background: #fff;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    padding: 20px;
    box-sizing: border-box;
    overflow: hidden;
}

#searchModule {
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

/* -------------------------
   LOCATION SECTION
   ------------------------- */

.location-section {
    border: 2px dashed #d0d5e0;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
    box-sizing: border-box;
}

.location-section-title {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 12px;
}

.location-cards {
    display: flex;
    gap: 10px;
}

.loc-card {
    flex: 1;
    background: #f8f9fc;
    border: 1px solid #e0e1e6;
    border-radius: 8px;
    padding: 14px 12px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
}

.loc-card:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.loc-card.has-selection {
    border-color: #667eea;
    background: #f0f4ff;
}

.loc-card-icon {
    font-size: 20px;
    color: #667eea;
    margin-bottom: 6px;
}

.loc-card-label {
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
}

.loc-card-value {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* -------------------------
   CATEGORY PILLS
   ------------------------- */

.category-section {
    margin-bottom: 16px;
}

.category-section-title {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 10px;
}

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

.cat-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid #e0e1e6;
    border-radius: 20px;
    background: #f8f9fc;
    font-size: 13px;
    color: #555;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.cat-pill:hover {
    border-color: #667eea;
    background: #f0f4ff;
    color: #667eea;
}

.cat-pill.selected {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: transparent;
    color: #fff;
}

.cat-pill-emoji {
    font-size: 15px;
}

/* -------------------------
   INLINE PRICE & NO INPUTS
   ------------------------- */

.inline-inputs-row {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    box-sizing: border-box;
}

.input-group {
    flex: 1;
    min-width: 120px;
}

.input-group label {
    display: block;
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
    font-weight: 500;
}

.search-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e0e1e6;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
    background: #f8f9fc;
}

.search-input:focus {
    border-color: #667eea;
    background: #fff;
}

.search-input::placeholder {
    color: #aaa;
}

/* -------------------------
   SEARCH & CLEAR BUTTONS
   ------------------------- */

.search-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.search-btn {
    flex: 1;
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.search-btn:hover {
    opacity: 0.9;
}

.clear-btn {
    padding: 12px 20px;
    background: #fff;
    color: #666;
    border: 1px solid #e0e1e6;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.clear-btn:hover {
    border-color: #ff4757;
    color: #ff4757;
}

/* -------------------------
   CONNECTIONS DROPDOWN
   ------------------------- */

.connections-dropdown-wrapper {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.connections-dropdown-wrapper select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e0e1e6;
    border-radius: 8px;
    font-size: 14px;
    background: #f8f9fc;
    outline: none;
    cursor: pointer;
}

.connections-dropdown-wrapper select:focus {
    border-color: #667eea;
}

/* -------------------------
   LOCATION MODAL
   ------------------------- */

.loc-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}

.loc-modal-overlay.active {
    display: flex;
}

.loc-modal {
    background: #fff;
    border-radius: 14px;
    width: 420px;
    max-width: 95vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    animation: modalFadeIn 0.25s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.loc-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.loc-modal-header h3 {
    margin: 0;
    font-size: 16px;
    color: #333;
}

.loc-modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 4px;
}

.loc-modal-close:hover {
    color: #333;
}

.loc-modal-search {
    padding: 12px 20px;
}

.loc-modal-search input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e0e1e6;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
}

.loc-modal-search input:focus {
    border-color: #667eea;
}

.loc-modal-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px;
    max-height: 350px;
}

.modal-item {
    padding: 12px 14px;
    margin: 4px 0;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.15s ease;
    font-size: 14px;
    color: #333;
}

.modal-item:hover {
    background: #f5f7ff;
}

.modal-item.selected {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.modal-item-check {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #d0d0d0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.modal-item.selected .modal-item-check {
    background: #4CAF50;
    border-color: #4CAF50;
}

.modal-item.selected .modal-item-check::after {
    content: '';
    width: 10px;
    height: 10px;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

.loc-modal-empty {
    padding: 30px 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

.loc-modal-footer {
    padding: 14px 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-clear-btn {
    padding: 10px 20px;
    background: #fff;
    border: 1px solid #e0e1e6;
    border-radius: 8px;
    font-size: 14px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-clear-btn:hover {
    border-color: #ff4757;
    color: #ff4757;
}

.modal-apply-btn {
    padding: 10px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.modal-apply-btn:hover {
    opacity: 0.9;
}

/* -------------------------
   NO RESULTS STATE
   ------------------------- */

.no-results {
    text-align: center;
    padding: 60px 20px;
}

.no-results i {
    font-size: 48px;
    color: #d0d5e0;
    margin-bottom: 16px;
}

.no-results h3 {
    font-size: 18px;
    color: #555;
    margin: 0 0 8px 0;
}

.no-results p {
    font-size: 14px;
    color: #999;
    margin: 0;
}

/* -------------------------
   LOADING
   ------------------------- */

.search-loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    z-index: 9999;
    overflow: hidden;
}

.search-loading-indicator.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, #667eea, transparent);
    animation: loading-bar 1s infinite;
}

@keyframes loading-bar {
    0% { left: -100%; }
    100% { left: 100%; }
}

.listingBoxes {
    transition: opacity 0.3s ease;
}

.listingBoxes.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* -------------------------
   RESPONSIVE
   ------------------------- */

@media (max-width: 992px) {
    .search-header { padding: 8px 14px; }
    .search-header-title { font-size: 13px; }
    .search-card { padding: 16px; }
    .location-section { padding: 12px; }
    .location-cards { gap: 8px; }
    .loc-card { padding: 12px 10px; }
}

/* --- Mobile: collapsible search + compact layout --- */

.search-mobile-header {
    display: none;
}

.search-toggle-btn {
    display: none;
}

.mobile-clear-btn {
    display: none;
}

@media (max-width: 768px) {
    .search-mobile-header {
        display: flex;
        align-items: center;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }

    /* Collapsible toggle button */
    .search-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex: 1;
        background: none;
        color: #fff;
        border: none;
        padding: 12px 16px;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
    }
    .search-toggle-btn i.toggle-arrow {
        transition: transform 0.3s ease;
    }
    .search-toggle-btn.collapsed i.toggle-arrow {
        transform: rotate(180deg);
    }

    .mobile-clear-btn {
        display: flex;
        align-items: center;
        gap: 4px;
        background: #fff;
        border: none;
        color: #764ba2;
        padding: 5px 12px;
        margin-right: 12px;
        border-radius: 4px;
        font-size: 12px;
        font-weight: 600;
        cursor: pointer;
        white-space: nowrap;
    }

    .mobile-clear-btn:hover {
        background: #f0f0f0;
    }

    /* Hide the desktop header on mobile */
    .search-header {
        display: none;
    }

    .search-card {
        border-radius: 0;
        padding: 10px 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    }

    /* Collapsible body */
    .search-card.collapsed {
        display: none;
    }

    /* Compact location section */
    .location-section {
        padding: 8px;
        margin-bottom: 10px;
        border-width: 1px;
    }
    .location-section-title {
        font-size: 12px;
        margin-bottom: 8px;
    }
    .location-cards {
        gap: 6px;
    }
    .loc-card {
        padding: 8px 6px;
    }
    .loc-card-icon {
        font-size: 16px;
        margin-bottom: 2px;
    }
    .loc-card-label {
        font-size: 10px;
        margin-bottom: 2px;
    }
    .loc-card-value {
        font-size: 11px;
    }

    /* Category pills: horizontal scroll */
    .category-section {
        margin-bottom: 10px;
    }
    .category-section-title {
        font-size: 12px;
        margin-bottom: 6px;
    }
    .category-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 6px;
        padding-bottom: 2px;
    }
    .category-pills::-webkit-scrollbar { display: none; }
    .cat-pill {
        flex: 0 0 auto;
        padding: 6px 10px;
        font-size: 12px;
    }
    .cat-pill-emoji { font-size: 13px; }

    /* Inputs: price side by side, no below */
    .inline-inputs-row {
        gap: 6px;
        margin-bottom: 10px;
    }
    .input-group {
        min-width: 0;
    }
    .input-group label {
        font-size: 11px;
        margin-bottom: 2px;
    }
    .search-input {
        padding: 8px 10px;
        font-size: 13px;
    }

    /* Buttons side by side */
    .search-actions {
        gap: 8px;
        margin-top: 0;
    }
    .search-btn {
        padding: 10px 16px;
        font-size: 14px;
    }
    .clear-btn {
        padding: 10px 16px;
        font-size: 13px;
    }

    /* Connections compact */
    .connections-dropdown-wrapper {
        margin-top: 8px;
        padding-top: 8px;
    }

    /* Modal full screen on mobile */
    .loc-modal {
        width: 100%;
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        height: 100vh;
    }
    .loc-modal-list { max-height: none; flex: 1; }
}

@media (max-width: 480px) {
    .loc-card { padding: 6px 4px; }
    .loc-card-icon { font-size: 14px; }
    .loc-card-label { font-size: 9px; }
    .loc-card-value { font-size: 10px; }
    .cat-pill { padding: 5px 8px; font-size: 11px; }
    .cat-pill-emoji { font-size: 12px; }
    .search-input { padding: 7px 8px; font-size: 12px; }
    .input-group label { font-size: 10px; }
}
