/* 3D Map Styles */
#map3d-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: none;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

#map3d-container.active {
    opacity: 1;
}

#map3d {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 0;
}

/* Map Controls */
.map3d-controls {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    gap: 1rem;
}

.map3d-info {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding: 1.5rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    pointer-events: auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 280px;
    animation: slideInLeft 0.5s ease-out;
}

.map3d-info h3 {
    margin: 0 0 0.5rem 0;
    color: var(--primary-color);
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.map3d-info p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
}

#properties-count {
    font-weight: 600;
    color: var(--primary-color);
}

.map3d-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: auto;
    animation: slideInRight 0.5s ease-out;
}

.map3d-btn {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
    font-size: 1.1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.map3d-btn:hover {
    background: white;
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

.map3d-btn:active {
    transform: scale(0.95);
}

#map3d-close {
    background: rgba(239, 68, 68, 0.95);
    color: white;
    border-color: rgba(239, 68, 68, 0.3);
}

#map3d-close:hover {
    background: var(--error-color);
    transform: scale(1.1);
}

/* Property Popup Styles */
.property-popup {
    background: white;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 280px;
    max-width: 320px;
}

.popup-image img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.popup-content {
    padding: 1rem;
}

.popup-content h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    color: var(--primary-color);
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.popup-price {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--error-color);
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
}

.popup-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.popup-details span {
    background: var(--bg-tertiary);
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

.popup-location {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.popup-content button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    width: 100%;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.popup-content button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Custom Marker Styles */
.custom-marker {
    background: transparent !important;
    border: none !important;
}

.custom-marker div {
    transition: all var(--transition-fast);
    cursor: pointer;
}

.custom-marker:hover div {
    transform: scale(1.2);
    box-shadow: 0 4px 15px rgba(0,0,0,0.4) !important;
}

/* Map Loading State */
.map3d-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    text-align: center;
    z-index: 20;
}

.map3d-loading .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--bg-tertiary);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

/* Mapbox Popup Overrides */
.mapboxgl-popup {
    max-width: 320px !important;
}

.mapboxgl-popup-content {
    padding: 0 !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-xl) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

.mapboxgl-popup-close-button {
    font-size: 18px !important;
    padding: 8px !important;
    color: var(--text-secondary) !important;
    right: 8px !important;
    top: 8px !important;
    background: rgba(255, 255, 255, 0.9) !important;
    border-radius: 50% !important;
    width: 32px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all var(--transition-fast) !important;
}

.mapboxgl-popup-close-button:hover {
    background: white !important;
    color: var(--primary-color) !important;
    transform: scale(1.1) !important;
}

.mapboxgl-popup-tip {
    border-top-color: white !important;
}

/* Leaflet Popup Overrides */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-xl) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    padding: 0 !important;
}

.leaflet-popup-content {
    margin: 0 !important;
    line-height: 1.4 !important;
}

.leaflet-popup-close-button {
    font-size: 18px !important;
    padding: 8px !important;
    color: var(--text-secondary) !important;
    right: 8px !important;
    top: 8px !important;
    background: rgba(255, 255, 255, 0.9) !important;
    border-radius: 50% !important;
    width: 32px !important;
    height: 32px !important;
    text-align: center !important;
    line-height: 16px !important;
    transition: all var(--transition-fast) !important;
}

.leaflet-popup-close-button:hover {
    background: white !important;
    color: var(--primary-color) !important;
    transform: scale(1.1) !important;
}

/* Animations */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Google Maps InfoWindow Styling */
.gm-style .gm-style-iw {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.gm-style .gm-style-iw-c {
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.gm-style .gm-style-iw-d {
    overflow: hidden !important;
}

.gm-style .gm-style-iw-t::after {
    background: white;
    box-shadow: var(--shadow-md);
}

/* Google Maps Controls Styling */
.gm-style .gm-style-cc {
    display: none; /* Hide Google logo in small maps */
}

.gm-style .gmnoprint {
    background: rgba(255, 255, 255, 0.9);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-md);
}

/* Satellite/Map Type Control */
.gm-style .gm-style-mtc {
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

/* Zoom Controls */
.gm-style .gm-bundled-control {
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

/* Street View Control */
.gm-style .gm-svpc {
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

/* Leaflet Controls Styling */
.leaflet-control-layers {
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.75rem;
    font-family: 'Inter', sans-serif;
    margin-top: 160px !important;
}

.leaflet-control-layers-expanded {
    margin-top: 160px !important;
}

.leaflet-top.leaflet-right .leaflet-control-layers {
    margin-top: 160px !important;
}

/* Custom positioning for inline map */
.map-inline .leaflet-control-layers {
    margin-top: 160px !important;
}

.map-inline .leaflet-control-layers-expanded {
    margin-top: 160px !important;
}

/* Utility classes for layer control positioning */
.leaflet-control-layers-offset-small {
    margin-top: 120px !important;
}

.leaflet-control-layers-offset-medium {
    margin-top: 160px !important;
}

.leaflet-control-layers-offset-large {
    margin-top: 200px !important;
}

.leaflet-control-layers-toggle {
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    width: 40px;
    height: 40px;
}

.leaflet-control-layers label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.leaflet-control-layers input[type="radio"],
.leaflet-control-layers input[type="checkbox"] {
    margin-right: 0.5rem;
    accent-color: var(--primary-color);
}

.leaflet-control-zoom {
    border: none;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.leaflet-control-zoom a {
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: var(--primary-color);
    border: none;
    width: 40px;
    height: 40px;
    line-height: 40px;
    font-size: 1.2rem;
    font-weight: bold;
    transition: all var(--transition-fast);
}

.leaflet-control-zoom a:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

.leaflet-popup-content-wrapper {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.leaflet-popup-tip {
    background: white;
    box-shadow: var(--shadow-md);
}

/* Responsive Design */
@media (max-width: 768px) {
    .map3d-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        top: 10px;
        left: 10px;
        right: 10px;
    }
    
    .map3d-info {
        min-width: auto;
        padding: 1rem;
    }
    
    .map3d-info h3 {
        font-size: 1rem;
    }
    
    .map3d-actions {
        flex-direction: row;
        justify-content: center;
        gap: 0.5rem;
    }
    
    .map3d-btn {
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }
    
    .property-popup {
        min-width: 260px;
        max-width: 280px;
    }
    
    .popup-content {
        padding: 0.75rem;
    }
    
    .popup-content h4 {
        font-size: 0.9rem;
    }
    
    .popup-price {
        font-size: 1.1rem;
    }
}

/* Dark Theme Support */
[data-theme="dark"] .map3d-info {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .map3d-info h3 {
    color: var(--primary-light);
}

[data-theme="dark"] .map3d-info p {
    color: var(--text-secondary);
}

[data-theme="dark"] .property-popup {
    background: var(--bg-primary);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .popup-content h4 {
    color: var(--primary-light);
}

[data-theme="dark"] .popup-details span {
    background: var(--bg-tertiary);
}

/* Performance Optimizations */
.map3d-controls,
.property-popup,
.map3d-btn {
    will-change: transform;
}

/* Accessibility */
.map3d-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.popup-content button:focus {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .map3d-controls,
    .map3d-btn,
    .property-popup,
    .custom-marker div {
        animation: none;
        transition: none;
    }
    
    .map3d-btn:hover,
    .custom-marker:hover div {
        transform: none;
    }
}

/* Mobile Layer Control Positioning */
@media (max-width: 768px) {
    .leaflet-control-layers {
        margin-top: 140px !important;
        font-size: 0.9rem !important;
        padding: 0.5rem !important;
    }

    .leaflet-control-layers-expanded {
        margin-top: 140px !important;
    }

    .leaflet-top.leaflet-right .leaflet-control-layers {
        margin-top: 140px !important;
        margin-right: 10px !important;
    }

    .leaflet-control-layers label {
        font-size: 0.8rem !important;
    }
}
