/**
 * TWW Maps - Basis-Styles
 *
 * @package TWW_Maps_Core
 */

/* Map Container */
.tww-map-container {
    position: relative;
    width: 100%;
    min-height: 400px;
    background-color: #f5f5f5;
    border-radius: 4px;
    overflow: hidden;
}

.tww-map-container canvas {
    outline: none;
}

/* Loading State */
.tww-map-container.loading {
    display: flex;
    align-items: center;
    justify-content: center;
}

.tww-map-container.loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top-color: var(--tww-brand-primary, #3388ff);
    border-radius: 50%;
    animation: tww-map-spin 1s linear infinite;
}

@keyframes tww-map-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error State */
.tww-map-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    padding: 20px;
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    text-align: center;
}

/* Marker Styles */
.tww-map-marker {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--tww-brand-primary, #3388ff);
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    /* Kein transition auf transform! MapLibre positioniert Marker via transform,
       eine Transition verursacht sichtbaren Lag beim Pan/Zoom */
    will-change: transform;
    backface-visibility: hidden;
}

.tww-map-marker:hover {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
    filter: brightness(1.15);
}

/* Pulsierender Ring-Effekt wenn Marker als Drop-Nachbar hervorgehoben wird */
.tww-map-marker.tww-marker-drop-highlight {
    z-index: 100 !important;
    animation: tww-marker-pulse 0.8s ease-in-out infinite alternate;
}

.tww-map-marker.tww-marker-drop-highlight::after {
    content: '';
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    border-radius: 50%;
    border: 3px solid var(--tww-brand-primary, #3388ff);
    animation: tww-marker-ring-pulse 1s ease-in-out infinite;
}

@keyframes tww-marker-pulse {
    0% {
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), 0 0 0 0 rgba(59,130,246,0.5);
    }
    100% {
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), 0 0 16px 4px rgba(59,130,246,0.3);
    }
}

@keyframes tww-marker-ring-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

.tww-map-marker .marker-number {
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    line-height: 1;
}

/* Verschiedene Marker-Typen */
.tww-map-marker.flight {
    background-color: var(--tww-brand-flight, #e74c3c);
}

.tww-map-marker.car {
    background-color: var(--tww-brand-car, #3498db);
}

.tww-map-marker.road {
    background-color: var(--tww-brand-car, #3498db);
}

.tww-map-marker.group {
    background-color: var(--tww-brand-group, #9b59b6);
}

.tww-map-marker.private {
    background-color: var(--tww-brand-private, #f39c12);
}

.tww-map-marker.ship {
    background-color: var(--tww-brand-ship, #2ecc71);
}

.tww-map-marker.ferry {
    background-color: var(--tww-brand-ferry, #1abc9c);
}

.tww-map-marker.boat_transfer {
    background-color: var(--tww-brand-boat_transfer, #17a2b8);
}

.tww-map-marker.seaplane {
    background-color: var(--tww-brand-seaplane, #e67e22);
}

.tww-map-marker.start {
    background-color: #27ae60;
    width: 36px;
    height: 36px;
}

.tww-map-marker.end {
    background-color: #c0392b;
    width: 36px;
    height: 36px;
}

/* Popup Styles */
.tww-map-popup {
    padding: 5px 0;
    max-width: 250px;
}

.tww-map-popup h4 {
    margin: 0 0 8px 0;
    padding: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--tww-brand-text, #333);
    font-family: var(--tww-brand-font-heading, inherit);
    line-height: 1.3;
}

.tww-map-popup .duration {
    margin: 0 0 5px 0;
    padding: 3px 8px;
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    color: #fff;
    background-color: var(--tww-brand-accent, #e74c3c);
    border-radius: 3px;
}

.tww-map-popup .notes {
    margin: 0;
    padding: 0;
    font-size: 13px;
    color: var(--tww-brand-text-light, #666);
    line-height: 1.4;
}

.tww-map-popup .tww-popup-link {
    margin: 4px 0 0;
    padding: 0;
    font-size: 13px;
    line-height: 1.4;
}

.tww-map-popup .tww-popup-link a {
    color: var(--tww-brand-primary, #3388ff);
    text-decoration: none;
}

.tww-map-popup .tww-popup-link a:hover {
    text-decoration: underline;
}

/* MapLibre Popup Override */
.maplibregl-popup-content {
    padding: 12px 15px;
    border-radius: 6px;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.15);
}

.maplibregl-popup-close-button {
    font-size: 18px;
    padding: 2px 6px;
    color: #666;
    outline: none;
    border: none;
}

.maplibregl-popup-close-button:hover {
    color: #333;
    background-color: transparent;
}

.maplibregl-popup-close-button:focus {
    outline: none;
    box-shadow: none;
}

/* Attribution Override */
.maplibregl-ctrl-attrib {
    font-size: 10px;
    background-color: rgba(255, 255, 255, 0.8);
}

/* Navigation Controls */
.maplibregl-ctrl-group {
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Responsive */
@media (max-width: 768px) {
    .tww-map-container {
        min-height: 300px;
    }

    .tww-map-marker {
        width: 26px;
        height: 26px;
    }

    .tww-map-marker .marker-number {
        font-size: 11px;
    }

    .tww-map-popup {
        max-width: 200px;
    }

    .tww-map-popup h4 {
        font-size: 13px;
    }

    .tww-map-popup .notes {
        font-size: 12px;
    }
}

/* Print Styles */
@media print {
    .tww-map-container {
        page-break-inside: avoid;
    }

    .maplibregl-ctrl-group,
    .maplibregl-ctrl-attrib {
        display: none !important;
    }

    .tww-segment-transport-icon {
        display: none !important;
    }
}

/* ==========================================
   Transport-Icons auf Routen-Segmenten
   ========================================== */
.tww-segment-transport-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    pointer-events: none;
    z-index: 5;
    transition: opacity 0.2s ease;
}

.tww-sti-emoji {
    font-size: 14px;
    line-height: 1;
}
