/**
 * Стили для интеграции с Яндекс.Картами
 * Маркеры событий, попапы, индикаторы загрузки
 */

/* Контейнер карты */
#map {
    width: 100%;
    height: 400px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
}

/* На мобильных устройствах карта больше */
@media (max-width: 768px) {
    #map {
        height: 300px;
        border-radius: 4px;
    }
}

/* Полноэкранная карта */
#map.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    border-radius: 0;
}

/* ==========================================
   МАРКЕРЫ СОБЫТИЙ
   ========================================== */

.event-marker {
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.event-marker:hover {
    transform: scale(1.1);
    z-index: 100;
}

.marker-pin {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.marker-icon {
    transform: rotate(45deg);
    font-size: 12px;
    color: white;
    line-height: 1;
}

/* Пульсирующая анимация для новых событий */
.event-marker.new {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(102, 126, 234, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
    }
}

/* Кластеры маркеров */
.marker-cluster {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border: 3px solid white;
    border-radius: 50%;
    color: white;
    font-weight: bold;
    font-size: 12px;
    text-align: center;
    line-height: 1;
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.marker-cluster:hover {
    transform: scale(1.1);
}

/* ==========================================
   ПОПАПЫ СОБЫТИЙ
   ========================================== */

.event-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90vw;
    max-height: 80vh;
    overflow: hidden;
    z-index: 1001;
    animation: popup-appear 0.3s ease-out;
}

@keyframes popup-appear {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.popup-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.popup-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    flex: 1;
    padding-right: 12px;
}

.popup-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.popup-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.popup-content {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.popup-content p {
    margin: 0 0 12px 0;
    font-size: 14px;
    line-height: 1.4;
}

.popup-content strong {
    color: #333;
}

.popup-preview {
    background: #f8f9fa;
    border-left: 4px solid #667eea;
    padding: 12px 16px;
    margin-top: 16px;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.5;
    color: #555;
    max-height: 120px;
    overflow-y: auto;
}

/* ==========================================
   ИНДИКАТОРЫ ЗАГРУЗКИ И ОШИБОК
   ========================================== */

.map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.map-loading p {
    margin: 12px 0 0 0;
    color: #666;
    font-size: 14px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.map-error {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #dc3545;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    z-index: 200;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

.map-error button {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 12px;
    font-size: 12px;
    transition: background-color 0.2s ease;
}

.map-error button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ==========================================
   ПАНЕЛЬ УПРАВЛЕНИЯ КАРТОЙ
   ========================================== */

.map-controls {
    background: white;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.map-controls label {
    font-weight: 500;
    font-size: 14px;
    color: #333;
}

.map-controls select,
.map-controls input {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
}

.map-controls button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: transform 0.2s ease;
}

.map-controls button:hover {
    transform: translateY(-1px);
}

.map-controls button:active {
    transform: translateY(0);
}

/* ==========================================
   СТАТИСТИКА КАРТЫ
   ========================================== */

.map-stats {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 12px 16px;
    margin-top: 16px;
    font-size: 13px;
    color: #666;
    border-left: 4px solid #667eea;
}

.map-stats .stat-item {
    display: inline-block;
    margin-right: 20px;
}

.map-stats .stat-value {
    font-weight: 600;
    color: #333;
}

/* ==========================================
   АДАПТИВНОСТЬ
   ========================================== */

@media (max-width: 768px) {
    .event-popup {
        width: 95vw;
        max-width: none;
    }

    .popup-header {
        padding: 12px 16px;
    }

    .popup-header h3 {
        font-size: 15px;
    }

    .popup-content {
        padding: 16px;
    }

    .map-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .map-controls>* {
        width: 100%;
        margin-bottom: 8px;
    }

    .map-stats .stat-item {
        display: block;
        margin-right: 0;
        margin-bottom: 4px;
    }
}

/* ==========================================
   ТЕМНАЯ ТЕМА (опционально)
   ========================================== */

@media (prefers-color-scheme: dark) {
    .map-controls {
        background: #2d3748;
        color: white;
    }

    .map-controls select,
    .map-controls input {
        background: #4a5568;
        border-color: #718096;
        color: white;
    }

    .map-stats {
        background: #2d3748;
        color: #cbd5e0;
    }

    .popup-content {
        background: #2d3748;
        color: white;
    }

    .popup-preview {
        background: #4a5568;
        color: #cbd5e0;
    }
}