/* ============================================
   Advanced Search Modal Styles
   ============================================ */

/* Modal Overlay */
.advanced-search-modal {
    font-family: 'DM Sans', sans-serif;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    overflow-y: auto;
    animation: fadeIn 0.3s ease-in-out;
}

/* Backdrop */
.advanced-search-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: 1;
}

/* Top Container - Search Bar */
.advanced-search-top-container {
    position: relative;
    max-width: 1054px;
    margin: 80px auto -8px;
    background: #ffffff;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 2;
    padding: 12px 20px;
    animation: slideDown 0.3s ease-in-out;
}

/* Bottom Container - Filters and Results */
.advanced-search-bottom-container {
    position: relative;
    max-width: 900px;
    margin: 0 auto 40px;
    margin-left: calc((100% - 1054px) / 2 + 20px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 2;
    padding: 24px 32px;
    animation: slideDown 0.3s ease-in-out 0.1s;
    animation-fill-mode: both;
}

/* Close Button */
.advanced-search-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
    color: #666;
    z-index: 10;
}

.advanced-search-close:hover {
    background-color: #f5f5f5;
    color: #333;
}

/* Header with Logo */
.advanced-search-header {
    text-align: center;
    margin-bottom: 30px;
}

.advanced-search-logo {
    height: 50px;
    width: auto;
}

/* Main Search Section */
.advanced-search-main {
    display: flex;
    gap: 12px;
    align-items: center;
}

.advanced-search-input-wrapper {
    flex: 1;
    position: relative;
}

.advanced-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #0F6699;
    pointer-events: none;
}

.advanced-search-input {
    width: 100%;
    height: 48px;
    padding: 12px 16px 12px 48px;
    border: 1px solid #116799;
    border-radius: 25px;
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    background: #ffffff;
}

.advanced-search-input::placeholder {
    color: #515C67;
}

/* Primary Button */
.advanced-search-btn-primary {
    height: 48px;
    padding: 0 32px;
    background-color: #0B4F6C;
    color: #ffffff;
    border: none;
    border-radius: 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.advanced-search-btn-primary:hover {
    background-color: #083a52;
}

/* Advanced Filters Section */
.advanced-filters-section {
    margin-bottom: 0;
}

.advanced-filters-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 0;
    background: transparent;
    border: none;
    border-radius: 0;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.advanced-filters-toggle:hover {
    color: #333;
}

.advanced-filters-toggle svg:first-child {
    color: #0B4F6C;
}

.advanced-filters-toggle span {
    flex: 1;
    text-align: left;
    font-weight: 500;
}

.advanced-filters-chevron {
    transition: transform 0.2s;
    color: #666;
}

.advanced-filters-toggle[aria-expanded="true"] .advanced-filters-chevron {
    transform: rotate(180deg);
}

/* Filters Content */
.advanced-filters-content {
    margin-top: 16px;
    padding: 0;
    background-color: transparent;
    border-radius: 0;
    animation: slideDown 0.2s ease-in-out;
}

.advanced-filters-grid {
    display: flex;
    gap: 24px;
}

.filter-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Filter Group */
.filter-group {
    background: transparent;
    padding: 0;
    border-radius: 16px;
    border: 1px solid #A1DCFF;
    height: auto;
    overflow: hidden;
    transition: width 0.4s ease-in-out, max-width 0.4s ease-in-out;
}

.filter-group-title-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: #ECF8FF;
    border-bottom: 1px solid #A1DCFF;
}

.filter-group-title-wrapper .filter-group-title {
    font-size: 16px;
    font-weight: 400;
    color: #1A5A7F;
    margin: 0;
    padding: 0;
    background: #ECF8FF;
    border-bottom: none;
}

.filter-group-title {
    font-size: 16px;
    font-weight: 400;
    color: #1A5A7F;
    margin: 0;
    padding: 10px 20px;
    background: #ECF8FF;
    border-bottom: 1px solid #A1DCFF;
}

.btn-expand-map {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: #0B4F6C;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
}

.btn-expand-map:hover {
    color: #083a52;
}

.btn-expand-map svg {
    transition: transform 0.2s;
}

.btn-expand-map[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

/* Expanded Map State - hides other filters and takes full width */
.advanced-filters-grid.has-expanded {
    position: relative;
    min-height: 600px;
}

.advanced-filters-grid.has-expanded .filter-column {
    transition: opacity 0.2s ease-in-out;
}

.advanced-filters-grid.has-expanded .filter-group:not(.expanded-map) {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease-in-out;
}

.filter-group.expanded-map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 10;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.filter-group.expanded-map .map-container {
    height: 400px;
}

.map-container {
    transition: height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.filter-options {
    display: flex;
    flex-direction: column;
    gap: 17px;
    background: #ffffff;
    padding: 16px 20px;
}

/* Checkbox Styling */
.filter-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    color: #515C67;
    line-height: 1.5;
}

.filter-checkbox input[type="checkbox"] {
    margin-top: 2px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #0B4F6C;
    flex-shrink: 0;
}

.filter-checkbox:hover {
    color: #333;
}

/* Location Search */
.location-search-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
    position: relative;
}

.location-search-wrapper .advanced-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #0F6699;
    pointer-events: none;
    z-index: 1;
}

.location-search-wrapper .advanced-search-input-wrapper {
    position: relative;
    flex: 1;
}

.location-search-input {
    width: 100%;
    height: 40px;
    padding: 8px 12px 8px 48px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    font-size: 14px;
    outline: none;
    position: relative;
    background: #ffffff;
}

.location-search-input:focus {
    border-color: #0B4F6C;
    box-shadow: 0 0 0 3px rgba(11, 79, 108, 0.1);
}

/* Places Autocomplete Dropdown - Custom styling to match light theme */
.places-autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 280px;
    overflow-y: auto;
    z-index: 1000;
    margin: 0;
}

.places-autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-bottom: 1px solid #f5f5f5;
}

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

.places-autocomplete-item:hover,
.places-autocomplete-item.selected {
    background-color: #f0f7fb;
}

.places-autocomplete-main {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 2px;
}

.places-autocomplete-secondary {
    font-size: 12px;
    color: #666;
}

/* Scrollbar styling for autocomplete dropdown */
.places-autocomplete-dropdown::-webkit-scrollbar {
    width: 8px;
}

.places-autocomplete-dropdown::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 0 12px 12px 0;
}

.places-autocomplete-dropdown::-webkit-scrollbar-thumb {
    background: #c0c0c0;
    border-radius: 4px;
}

.places-autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

.btn-drop-pin {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background-color: #0B4F6C;
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.btn-drop-pin:hover {
    background-color: #083a52;
}

.btn-drop-pin.active {
    background-color: #1A5A7F;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

/* Map Container */
.map-container {
    width: calc(100% + 40px);
    margin-left: -20px;
    height: 207px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
    position: relative;
}

/* Ensure Google Maps fills the container */
.map-container > div {
    width: 100% !important;
    height: 100% !important;
}

.map-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
}

.map-placeholder svg {
    margin-bottom: 12px;
}

.map-placeholder p {
    margin: 0;
    font-size: 14px;
}

/* Distance Options */

.distance-inline {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.distance-label {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.distance-label span {
    font-size: 14px;
    font-weight: 400;
    color: #919EAB;
}

.distance-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #515C67;
}

.distance-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #0B4F6C;
    flex-shrink: 0;
}

.distance-checkbox span {
    font-size: 14px;
    color: #515C67;
}

.distance-checkbox:hover {
    color: #333;
}

/* Results Preview */
.advanced-search-results-preview {
    padding: 40px 0 0;
    background-color: transparent;
    border-top: 1px solid #e0e0e0;
}

.results-preview-title {
    font-size: 12px;
    font-weight: 600;
    color: #515C67;
    margin: 0 0 8px 0;
}

.results-preview-text {
    font-size: 16px;
    color: #515C67;
    margin: 0;
    line-height: 1.6;
}

/* Search Results List */
.search-results-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.search-result-item {
    padding: 16px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.2s;
    cursor: pointer;
}

.search-result-item:hover {
    background: #ffffff;
    border-color: #0B4F6C;
    box-shadow: 0 2px 8px rgba(11, 79, 108, 0.1);
}

.result-name {
    font-size: 16px;
    font-weight: 600;
    color: #0B4F6C;
    margin: 0 0 8px 0;
}

.result-details {
    font-size: 14px;
    color: #515C67;
    margin: 0;
    line-height: 1.4;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
}

/* ============================================
   Responsive Styles
   ============================================ */
@media (max-width: 1030px) {
    .advanced-search-bottom-container {
        margin-left: calc((100% - 900px) / 2); 
        transform: translateX(-50%);
    }
}

@media (max-width: 899px) {
    .advanced-search-top-container {
        margin: 60px 20px 12px;
        padding: 10px 16px;
    }
    
    .advanced-search-bottom-container {
        margin: 0 20px 20px;
        padding: 20px;
    }

    .advanced-filters-grid {
        flex-direction: column;
    }

    .location-search-input {
        width: 100%;
    }

    .distance-inline {
        gap: 12px;
    }

    .map-container {
        height: 200px;
    }
}

@media (max-width: 480px) {
    .advanced-search-top-container {
        margin: 40px 10px 10px;
        padding: 8px 12px;
    }
    
    .advanced-search-bottom-container {
        margin: 0 10px 10px;
        padding: 16px;
    }

    .advanced-search-logo {
        height: 40px;
    }

    .advanced-search-input,
    .advanced-search-btn-primary {
        height: 44px;
        font-size: 14px;
    }

    .filter-group {
        padding: 16px;
    }

    .filter-group-title {
        font-size: 15px;
    }

    .filter-checkbox {
        font-size: 13px;
    }
}

/* ============================================
   Accessibility
   ============================================ */

/* Focus styles for keyboard navigation */
.advanced-search-close:focus,
.advanced-search-btn-primary:focus,
.advanced-filters-toggle:focus,
.btn-drop-pin:focus {
    outline: 2px solid #0B4F6C;
    outline-offset: 2px;
}

.filter-checkbox input[type="checkbox"]:focus {
    outline: 2px solid #0B4F6C;
    outline-offset: 2px;
}

.distance-checkbox input[type="checkbox"]:focus {
    outline: 2px solid #0B4F6C;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .advanced-search-container {
        border: 2px solid #000;
    }

    .advanced-search-input,
    .filter-group,
    .advanced-filters-toggle {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .advanced-search-modal,
    .advanced-search-container,
    .advanced-filters-content {
        animation: none;
    }

    .advanced-filters-chevron,
    .advanced-search-input,
    .advanced-search-btn-primary,
    .advanced-filters-toggle,
    .distance-checkbox {
        transition: none;
    }
}
