/**
 * Custom Provider Search Styles
 */

.cps-search-container,
.cps-elementor-widget {
    max-width: 1200px;
    margin: 40px auto;
    padding: 20px;
}

.search-wrapper h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
}

.search-form {
    background: #f9f9f9;
    padding: 30px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.search-fields-wrapper {
    display: flex !important;
    flex-direction: row !important;
    gap: 15px !important;
    align-items: flex-end !important;
    flex-wrap: nowrap !important;
    width: 100%;
}

.search-field-group {
    display: flex !important;
    flex-direction: column !important;
    gap: 5px !important;
    flex: 1 1 auto !important;
    min-width: 0;
    max-width: none;
    position: relative;
    align-items: stretch;
}

.search-field-group label {
    font-weight: 600;
    color: #333;
    font-size: 14px;
    margin-bottom: 5px;
    white-space: nowrap;
    display: block;
}

.search-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-button-wrapper {
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: flex-end !important;
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
    min-width: auto;
}

.search-button-wrapper .search-button {
    white-space: nowrap;
    margin-bottom: 0;
    padding: 15px 30px;
    min-height: 50px;
    box-sizing: border-box;
}

.search-input {
    width: 100%;
    padding: 15px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 4px;
    transition: border-color 0.3s;
    box-sizing: border-box;
    min-height: 50px;
    line-height: 1.5;
    position: relative;
    z-index: 1;
}

.search-input:focus {
    outline: none;
    border-color: #0073aa;
}

.search-button {
    padding: 15px 30px;
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.search-button:hover {
    background: #005a87;
}

/* Sidebar filters layout */
.cps-search-container.cps-with-sidebar .cps-search-layout {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
    align-items: flex-start;
}

.cps-filters-sidebar {
    flex-shrink: 0;
    width: 260px;
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.cps-filters-title,
.cps-filters-sidebar .cps-filter-group:first-of-type {
    margin-top: 0;
}

.cps-filters-title {
    font-size: 18px;
    margin-bottom: 20px;
    color: #333;
    padding-bottom: 10px;
    border-bottom: 2px solid #0073aa;
}

.cps-filter-group {
    margin-bottom: 18px;
}

.cps-filter-group label {
    display: block;
    font-weight: 600;
    color: #555;
    font-size: 13px;
    margin-bottom: 6px;
}

.cps-filter-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    box-sizing: border-box;
}

.cps-filter-select:focus {
    outline: none;
    border-color: #0073aa;
}

.cps-search-main {
    flex: 1;
    min-width: 0;
}

.advanced-filters {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.filter-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
}

.filter-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.toggle-filters {
    background: none;
    border: none;
    color: #0073aa;
    cursor: pointer;
    text-decoration: underline;
    margin-top: 10px;
    padding: 0;
}

.results-header {
    margin-bottom: 20px;
}

.results-count {
    font-size: 18px;
    color: #666;
    font-weight: 600;
}

.results-container {
    width: 100%;
}

/* Default grid layout - applies to all results-grid */
.results-grid {
    /*display: grid !important;*/
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 20px;
    margin-bottom: 30px;
    width: 100%;
}

/* Ensure grid view works even when container has results-grid class */
.results-container.results-grid .results-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)) !important;
}

.provider-card {
    background: white;
    border: 2px solid #90EE90;
    border-radius: 8px;
    padding: 20px;
    transition: box-shadow 0.3s;
    display: flex;
    flex-direction: column;
}

.provider-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.provider-card-header {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
    align-items: center;
}

.provider-card-header:has(.provider-avatar) {
    /* Header with avatar - layout fixed */
}

.provider-card-header:not(:has(.provider-avatar)) .provider-header-content {
    width: 100%;
    margin-left: 0;
}

.provider-avatar {
    width: 40px;
    height: 40px;
    background: #90EE90;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
    font-weight: bold;
    color: #333;
    line-height: 1;
    margin-right: 12px;
}

.provider-header-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.provider-name {
    margin: 0;
    font-size: 18px;
    font-weight: bold;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.provider-name a {
    color: #333;
    text-decoration: none;
}

.provider-name a:hover {
    color: #0073aa;
}

.provider-field {
    margin-bottom: 10px;
    color: #555;
    line-height: 1.6;
    font-size: 14px;
}

.provider-field strong {
    color: #333;
    font-weight: 600;
}

.provider-address {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #555;
    font-size: 14px;
    margin-bottom: 10px;
}

.provider-address-icon {
    color: #90EE90;
    font-size: 16px;
}

.provider-card-footer {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
}

.view-details {
    display: inline-block;
    padding: 10px 20px;
    background: #228B22;
    color: white;
    text-decoration: none;
    font-weight: 600;
    border-radius: 6px;
    font-size: 14px;
    transition: background 0.3s;
}

.view-details:hover {
    background: #1e7a1e;
    color: white;
}

.no-results,
.search-prompt {
    text-align: center;
    padding: 40px;
    background: #f9f9f9;
    border-radius: 8px;
    color: #666;
}

.search-loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

/* Autocomplete Styles */
.cps-autocomplete {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    z-index: 1000;
    width: 100%;
    display: none;
}

.cps-autocomplete.show {
    display: block;
}

.autocomplete-list {
    list-style: none;
    padding: 0;
    margin: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 300px;
    overflow-y: auto;
    width: 100%;
}

.autocomplete-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
    color: #333;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: #f5f5f5;
    color: #0073aa;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

/* Distance Search Controls */
.distance-search-wrapper {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.cps-near-me-btn {
    padding: 10px 20px;
    background: #228B22;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.3s;
}

.cps-near-me-btn:hover {
    background: #1e7a1e;
}

.cps-near-me-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.radius-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.radius-selector label {
    font-weight: 600;
    white-space: nowrap;
}

.radius-selector select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

/* Results Controls */
.results-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
}

.results-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.sort-control {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.sort-control label {
    font-weight: 600;
    white-space: nowrap;
}

.cps-sort-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    min-width: 120px;
}

.sort-order-toggle {
    padding: 8px 12px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background 0.3s;
    min-width: 44px;
    flex-shrink: 0;
}

.sort-order-toggle:hover {
    background: #e0e0e0;
}

.view-control {
    display: flex;
    gap: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.view-toggle {
    padding: 8px 12px;
    background: white;
    border: none;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s;
    border-right: 1px solid #ddd;
}

.view-toggle:last-child {
    border-right: none;
}

.view-toggle:hover {
    background: #f5f5f5;
}

.view-toggle.active {
    background: #0073aa;
    color: white;
}

/* Distance Display */
.provider-distance {
    color: #228B22;
    font-weight: 600;
    margin-left: 5px;
}

/* List View */
/* List view - only apply when container has results-list class */
.results-container.results-list .results-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 15px;
}

.results-list .provider-card {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 20px;
    padding: 20px;
}

.results-list .provider-card-header {
    flex-direction: row;
    margin-bottom: 0;
    min-width: 200px;
}

.results-list .provider-avatar {
    width: 40px;
    height: 40px;
    font-size: 18px;
}

.results-list .provider-header-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.results-list .provider-card-footer {
    margin-top: 0;
    margin-left: auto;
    border-top: none;
    padding-top: 0;
}

/* Map View */
.cps-map-container {
    width: 100%;
    height: 400px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f5f5f5;
}

.results-map-list {
    max-height: 400px;
    overflow-y: auto;
}

/* Responsive */
@media (max-width: 768px) {
    .results-header-top {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .results-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .distance-search-wrapper {
        flex-direction: column;
        align-items: stretch;
    }
    
    .radius-selector {
        width: 100%;
    }
    
    .radius-selector select {
        flex: 1;
    }
    
    .results-list .provider-card {
        flex-direction: column;
    }
    
    .results-list .provider-card-footer {
        margin-left: 0;
        width: 100%;
    }
}

.pagination-wrapper {
    text-align: center;
    margin-top: 30px;
}

.pagination-wrapper .page-numbers {
    display: inline-flex;
    gap: 5px;
    list-style: none;
    padding: 0;
}

.pagination-wrapper .page-numbers li {
    display: inline;
}

.pagination-wrapper .page-numbers a,
.pagination-wrapper .page-numbers span {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #0073aa;
}

.pagination-wrapper .page-numbers .current {
    background: #0073aa;
    color: white;
    border-color: #0073aa;
}

@media (max-width: 768px) {
    .cps-search-container.cps-with-sidebar .cps-search-layout {
        flex-direction: column;
    }
    
    .cps-filters-sidebar {
        width: 100%;
    }
    
    .filter-row {
        grid-template-columns: 1fr;
    }
    
    .search-input-group {
        flex-direction: column;
    }
    
    .search-fields-wrapper {
        flex-direction: column !important;
        gap: 15px !important;
    }
    
    .search-field-group {
        flex: 1 1 100% !important;
        width: 100% !important;
        position: relative;
    }
    
    .cps-autocomplete {
        position: absolute;
        top: calc(100% + 2px);
        left: 0;
        right: 0;
    }
    
    .search-button-wrapper {
        width: 100% !important;
        align-items: stretch !important;
    }
    
    .search-button-wrapper .search-button {
        width: 100% !important;
    }
    
    .results-container .results-grid,
    .results-container.results-grid .results-grid {
        grid-template-columns: 1fr !important;
        display: grid !important;
    }
    
    .provider-card-header {
        flex-direction: column;
    }
    
    .provider-avatar {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
}
