/**
 * Enhanced Map Styles for Friendoza
 */

/* Map Container */
#map {
    height: calc(100vh - 180px);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    position: relative;
}

/* Search Control */
.map-search-control {
    margin: 12px;
}

.map-search-box {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    min-width: 320px;
    transition: all 0.3s ease;
}

.map-search-box:focus-within {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.3);
    transform: translateY(-2px);
}

.map-search-box i {
    color: var(--text-secondary);
    font-size: 16px;
}

.map-search-box input {
    border: none;
    outline: none;
    flex: 1;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background: transparent;
}

.map-search-box input::placeholder {
    color: var(--text-secondary);
}

/* Dark mode search */
.dark-mode .map-search-box {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.dark-mode .map-search-box input {
    color: var(--text-primary);
}

/* Filter Control */
.map-filter-control {
    margin: 12px;
    position: relative;
}

.map-filters {
    background: rgba(255, 255, 255, 0.98); /* ✅ Slightly opaque */
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2); /* ✅ Stronger shadow */
    padding: 16px;
    min-width: 200px;
    max-width: 250px;
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.1); /* ✅ Subtle border */
    position: relative; /* For close button */
}

.map-filters.collapsed {
    display: none;
}

.map-filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.map-filters-title {
    font-weight: 800; /* ✅ Super bold */
    font-size: 16px; /* ✅ Larger */
    color: #0f172a; /* ✅ Explicit dark color */
    display: flex;
    align-items: center;
    gap: 8px;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8); /* ✅ Better readability */
}

.map-filters-title i {
    color: var(--accent-primary);
}

.map-toggle-btn {
    background: rgba(241, 245, 249, 0.8);
    border: none;
    color: #475569;
    cursor: pointer;
    padding: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.map-toggle-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
    transform: scale(1.1);
}

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

.map-filter-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.map-filter-item:hover {
    background: var(--bg-hover);
}

.map-filter-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-primary);
}

.filter-icon {
    font-size: 20px;
    line-height: 1;
}

.filter-name {
    font-size: 15px; /* ✅ Larger */
    font-weight: 600; /* ✅ Bolder */
    color: #0f172a; /* ✅ Explicit dark color */
    flex: 1;
}

/* Dark mode filters */
.dark-mode .map-filters {
    background: rgba(15, 23, 42, 0.95); /* ✅ Slightly transparent */
    border: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .map-filters {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .map-filters-title {
    color: #f8fafc;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .filter-name {
    color: #f8fafc;
    font-weight: 600;
}

/* Radius Control */
.map-radius-control {
    margin: 12px;
}

.map-radius-slider {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 16px;
    min-width: 280px;
}

.radius-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--text-primary);
}

.radius-label i {
    color: var(--accent-primary);
}

.radius-label strong {
    color: var(--accent-primary);
    font-weight: 600;
}

#radiusSlider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, var(--accent-primary), var(--accent-secondary));
    outline: none;
    -webkit-appearance: none;
    margin: 8px 0;
}

#radiusSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border: 3px solid var(--accent-primary);
    transition: all 0.2s ease;
}

#radiusSlider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

#radiusSlider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border: 3px solid var(--accent-primary);
    transition: all 0.2s ease;
}

#radiusSlider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.radius-marks {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Dark mode radius */
.dark-mode .map-radius-slider {
    background: var(--bg-secondary);
}

/* Legend Control */
.map-legend-control {
    margin: 12px;
    position: relative;
}

.map-legend {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 16px;
    min-width: 160px;
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.08);
    position: relative; /* For close button */
}

.map-legend.collapsed {
    display: none;
}

.legend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.legend-title {
    font-weight: 800; /* ✅ Super bold */
    font-size: 15px; /* ✅ Larger */
    color: #0f172a; /* ✅ Explicit dark color */
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.legend-icon {
    font-size: 18px;
    line-height: 1;
    width: 24px;
    text-align: center;
}

.legend-name {
    font-size: 15px; /* ✅ Larger */
    font-weight: 700; /* ✅ Extra bold */
    color: #1e293b; /* ✅ Darker color for better contrast */
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.6);
}

/* Dark mode legend */
[data-theme="dark"] .map-legend {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .legend-title {
    color: #f8fafc; /* ✅ Very light for dark theme */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .legend-name {
    color: #e2e8f0; /* ✅ Lighter gray for better contrast */
    font-weight: 700; /* ✅ Extra bold */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Show Panels Button (when collapsed) */
.map-show-panel-btn {
    background: linear-gradient(135deg, #0ea5e9 0%, #22d3ee 100%);
    border: 2px solid white;
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(14, 165, 233, 0.5), 0 2px 8px rgba(0, 0, 0, 0.2);
    padding: 12px 16px;
    cursor: pointer;
    color: white;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

.map-show-panel-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 25px rgba(14, 165, 233, 0.6), 0 4px 12px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, #0284c7 0%, #06b6d4 100%);
}

.map-show-panel-btn i {
    font-size: 18px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.dark-mode .map-show-panel-btn {
    background: linear-gradient(135deg, #0ea5e9 0%, #22d3ee 100%);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    box-shadow: 0 6px 20px rgba(14, 165, 233, 0.4), 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Info Window Styles */
.map-info-window {
    padding: 4px;
    max-width: 320px;
    font-family: 'Inter', sans-serif;
}

.info-header {
    margin-bottom: 8px;
}

.info-category {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    color: white;
    text-transform: capitalize;
}

.info-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin: 8px 0;
    line-height: 1.4;
}

.info-description {
    font-size: 13px;
    color: #6b7280;
    margin: 8px 0;
    line-height: 1.5;
}

.info-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 12px 0;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #4b5563;
}

.info-item i {
    width: 16px;
    text-align: center;
    color: var(--accent-primary);
}

.info-button {
    width: 100%;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    margin-top: 12px;
    font-family: 'Inter', sans-serif;
}

.info-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.info-button i {
    font-size: 14px;
}

/* Google Maps InfoWindow custom styling */
.gm-style .gm-style-iw-c {
    padding: 16px !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15) !important;
}

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

.gm-style .gm-style-iw-t::after {
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Close button styling */
.gm-ui-hover-effect {
    opacity: 0.6 !important;
    width: 32px !important;
    height: 32px !important;
    top: 8px !important;
    right: 8px !important;
}

.gm-ui-hover-effect:hover {
    opacity: 1 !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    #map {
        height: calc(100vh - 140px);
        border-radius: 8px;
    }

    .map-search-box {
        min-width: auto;
        max-width: calc(100vw - 80px);
        padding: 10px 12px;
    }

    .map-filters {
        max-width: calc(100vw - 24px);
    }

    .map-radius-slider {
        min-width: auto;
        max-width: calc(100vw - 24px);
    }

    .map-legend {
        min-width: auto;
    }

    .map-info-window {
        max-width: 280px;
    }

    .info-title {
        font-size: 15px;
    }

    .info-description {
        font-size: 12px;
    }

    .info-button {
        padding: 8px 14px;
        font-size: 13px;
    }
    
    /* Улучшенная видимость кнопок на планшетах */
    .map-show-panel-btn {
        padding: 13px 17px;
        font-size: 15px;
        border: 2.5px solid white;
        box-shadow: 0 7px 22px rgba(14, 165, 233, 0.55), 
                    0 3px 10px rgba(0, 0, 0, 0.25);
    }
    }
}

@media (max-width: 480px) {
    .map-search-control,
    .map-filter-control,
    .map-radius-control,
    .map-legend-control {
        margin: 8px;
    }

    .map-filters,
    .map-radius-slider,
    .map-legend {
        padding: 12px;
    }

    .map-filters-title,
    .legend-title {
        font-size: 13px;
    }

    .map-filter-item {
        padding: 8px;
    }

    .filter-name,
    .legend-name {
        font-size: 13px;
    }
    
    /* Улучшенная видимость кнопок на мобильных */
    .map-show-panel-btn {
        padding: 14px 18px;
        font-size: 16px;
        font-weight: 700;
        border: 3px solid white;
        box-shadow: 0 8px 24px rgba(14, 165, 233, 0.6), 
                    0 4px 12px rgba(0, 0, 0, 0.3),
                    0 0 0 4px rgba(14, 165, 233, 0.2);
        backdrop-filter: blur(12px);
    }
    
    .map-show-panel-btn i {
        font-size: 20px;
    }
    
    .map-show-panel-btn:active {
        transform: scale(0.95);
    }

    .radius-label {
        font-size: 13px;
    }

    #radiusSlider {
        height: 5px;
    }

    #radiusSlider::-webkit-slider-thumb {
        width: 16px;
        height: 16px;
    }

    #radiusSlider::-moz-range-thumb {
        width: 16px;
        height: 16px;
    }
}

/* Animation for controls appearing */
@keyframes slideInLeft {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

.map-search-control,
.map-radius-control {
    animation: slideInTop 0.4s ease;
}

.map-filter-control,
.map-legend-control {
    animation: slideInLeft 0.4s ease;
}

/* Loading state */
.map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 24px 32px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text-primary);
    z-index: 1000;
}

.map-loading .loader {
    width: 20px;
    height: 20px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.dark-mode .map-loading {
    background: var(--bg-secondary);
}
