/**
 * DS Interactive Map - Frontend Styles
 * Version: 3.0.0
 * Supports: Google Maps, Leaflet, MapLibre, OpenFreeMap
 */

/* =============================================
   BASE STYLES
   ============================================= */

.ds-interactive-map {
    width: 100%;
    min-height: 300px;
    background-color: #000;
    position: relative;
}

/* Loading state */
.ds-interactive-map.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: dsMapSpin 1s linear infinite;
    z-index: 1000;
}

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

/* =============================================
   ANIMATED MARKER (All Providers)
   ============================================= */

.ds-marker-overlay {
    z-index: 100;
    cursor: pointer;
}

.ds-marker-overlay .animated-dot {
    width: 30px;
    height: 30px;
    position: relative;
}

.ds-marker-overlay .animated-dot .middle-dot {
    width: 16px;
    height: 16px;
    border-radius: 30px;
    position: absolute;
    left: 7px;
    top: 7px;
    background-color: var(--ds-marker-color, #f5c518);
    transform-origin: 50% 50%;
    box-shadow: 0 0 10px var(--ds-marker-glow, rgba(245, 197, 24, 0.5));
    cursor: pointer;
    transition: transform 0.2s ease;
}

.ds-marker-overlay .animated-dot .middle-dot:hover {
    transform: scale(1.1);
}

.ds-marker-overlay .animated-dot .middle-dot::after {
    width: 100%;
    height: 100%;
    display: block;
    position: absolute;
    left: 0;
    top: 0;
    content: '';
    background-color: #fff;
    border-radius: 30px;
    z-index: 100;
    opacity: 0;
    transform-origin: 50% 50%;
    animation: dsAnimationSignal2 2s cubic-bezier(0, 0.55, 0.55, 1) 0.78s infinite;
}

.ds-marker-overlay .animated-dot .signal,
.ds-marker-overlay .animated-dot .signal2 {
    width: 180px;
    height: 180px;
    border-radius: 200px;
    position: absolute;
    left: -75px;
    top: -75px;
    opacity: 0;
    pointer-events: none;
    background-color: var(--ds-marker-signal, rgba(245, 197, 24, 0.3));
    transform-origin: 50% 50%;
}

.ds-marker-overlay .animated-dot .signal {
    animation: dsAnimationSignal 2s cubic-bezier(0, 0.55, 0.55, 1) 0.78s infinite;
}

.ds-marker-overlay .animated-dot .signal2 {
    animation: dsAnimationSignal 2s cubic-bezier(0, 0.55, 0.55, 1) 1s infinite;
}

@keyframes dsAnimationSignal {
    0% {
        opacity: 0;
        transform: scale(0);
    }
    1% {
        opacity: 0.25;
    }
    20% {
        opacity: 0.25;
    }
    60%, 100% {
        transform: scale(1);
        opacity: 0;
    }
}

@keyframes dsAnimationSignal2 {
    0% {
        opacity: 0;
    }
    1% {
        opacity: 0.2;
    }
    20% {
        opacity: 0.17;
    }
    60%, 100% {
        opacity: 0;
    }
}

/* =============================================
   MAPLIBRE GL JS SPECIFIC STYLES
   ============================================= */

/* MapLibre marker wrapper */
.ds-maplibre-marker {
    cursor: pointer;
}

.ds-maplibre-marker .ds-marker-overlay {
    pointer-events: auto;
}

/* MapLibre zoom controls */
.ds-interactive-map .maplibregl-ctrl-group {
    background: #1a1a1a;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.ds-interactive-map .maplibregl-ctrl-group button {
    background-color: #1a1a1a;
    border: none;
    width: 36px;
    height: 36px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.ds-interactive-map .maplibregl-ctrl-group button:hover {
    background-color: #333;
}

.ds-interactive-map .maplibregl-ctrl-group button + button {
    border-top: 1px solid #333;
    border-radius: 0px !important;
}

.ds-interactive-map .maplibregl-ctrl-group button .maplibregl-ctrl-icon {
    filter: invert(1);
}

/* MapLibre attribution - minimal style */
.ds-interactive-map .maplibregl-ctrl-attrib {
    background: transparent !important;
    font-size: 10px !important;
    padding: 0 !important;
    border-radius: 14px !important;
    overflow: visible !important;
    position: relative !important;
}

.ds-interactive-map .maplibregl-ctrl-attrib:focus,
.ds-interactive-map .maplibregl-ctrl-attrib:focus-within,
.ds-interactive-map .maplibregl-ctrl-attrib-button:focus {
    outline: none !important;
    box-shadow: none !important;
}

.ds-interactive-map .maplibregl-ctrl-bottom-right {
    overflow: visible !important;
}

/* Hide attribution text by default - only show on hover/click */
.ds-interactive-map .maplibregl-ctrl-attrib .maplibregl-ctrl-attrib-inner {
    position: absolute !important;
    bottom: 0 !important;
    right: 40px !important;
    background: rgba(0,0,0,0.9) !important;
    color: #888 !important;
    padding: 6px 12px !important;
    border-radius: 4px !important;
    white-space: nowrap !important;
    font-size: 10px !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transition: opacity 0.2s ease, visibility 0.2s ease !important;
    pointer-events: none !important;
}

.ds-interactive-map .maplibregl-ctrl-attrib a {
    color: #999 !important;
    text-decoration: none !important;
}

.ds-interactive-map .maplibregl-ctrl-attrib a:hover {
    color: #ccc !important;
    text-decoration: underline !important;
}

/* Show attribution text only on hover */
.ds-interactive-map .maplibregl-ctrl-attrib:hover .maplibregl-ctrl-attrib-inner,
.ds-interactive-map .maplibregl-ctrl-attrib[open] .maplibregl-ctrl-attrib-inner {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

/* Info button styling - always visible */
.ds-interactive-map .maplibregl-ctrl-attrib-button {
    display: block !important;
    background-color: transparent !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='10' fill='none' stroke='%23aaaaaa' stroke-width='1.5'/%3E%3Ctext x='12' y='16' text-anchor='middle' font-family='Georgia,serif' font-size='12' font-weight='400' fill='%23aaaaaa'%3Ei%3C/text%3E%3C/svg%3E") !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-size: 22px !important;
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    border-radius: 14px !important;
    border: none !important;
    cursor: pointer !important;
    opacity: 0.6 !important;
    transition: opacity 0.2s ease !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
}

.ds-interactive-map .maplibregl-ctrl-attrib-button:hover {
    opacity: 1 !important;
    background-color: rgba(0,0,0,0.8) !important;
}

/* Ensure attribution container doesn't clip the button */
.ds-interactive-map .maplibregl-ctrl-attrib.maplibregl-compact {
    overflow: visible !important;
    min-width: 28px !important;
    min-height: 28px !important;
}

/* Fix MapLibre canvas sizing */
.ds-interactive-map .maplibregl-canvas-container,
.ds-interactive-map .maplibregl-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* =============================================
   LEAFLET SPECIFIC STYLES
   ============================================= */

/* Leaflet marker wrapper - remove default styles */
.ds-leaflet-marker-wrapper {
    background: none !important;
    border: none !important;
}

/* Ensure marker is clickable in Leaflet */
.ds-interactive-map .leaflet-marker-icon {
    cursor: pointer !important;
}

.ds-interactive-map .leaflet-marker-icon .ds-marker-overlay {
    pointer-events: auto;
}

/* Style Leaflet zoom controls */
.ds-interactive-map .leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;
}

.ds-interactive-map .leaflet-control-zoom a {
    background-color: #1a1a1a !important;
    color: #fff !important;
    border: none !important;
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    font-size: 18px !important;
    transition: background-color 0.2s ease;
}

.ds-interactive-map .leaflet-control-zoom a:hover {
    background-color: #333 !important;
}

.ds-interactive-map .leaflet-control-zoom-in {
    border-radius: 4px 4px 0 0 !important;
}

.ds-interactive-map .leaflet-control-zoom-out {
    border-radius: 0 0 4px 4px !important;
}

/* Leaflet attribution - subtle styling */
.ds-interactive-map .leaflet-control-attribution {
    background: rgba(0,0,0,0.6) !important;
    color: #666 !important;
    font-size: 10px !important;
    padding: 2px 8px !important;
}

.ds-interactive-map .leaflet-control-attribution a {
    color: #888 !important;
}

/* =============================================
   GOOGLE MAPS SPECIFIC STYLES
   ============================================= */

/* Google branding - subtle */
.ds-interactive-map .gm-style-cc,
.ds-interactive-map .gmnoscreen {
    opacity: 0.5;
}

/* Google zoom controls */
.ds-interactive-map .gm-style .gm-style-mtc,
.ds-interactive-map .gm-bundled-control {
    background: #1a1a1a !important;
}

/* =============================================
   ERROR STATE
   ============================================= */

.ds-interactive-map-error {
    padding: 20px;
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid #ff0000;
    color: #ff0000;
    text-align: center;
    font-size: 14px;
    border-radius: 4px;
}

/* =============================================
   RESPONSIVE
   ============================================= */

@media (max-width: 768px) {
    .ds-interactive-map {
        min-height: 250px;
    }

    /* Smaller signal on mobile for performance */
    .ds-marker-overlay .animated-dot .signal,
    .ds-marker-overlay .animated-dot .signal2 {
        width: 120px;
        height: 120px;
        left: -45px;
        top: -45px;
    }

    /* Smaller zoom controls on mobile */
    .ds-interactive-map .leaflet-control-zoom a,
    .ds-interactive-map .maplibregl-ctrl-group button {
        width: 32px !important;
        height: 32px !important;
        line-height: 32px !important;
        font-size: 16px !important;
    }

    /* Smaller MapLibre attribution on mobile */
    .ds-interactive-map .maplibregl-ctrl-attrib .maplibregl-ctrl-attrib-inner {
        font-size: 8px !important;
        padding: 4px 8px !important;
        right: 32px !important;
        max-width: 70vw !important;
        white-space: normal !important;
        line-height: 1.3 !important;
    }

    .ds-interactive-map .maplibregl-ctrl-attrib-button {
        width: 22px !important;
        height: 22px !important;
        min-width: 22px !important;
        min-height: 22px !important;
        background-size: 16px !important;
    }
}
