/* ============================================
   Altkleider Map — Light & Friendly UI
   ============================================ */

/* --- CSS Variables (defaults, overridden inline by widget) --- */
.altkleider-map-wrapper {
    --akm-marker-color: #16a34a;
    --akm-marker-size: 14px;
    --akm-tooltip-bg: rgba(255, 255, 255, 0.97);
    --akm-tooltip-text: #1e293b;
    --akm-tooltip-accent: #16a34a;
    --akm-search-bg: rgba(255, 255, 255, 0.92);
    --akm-border-radius: 16px;
    --akm-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* --- Wrapper --- */
.altkleider-map-wrapper {
    position: relative;
    font-family: var(--akm-font);
    border-radius: var(--akm-border-radius);
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
}

/* --- Map container --- */
.akm-map {
    width: 100%;
    z-index: 1;
    border-radius: var(--akm-border-radius);
}

/* Dark mode via CSS filter on standard OSM tiles */
.akm-dark-tiles .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(0.8) contrast(1.2);
}

/* --- Search Bar --- */
.akm-search-bar {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: 90%;
    max-width: 420px;
}

.akm-search-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--akm-search-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 50px;
    padding: 10px 18px;
    box-shadow: 0 2px 12px rgba(0,0,0,.08);
    transition: border-color .2s ease, box-shadow .2s ease;
}

.akm-search-inner:focus-within {
    border-color: var(--akm-marker-color);
    box-shadow: 0 0 0 3px rgba(22,163,74,.12), 0 2px 12px rgba(0,0,0,.08);
}

.akm-search-icon {
    width: 18px;
    height: 18px;
    color: #94a3b8;
    flex-shrink: 0;
}

.akm-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #1e293b;
    font-size: 14px;
    font-family: var(--akm-font);
    min-width: 0;
}

.akm-search-input::placeholder {
    color: #94a3b8;
}

.akm-search-count {
    font-size: 12px;
    color: var(--akm-marker-color);
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.akm-search-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.06);
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: background .2s ease;
}

.akm-search-clear svg {
    width: 14px;
    height: 14px;
    color: #64748b;
}

.akm-search-clear:hover {
    background: rgba(0,0,0,.1);
}

/* --- Stats Bar --- */
.akm-stats-bar {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--akm-search-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 50px;
    padding: 8px 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,.08);
}

.akm-stat {
    display: flex;
    align-items: center;
    gap: 6px;
}

.akm-stat svg {
    width: 16px;
    height: 16px;
    color: var(--akm-marker-color);
    flex-shrink: 0;
}

.akm-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
}

.akm-stat-label {
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
}

.akm-stat-divider {
    width: 1px;
    height: 20px;
    background: rgba(0,0,0,.1);
}

/* --- Leaflet Tooltip (popup) --- */
.akm-tooltip {
    background: var(--akm-tooltip-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 12px;
    border-left: 3px solid var(--akm-tooltip-accent);
    padding: 14px 16px;
    color: var(--akm-tooltip-text);
    font-family: var(--akm-font);
    min-width: 220px;
    max-width: 280px;
    box-shadow: 0 8px 24px rgba(0,0,0,.1), 0 2px 8px rgba(0,0,0,.06);
}

.akm-tooltip .akm-tooltip-title {
    font-size: 14px;
    font-weight: 700;
    margin: 0 0 8px;
    line-height: 1.3;
    color: #0f172a;
}

.akm-tooltip .akm-tooltip-address {
    font-size: 12px;
    color: #64748b;
    margin: 0 0 4px;
    line-height: 1.4;
}

.akm-tooltip .akm-tooltip-city {
    font-size: 12px;
    color: #64748b;
    margin: 0 0 8px;
    line-height: 1.4;
}

.akm-tooltip .akm-tooltip-type {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    background: rgba(22,163,74,.1);
    color: var(--akm-tooltip-accent);
    padding: 3px 8px;
    border-radius: 4px;
    margin-bottom: 10px;
}

.akm-tooltip .akm-tooltip-link {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--akm-tooltip-accent);
    text-decoration: none;
    transition: opacity .2s ease;
}

.akm-tooltip .akm-tooltip-link:hover {
    opacity: .75;
}

/* Override Leaflet popup default styles */
.leaflet-popup-content-wrapper {
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
}

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

.leaflet-popup-tip-container {
    display: none !important;
}

.leaflet-popup-close-button {
    display: none !important;
}

/* --- Marker Styles --- */
.akm-marker {
    transition: transform .2s ease;
}

.akm-marker:hover {
    transform: scale(1.3);
}

/* Marker pulse animation — continuous, strong signal */
@keyframes akm-pulse {
    0%   { box-shadow: 0 0 4px 0 rgba(239,68,68,.7); }
    70%  { box-shadow: 0 0 6px 12px rgba(239,68,68,0); }
    100% { box-shadow: 0 0 4px 0 rgba(239,68,68,0); }
}

.akm-marker-dot {
    width: var(--akm-marker-size);
    height: var(--akm-marker-size);
    background: #ef4444;
    border-radius: 50%;
    border: 2.5px solid #fff;
    box-shadow: 0 0 6px 2px rgba(239,68,68,.5), 0 1px 4px rgba(0,0,0,.25);
    transition: transform .2s ease;
    animation: akm-pulse 1.8s ease-out infinite;
}

.akm-marker-dot:hover {
    transform: scale(1.4);
    background: #dc2626;
    box-shadow: 0 0 10px 4px rgba(239,68,68,.6), 0 1px 4px rgba(0,0,0,.3);
    animation: akm-pulse .9s ease-out infinite;
}

/* --- Cluster Icons --- */
.akm-cluster-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    font-family: var(--akm-font);
    font-size: 13px;
    border: 3px solid rgba(255,255,255,.7);
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    transition: transform .2s ease;
}

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

.akm-cluster-small {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    font-size: 12px;
}

.akm-cluster-medium {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #16a34a, #15803d);
    font-size: 13px;
}

.akm-cluster-large {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, #15803d, #166534);
    font-size: 14px;
}

/* --- Leaflet Controls Override (light) --- */
.altkleider-map-wrapper .leaflet-control-zoom {
    border: none !important;
    border-radius: 12px !important;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,.1) !important;
}

.altkleider-map-wrapper .leaflet-control-zoom a {
    background: rgba(255,255,255,.92) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: #334155 !important;
    border: none !important;
    border-bottom: 1px solid rgba(0,0,0,.06) !important;
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    font-size: 18px !important;
    transition: background .2s ease, color .2s ease;
}

.altkleider-map-wrapper .leaflet-control-zoom a:last-child {
    border-bottom: none !important;
}

.altkleider-map-wrapper .leaflet-control-zoom a:hover {
    background: #fff !important;
    color: var(--akm-marker-color) !important;
}

/* --- Reset Zoom Button --- */
.akm-reset-btn {
    position: absolute;
    top: 80px;
    left: 10px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
    transition: background .2s ease, transform .15s ease;
    padding: 0;
}

.akm-reset-btn svg {
    width: 18px;
    height: 18px;
    color: #334155;
    transition: color .2s ease;
}

.akm-reset-btn:hover {
    background: #fff;
    transform: scale(1.05);
}

.akm-reset-btn:hover svg {
    color: var(--akm-marker-color);
}

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

/* --- Fullscreen Button --- */
.akm-fullscreen-btn {
    position: absolute;
    top: 122px;
    left: 10px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
    transition: background .2s ease;
    padding: 0;
}

.akm-fullscreen-btn svg {
    width: 18px;
    height: 18px;
    color: #334155;
    transition: color .2s ease;
}

.akm-fullscreen-btn:hover {
    background: #fff;
}

.akm-fullscreen-btn:hover svg {
    color: var(--akm-marker-color);
}

/* Fullscreen state */
.altkleider-map-wrapper.akm-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 99999 !important;
    border-radius: 0 !important;
}

.altkleider-map-wrapper.akm-fullscreen .akm-map {
    height: 100vh !important;
    border-radius: 0;
}

/* --- Loading Overlay --- */
.akm-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: var(--akm-border-radius);
    transition: opacity .3s ease;
}

.akm-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0,0,0,.08);
    border-top-color: var(--akm-marker-color);
    border-radius: 50%;
    animation: akm-spin .8s linear infinite;
}

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

.akm-loading.akm-hidden {
    opacity: 0;
    pointer-events: none;
}

/* --- Attribution --- */
.altkleider-map-wrapper .leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #94a3b8 !important;
    font-size: 10px !important;
    border-radius: 8px 0 0 0;
}

.altkleider-map-wrapper .leaflet-control-attribution a {
    color: #64748b !important;
}

/* --- Scrollbar --- */
.akm-tooltip::-webkit-scrollbar {
    width: 4px;
}

.akm-tooltip::-webkit-scrollbar-track {
    background: transparent;
}

.akm-tooltip::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,.1);
    border-radius: 2px;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .akm-search-bar {
        width: 92%;
        top: 10px;
    }

    .akm-search-inner {
        padding: 8px 14px;
    }

    .akm-search-input {
        font-size: 13px;
    }

    .akm-stats-bar {
        bottom: 10px;
        padding: 6px 16px;
        gap: 12px;
    }

    .akm-stat-value {
        font-size: 14px;
    }

    .akm-stat-label {
        font-size: 11px;
    }

    .akm-tooltip {
        min-width: 180px;
        max-width: 240px;
        padding: 10px 12px;
    }

    .akm-reset-btn {
        top: 70px;
    }

    .akm-fullscreen-btn {
        top: 112px;
    }
}
