/**
 * Frontend Styles für Regional Sources Map Widget
 */

/* === Widget Container === */
.rsm-widget-wrapper {
    width: 100%;
    background: transparent; /* war #fff -> transparent für dunkle Hintergründe */
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

/* === Controls (Filter & Search) === */
.rsm-controls {
    padding: 20px;
    background: transparent; /* war #fff */
    border-bottom: 1px solid #e0e0e0;
}

.rsm-search-wrapper {
    position: relative;
    margin-bottom: 15px;
}

.rsm-search-input {
    width: 100%;
    padding: 12px 40px 12px 15px;
    border: 1px solid #dcdcdc;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1; /* Unter dem Clear-Button */
}

.rsm-search-input:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.1);
}

.rsm-search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
}

/* Clear (X) Button für Suche */
.rsm-search-clear {
    position: absolute;
    right: 36px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 12px;
    border: 1px solid #dcdcdc;
    background: #fff;
    color: #666;
    display: none; /* Standardmäßig versteckt */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    z-index: 100; /* Deutlich über dem Input */
    padding: 0;
    margin: 0;
    line-height: 1;
    pointer-events: auto; /* Sicherstellen dass Button klickbar ist */
}

.rsm-search-clear span {
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
    display: block;
}

.rsm-search-clear:hover {
    background: #f3f3f3;
    color: #333;
    border-color: #999;
}

.rsm-search-clear:active {
    transform: translateY(-50%) scale(0.95);
}

/* === Cluster ausblenden Checkbox === */
.rsm-hide-clusters-wrapper {
    margin: 0;
    padding: 15px 20px;
    background: transparent;
    border-bottom: 1px solid #e0e0e0;
}

/* Wenn Checkbox außerhalb von Controls angezeigt wird */
.rsm-widget-wrapper > .rsm-hide-clusters-wrapper {
    border-bottom: 1px solid #e0e0e0;
}

/* Wenn Checkbox innerhalb von Controls angezeigt wird */
.rsm-controls .rsm-hide-clusters-wrapper {
    margin-top: 10px;
    padding-top: 10px;
    padding-bottom: 0;
    padding-left: 0;
    padding-right: 0;
    border-top: 1px solid #e0e0e0;
    border-bottom: none;
}

.rsm-hide-clusters-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    padding: 8px 0;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    transition: color 0.2s ease;
}

.rsm-hide-clusters-checkbox:hover {
    color: #2271b1;
}

.rsm-hide-clusters-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 0;
    accent-color: #2271b1;
    flex-shrink: 0;
}

.rsm-hide-clusters-checkbox span {
    font-size: 14px;
    color: inherit;
    font-weight: 500;
}

/* === Filter Buttons === */
.rsm-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    overflow-x: auto;
    padding-top: 8px;
    padding-bottom: 8px; /* mehr vertikaler Abstand, verhindert Hover-Clipping */
}

/* Klappbare Kategorien für Mobile */
.rsm-filters-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.rsm-filters-toggle:hover {
    background: #f9f9f9;
    border-color: #2271b1;
}

.rsm-filters-toggle i {
    transition: transform 0.2s ease;
    color: #666;
}

.rsm-filters-buttons {
    display: none;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
    flex-wrap: wrap;
}

.rsm-filters-buttons[style*="flex"] {
    display: flex !important;
}

.rsm-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid #dcdcdc;
    border-radius: 20px;
    background: #fff;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.rsm-filter-btn:hover {
    border-color: #2271b1;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.rsm-filter-btn.active {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
}

.rsm-filter-btn i {
    font-size: 16px;
}

/* === Map Container === */
.rsm-map-container {
    position: relative;
    width: 100%;
    height: 600px;
    background: #ffffff; /* Standard-Hintergrundfarbe, kann über Elementor überschrieben werden */
    overflow: hidden;
}

.rsm-map-canvas {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* Wrapper für SVG und Marker */
.rsm-map-content,
.rsm-map-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    transform-origin: center center;
}

.rsm-map-canvas svg {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
    user-select: none;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1; /* SVG unter den Markern */
    pointer-events: none; /* SVG blockiert keine Klicks */
}

.rsm-map-canvas.panning svg {
    cursor: grabbing;
}

/* === Loading State === */
.rsm-map-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent; /* war #fff */
    z-index: 10;
}

.rsm-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f0f0f0;
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: rsm-spin 1s linear infinite;
}

@keyframes rsm-spin {
    to { transform: rotate(360deg); }
}

.rsm-map-loading p {
    margin-top: 15px;
    color: #666;
    font-size: 14px;
}

/* === Map Markers === */
.rsm-marker {
    position: absolute;
    cursor: pointer;
    transition: all 0.2s ease;
    /* z-index wird per JavaScript gesetzt für individuelle Kontrolle */
    transform-origin: bottom center; /* Wichtig: Marker von unten skalieren */
    pointer-events: auto !important; /* Sicherstellen dass Marker klickbar sind */
}

.rsm-marker svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    display: block !important;
    width: 30px !important;
    height: 30px !important;
    position: relative !important;
    z-index: 1 !important;
}

/* Debug-Rahmen entfernt */

.rsm-marker.rsm-marker-hidden {
    display: none;
}

.rsm-marker.rsm-marker-pulse {
    animation: rsm-pulse 1.5s ease-in-out infinite;
}

/* Restaurant Marker Special Styling */
.rsm-restaurant-marker {
    z-index: 1000 !important; /* Höherer Z-Index für Restaurant PIN */
    opacity: 1 !important; /* Restaurant-Marker immer vollständig sichtbar */
}

.rsm-restaurant-marker::before {
    content: '';
    position: absolute;
    width: 60px;
    height: 60px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(214, 54, 56, 0.2) 0%, transparent 70%);
    animation: rsm-restaurant-pulse 2s ease-in-out infinite;
    pointer-events: none;
    z-index: 0; /* Schein unter dem Pin-SVG halten */
}

/* Sicherstellen, dass das Pin-SVG über dem Schein liegt */
.rsm-restaurant-marker svg {
    position: relative;
    z-index: 1;
}

/* Bezugsquellen-Marker Transparenz-Unterstützung */
.rsm-marker:not(.rsm-restaurant-marker) {
    transition: opacity 0.3s ease, transform 0.2s ease;
}

/* Hover-Effekt für Bezugsquellen-Marker mit Transparenz-Unterstützung */
.rsm-marker:not(.rsm-restaurant-marker):hover {
    opacity: 1 !important; /* Bei Hover vollständig sichtbar */
    transform: scale(1.2);
    z-index: 1500 !important; /* Höherer Z-Index beim Hover */
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
    transition: all 0.3s ease;
}

/* Cluster-Marker Styling */
.rsm-cluster-marker {
    z-index: 1000 !important; /* Höherer Z-Index für Cluster */
    transition: transform 0.2s ease, filter 0.2s ease, opacity 0.3s ease;
}

.rsm-cluster-marker:hover {
    transform: scale(1.1);
    z-index: 1500 !important; /* Höherer Z-Index beim Hover */
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

.rsm-cluster-marker svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    display: block !important;
    width: 40px !important;
    height: 40px !important;
    position: relative !important;
    z-index: 1 !important;
}

@keyframes rsm-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

@keyframes rsm-restaurant-pulse {
    0%, 100% {
        opacity: 0.5;
        transform: translate(-50%, -50%) scale(0.8);
    }
    50% {
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(1.2);
    }
}

/* === Popup === */
.rsm-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: rsm-popup-fade-in 0.3s ease;
}

/* === Tooltips & Labels === */
.rsm-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    font-size: 12px;
    padding: 6px 8px;
    border-radius: 4px;
    pointer-events: none;
    white-space: nowrap;
    z-index: 2000; /* Höherer Z-Index für Hover Text */
    transform: translateZ(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    font-weight: 500;
}

.rsm-tooltip::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: -5px;
    border-width: 5px 5px 0 5px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.8) transparent transparent transparent;
}

.rsm-marker-label {
    position: absolute;
    bottom: 32px; /* über dem Pin */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 4px 6px;
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1001; /* Höher als Marker */
    font-weight: 500;
    max-width: 120px;
    text-align: center;
    word-wrap: break-word;
    line-height: 1.2;
}

.rsm-restaurant-label {
    background: #d63638;
}

.rsm-source-label {
    background: rgba(0, 0, 0, 0.8);
    font-size: 11px;
    padding: 3px 5px;
    max-width: 100px;
}

.rsm-popup.rsm-popup-fade {
    animation: rsm-popup-fade-in 0.3s ease;
}

.rsm-popup.rsm-popup-slide {
    animation: rsm-popup-slide-in 0.3s ease;
}

.rsm-popup.rsm-popup-scale {
    animation: rsm-popup-scale-in 0.3s ease;
}

@keyframes rsm-popup-fade-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes rsm-popup-slide-in {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes rsm-popup-scale-in {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.rsm-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
}

.rsm-popup-content {
    position: relative;
    width: 90%;
    max-width: 960px;
    background: #fff !important; /* Force white background, override dark mode */
    border-radius: 16px; /* Weichere Ecken */
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.25); /* Eleganterer Schatten */
    overflow: hidden;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.rsm-popup-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #e0e0e0;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.rsm-popup-close::before {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M18 6L6 18M6 6l12 12" stroke="%23333" stroke-width="2" stroke-linecap="round"/></svg>') no-repeat center;
    background-size: contain;
}

.rsm-popup-close:hover {
    background: #fff;
    border-color: #d63638;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.rsm-popup-close svg {
    stroke: #333;
    stroke-width: 2.5;
    width: 20px;
    height: 20px;
    display: none; /* Verstecken da wir ::before verwenden */
}

.rsm-popup-close:hover::before {
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M18 6L6 18M6 6l12 12" stroke="%23d63638" stroke-width="2" stroke-linecap="round"/></svg>') no-repeat center;
    background-size: contain;
}

.rsm-popup-body {
    padding: 30px;
    overflow-y: auto;
}

/* Cluster-Popup Styling */
.rsm-cluster-popup .rsm-popup-content {
    max-width: 600px;
    max-height: 80vh;
}

.rsm-cluster-sources {
    margin-top: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.rsm-cluster-source-item {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    background: #f9f9f9;
    transition: background-color 0.2s ease;
}

.rsm-cluster-source-item:hover {
    background: #f0f0f0;
}

.rsm-cluster-source-item:last-child {
    margin-bottom: 0;
}

.rsm-cluster-source-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.rsm-cluster-source-logo {
    width: 40px;
    height: 40px;
    margin-right: 12px;
    flex-shrink: 0;
}

.rsm-cluster-source-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.rsm-cluster-source-logo i {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #4a90e2;
    color: white;
    border-radius: 50%;
    font-size: 16px;
}

.rsm-cluster-source-info {
    flex: 1;
}

.rsm-cluster-source-name {
    margin: 0 0 5px 0;
    font-size: 16px;
    font-weight: 600;
    color: #1d2327;
}

.rsm-cluster-source-category {
    font-size: 12px;
    color: #666;
    background: #e8f4fd;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
}

.rsm-cluster-source-category i {
    margin-right: 4px;
}

.rsm-cluster-source-products {
    font-size: 14px;
    color: #555;
    margin-bottom: 10px;
    line-height: 1.4;
}

.rsm-cluster-source-actions {
    text-align: right;
}

.rsm-cluster-source-link {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    background: #4a90e2;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.rsm-cluster-source-link:hover {
    background: #357abd;
    color: white;
    text-decoration: none;
}

.rsm-cluster-source-link i {
    margin-right: 4px;
}

/* === Popup Content === */
.rsm-popup-header {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 20px;
}

.rsm-popup-logo {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rsm-popup-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rsm-popup-logo i {
    font-size: 36px;
    color: #999;
}

.rsm-popup-info {
    flex: 1;
}

.rsm-popup-title {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 600;
    color: #1d2327;
}

.rsm-popup-location {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #666;
    font-size: 14px;
    margin-bottom: 8px;
}

/* Kategorie-Label neben Ort */
.rsm-popup-category-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: #2271b1;
    color: #fff;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    margin-left: 10px;
}

.rsm-popup-location i {
    color: #999;
}


.rsm-popup-details {
    margin-top: 20px;
}

.rsm-popup-section {
    margin-bottom: 20px;
}

.rsm-popup-section:last-child {
    margin-bottom: 0;
}

/* Layout für Kategorie und Website-Button nebeneinander */
.rsm-popup-actions {
    display: flex;
    justify-content: center; /* Button mittig positionieren */
    align-items: center;
    gap: 20px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.rsm-popup-category-section {
    display: none; /* Kategorie-Sektion verstecken */
}

.rsm-popup-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rsm-popup-section-title i {
    color: #2271b1;
}

.rsm-popup-category {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    background-color: #2271b1;
}

.rsm-popup-category i {
    font-size: 16px;
}

.rsm-popup-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #2271b1;
    color: #fff !important; /* Button-Text immer weiß, theme-unabhängig */
    text-decoration: none !important; /* Unterstrichenen Text entfernen */
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(34, 113, 177, 0.2);
}

.rsm-popup-link:hover {
    background: #135e96;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(34, 113, 177, 0.3);
}

.rsm-popup-link i {
    font-size: 16px;
}

/* === Restaurant Popup Specific Styles === */
.rsm-popup-description {
    color: #666;
    line-height: 1.6;
    margin-bottom: 0;
}

/* === No Results === */
.rsm-no-results {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #999;
}

.rsm-no-results i {
    font-size: 48px;
    margin-bottom: 15px;
}

.rsm-no-results p {
    margin: 0;
    font-size: 16px;
}

/* === Zoom Controls (optional für Frontend) === */
.rsm-zoom-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}

.rsm-zoom-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #dcdcdc;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.rsm-zoom-btn:hover {
    background: #f9f9f9;
    transform: scale(1.05);
}

/* Desktop: normale Darstellung ohne Toggle */
@media (min-width: 769px) {
    .rsm-filters-toggle {
        display: none !important;
    }
    
    .rsm-filters-buttons {
        display: flex !important;
        flex-direction: row;
        flex-wrap: wrap;
        border-top: none;
        margin-top: 0;
        padding-top: 0;
    }
}

/* === Mobile Responsive === */
@media (max-width: 768px) {
    .rsm-controls {
        padding: 15px;
    }
    
    .rsm-search-input {
        font-size: 16px; /* Verhindert Auto-Zoom auf iOS */
    }
    
    .rsm-filters {
        flex-direction: column;
        overflow-x: visible;
    }
    
    /* Klappbare Kategorien auf Mobile - standardmäßig zugeklappt */
    .rsm-filters-buttons {
        display: none !important; /* Standardmäßig zugeklappt */
    }
    
    .rsm-filters-toggle {
        display: flex;
    }
    
    .rsm-map-container {
        height: 400px;
    }
    
    /* Popup als Bottom Sheet auf Mobile */
    .rsm-popup {
        align-items: flex-end;
    }
    
    .rsm-popup-content {
        width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        max-height: 80vh;
    }
    
    .rsm-popup-body {
        padding: 25px 20px;
    }
    
    .rsm-popup-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .rsm-popup-title {
        font-size: 20px;
    }
    
    /* Mobile Layout für Actions */
    .rsm-popup-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .rsm-popup-category-section {
        text-align: center;
    }
    
    .rsm-popup-link {
        justify-content: center;
        width: 100%;
    }
    
    .rsm-zoom-controls {
        bottom: 15px;
        right: 15px;
        gap: 6px;
    }
    
    .rsm-source-label {
        font-size: 10px;
        padding: 2px 4px;
        max-width: 80px;
    }
    
    .rsm-restaurant-label {
        font-size: 11px;
        padding: 3px 5px;
        max-width: 100px;
    }

/* === Touch Optimizations === */
@media (hover: none) and (pointer: coarse) {
    .rsm-marker {
        /* Größere Touch-Targets auf Touchscreens */
        padding: 10px;
        margin: -10px;
    }
    
    .rsm-filter-btn {
        padding: 10px 18px;
    }
}

/* === Elementor Editor Live-Preview === */
.elementor-editor .rsm-widget-wrapper {
    /* Spezielle Styles für Elementor Editor */
    border: 2px dashed #2271b1;
    background: rgba(34, 113, 177, 0.05);
    position: relative;
}

.elementor-editor .rsm-widget-wrapper::before {
    content: 'Live-Vorschau: Regional Sources Map';
    position: absolute;
    top: -25px;
    left: 0;
    background: #2271b1;
    color: white;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 4px 4px 0 0;
    z-index: 1000;
}

.elementor-editor .rsm-map-container {
    /* Minimale Höhe für Editor-Vorschau */
    min-height: 300px;
}

.elementor-editor .rsm-map-loading {
    /* Loading-Spinner für Editor */
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(2px);
}

.elementor-editor .rsm-map-canvas {
    /* Canvas für Live-Updates im Editor */
    transition: all 0.3s ease;
}

/* Live-Update Animation */
.rsm-live-update {
    animation: rsm-live-update-pulse 0.5s ease-in-out;
}

@keyframes rsm-live-update-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.02);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Elementor Editor spezifische Marker-Styles */
.elementor-editor .rsm-marker {
    /* Marker im Editor etwas größer für bessere Sichtbarkeit */
    transform: scale(1.1);
}

.elementor-editor .rsm-marker:hover {
    /* Hover-Effekt im Editor verstärken */
    transform: scale(1.3);
    z-index: 20;
}

/* Editor-spezifische Tooltip-Styles */
.elementor-editor .rsm-tooltip {
    /* Tooltips im Editor besser sichtbar machen */
    background: rgba(34, 113, 177, 0.95);
    border: 2px solid #2271b1;
    font-weight: 600;
}

.elementor-editor .rsm-tooltip::after {
    border-color: #2271b1 transparent transparent transparent;
}


/* ============================================================================
   COLLECTIONS STYLES
   ============================================================================ */

/* === Collection Marker (vereinfacht: nur Badge mit Zahl) === */
.rsm-collection-marker {
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

.rsm-collection-marker:hover {
    transform: scale(1.15);
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.4));
    z-index: 1000 !important;
}

.rsm-collection-marker svg {
    pointer-events: none;
}

/* Collection-Marker Badge-Styling (Kreis mit Zahl) */
.rsm-collection-marker svg circle {
    transition: all 0.3s ease;
}

.rsm-collection-marker:hover svg circle {
    fill: #135e96; /* Dunkleres Blau bei Hover */
}

/* Collection-Quelle als Einzelmarker (wenn nur 1 nach Filter übrig) */
.rsm-collection-source-single {
    /* Unterscheidet sich optisch nicht von normalen Markern */
}

/* === Collection Popup === */
.rsm-collection-popup .rsm-popup-content {
    max-width: 960px;
}

.rsm-collection-popup .rsm-popup-body {
    max-height: 75vh;
    overflow-y: auto;
    padding: 30px;
}

/* Collection Header */
.rsm-collection-header {
    padding-bottom: 20px;
    border-bottom: 1px solid #eef2f7; /* Subtilerer Trenner */
    margin-bottom: 25px;
}

.rsm-collection-badge {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #3a82c1 0%, #2271b1 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(34, 113, 177, 0.25);
    position: relative;
    overflow: visible;
}

.rsm-collection-badge-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.rsm-collection-count {
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    line-height: 1;
}

.rsm-collection-badge-inner .fa-layer-group {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    opacity: 0.9;
}

/* Collection Sources als Karten */
.rsm-collection-sources {
    display: grid;
    grid-template-columns: 1fr !important; /* Standard für Mobile */
    gap: 16px !important;
    margin-top: 0;
}

@media (min-width: 769px) {
    .rsm-collection-sources {
        grid-template-columns: repeat(2, 1fr) !important; /* 2 Spalten für Tablets */
        gap: 20px !important;
    }
}

@media (min-width: 992px) {
    .rsm-collection-sources {
        grid-template-columns: repeat(3, 1fr) !important; /* 3 Spalten für größere Desktops */
        gap: 25px !important;
    }
}

.rsm-collection-source-card {
    background: #fff;
    border: 1px solid #e0e4e8; /* Hellerer Rand */
    border-radius: 14px; /* Etwas abgerundeter */
    padding: 0;
    transition: all 0.25s ease; /* Sanfterer Übergang für alles */
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); /* Modernerer Schatten */
}

.rsm-collection-source-card:hover {
    border-color: #a7c7ed; /* Hellerer Hover-Rand */
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15); /* Ausgeprägterer Hover-Schatten */
    transform: translateY(-4px); /* Stärkerer Hover-Effekt */
}

.rsm-collection-source-card-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px 18px 12px 18px;
    background: #fff;
}

.rsm-collection-source-avatar {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 12px;
    overflow: hidden;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #e8eaed;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.rsm-collection-source-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rsm-collection-source-avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #edf2f7;
    color: #5e6a7a;
}

.rsm-collection-source-avatar-placeholder i {
    font-size: 24px;
    color: #fff;
}

.rsm-collection-source-card-info {
    flex: 1;
    min-width: 0;
}

.rsm-collection-source-card-name {
    margin: 0 0 8px 0;
    font-size: 17px;
    font-weight: 700;
    color: #1d2327;
    line-height: 1.3;
}

.rsm-collection-source-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.rsm-collection-source-category-badge {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 6px 12px !important; /* Etwas mehr Padding */
    border: 1px solid !important;
    border-radius: 20px !important; /* Abgerundeter */
    font-size: 13px !important;
    font-weight: 600 !important; /* Bold */
    background-color: transparent !important; /* Farbe kommt von inline-style */
    transition: all 0.2s ease !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important; /* Leichter Schatten */
}

.rsm-collection-source-category-badge i {
    font-size: 14px !important;
}

.rsm-collection-source-location-badge {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 6px 12px !important;
    background: #e8ebf0 !important; /* Hellgrau */
    border: 1px solid #d4dae2 !important; /* Dunklerer Rand */
    border-radius: 20px !important;
    font-size: 13px !important;
    color: #5f6368 !important;
    font-weight: 500 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important; /* Leichter Schatten */
}

.rsm-collection-source-location-badge i {
    font-size: 12px;
    color: #89929b;
}

/* Card Body */
.rsm-collection-source-card-body {
    padding: 0 18px 16px 18px;
    border-top: 1px solid #f2f4f7;
    margin-top: 8px;
    padding-top: 14px;
}

.rsm-collection-source-products {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: #f7f8fa;
    border-radius: 8px;
    font-size: 14px;
    color: #4a5568;
    line-height: 1.5;
    margin-bottom: 8px;
}

.rsm-collection-source-products i {
    flex-shrink: 0;
    color: #2271b1;
    font-size: 16px;
    margin-top: 2px;
}

.rsm-collection-source-products span {
    flex: 1;
}

.rsm-collection-source-description {
    font-size: 14px;
    color: #5f6368;
    line-height: 1.6;
    margin-top: 8px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
}

/* Card Footer */
.rsm-collection-source-card-footer {
    padding: 14px 18px 18px 18px;
    border-top: 1px solid #f2f4f7;
    background: #fbfcfe;
}

.rsm-collection-source-link {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important; /* Zentriert den Inhalt */
    gap: 8px !important;
    padding: 12px 24px !important; /* Größerer Padding */
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 9999px !important; /* Pillenförmige Buttons */
    font-size: 15px !important;
    font-weight: 700 !important; /* Bold */
    transition: all 0.3s ease !important; /* Sanfterer Übergang */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    border: 2px solid transparent !important;
}

.rsm-collection-source-link:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25) !important;
    opacity: 0.9 !important;
}

.rsm-collection-source-link i {
    font-size: 13px !important;
}

/* === Responsive Collections === */
@media (max-width: 768px) {
    .rsm-collection-popup .rsm-popup-content {
        max-width: 95%;
        margin: 10px;
    }
    
    .rsm-collection-popup .rsm-popup-body {
        padding: 20px 15px;
        max-height: 80vh;
    }
    
    .rsm-collection-header {
        margin-bottom: 20px;
        padding-bottom: 15px;
    }
    
    .rsm-collection-badge {
        width: 70px;
        height: 70px;
        border-radius: 14px;
    }
    
    .rsm-collection-count {
        font-size: 28px;
    }
    
    .rsm-collection-badge-inner .fa-layer-group {
        font-size: 16px;
    }
    
    .rsm-collection-sources {
        gap: 16px;
    }
    
    .rsm-collection-source-card {
        border-radius: 10px;
    }
    
    .rsm-collection-source-card-header {
        padding: 16px;
        gap: 12px;
    }
    
    .rsm-collection-source-avatar {
        width: 48px;
        height: 48px;
        border-radius: 10px;
    }
    
    .rsm-collection-source-card-name {
        font-size: 16px;
        margin-bottom: 10px;
    }
    
    .rsm-collection-source-card-meta {
        gap: 8px;
    }
    
    .rsm-collection-source-category-badge,
    .rsm-collection-source-location-badge {
        font-size: 12px;
        padding: 5px 10px;
    }
    
    .rsm-collection-source-card-body {
        padding: 0 16px 16px 16px;
        padding-top: 16px;
    }
    
    .rsm-collection-source-card-footer {
        padding: 16px;
    }
    
    .rsm-collection-source-link {
        width: 100%;
        justify-content: center;
        padding: 12px 20px;
    }
}

/* Zweispaltiges Grid ab Tablet-Breite */
/*  @media (min-width: 640px) {
    .rsm-collection-sources {
        grid-template-columns: repeat(2, 1fr);
    }
} */

/* Dark-Mode-Unterstützung entfernt: Popups und Karten folgen immer den hellen Styles */

/* === Animation für Collection-Marker === */
@keyframes rsm-collection-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.rsm-collection-marker.rsm-highlight {
    animation: rsm-collection-pulse 0.6s ease-in-out;
}

/* ============================================================================
   TABLE WIDGET STYLES
   ============================================================================ */

/* === Table Wrapper === */
.rsm-table-wrapper {
    width: 100%;
    background: transparent;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

/* === Table Controls (Filter & Search) === */
.rsm-table-controls {
    padding: 20px;
    background: transparent;
    border-bottom: 1px solid #e0e0e0;
}

/* === Table Container === */
.rsm-table-container {
    position: relative;
    width: 100%;
    background: #ffffff;
    overflow-x: auto;
}

.rsm-table-loading {
    position: relative;
    padding: 60px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
}

/* === Table === */
.rsm-table-content {
    width: 100%;
}

.rsm-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: 14px;
}

.rsm-table thead {
    background: linear-gradient(to bottom, #f8f9fa 0%, #f0f2f5 100%);
    border-bottom: 2px solid #e0e0e0;
}

.rsm-table th {
    padding: 16px 20px;
    text-align: left;
    font-weight: 600;
    color: #1d2327;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.rsm-table tbody tr {
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

.rsm-table tbody tr:hover {
    background-color: #f8f9fa;
}

.rsm-table td {
    padding: 16px 20px;
    vertical-align: middle;
    color: #333;
}

/* === Table Columns === */
.rsm-table-logo {
    width: 60px;
    text-align: center;
}

.rsm-table .rsm-table-logo img, .rsm-table-logo img, .rsm-table-wrapper .rsm-table .rsm-table-logo > img {
    /* Fixe, einheitliche Logo-Größe – robust gegen globale img-Resets (Astra/Elementor) */
    width: 48px !important;
    height: 48px !important;
    inline-size: 48px !important;
    block-size: 48px !important;
    aspect-ratio: 1 / 1 !important;
    max-width: none !important; /* Überschreibt img { max-width: 100% } */
    max-height: none !important;
    object-fit: contain !important;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    background: #fff;
    display: inline-block !important; /* verhindert baseline-Verschiebungen und Theme Overrides */
}

.rsm-table-logo i {
    font-size: 24px;
    color: #999;
}

.rsm-table-name {
    font-weight: 600;
    color: #1d2327;
}

.rsm-table-name-link {
    color: #1d2327;
    text-decoration: none;
    transition: color 0.2s ease;
}

.rsm-table-name-link:hover {
    color: #2271b1;
    text-decoration: underline;
}

.rsm-table-category {
    min-width: 150px;
}

.rsm-table-category-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 2px solid;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.rsm-table-category-badge i {
    font-size: 12px;
}

.rsm-table-location {
    color: #666;
}

.rsm-table-products {
    color: #555;
    max-width: 300px;
}

.rsm-table-action {
    text-align: center;
    width: 120px;
}

.rsm-table-action-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #2271b1;
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 0; /* wie Button verhalten */
    appearance: none;
    line-height: 1.2;
}

.rsm-table-action-link:hover {
    background: #135e96;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(34, 113, 177, 0.3);
}

.rsm-table-action-link i {
    font-size: 12px;
}

/* === Table Robustness gegen Theme/Builder Overrides (Astra/Elementor) === */
.rsm-table-wrapper .rsm-table {
    border-collapse: collapse;
    border-spacing: 0;
    table-layout: auto;
}

.rsm-table-wrapper .rsm-table th,
.rsm-table-wrapper .rsm-table td {
    background: transparent !important; /* Verhindert Theme-Hintergründe in Tabellenzellen */
}

.rsm-table-wrapper .rsm-table td a {
    text-decoration: none !important; /* Verhindert Unterstreichungen durch Themes */
}

.rsm-table-wrapper .rsm-table .rsm-table-name a {
    color: inherit; /* nutzt definiertes Link-Styling oben */
}

/* === Table Empty State === */
.rsm-table-empty {
    padding: 60px 20px;
    text-align: center;
    color: #999;
}

.rsm-table-empty i {
    font-size: 48px;
    margin-bottom: 15px;
    color: #d0d0d0;
}

.rsm-table-empty p {
    margin: 0;
    font-size: 16px;
    color: #999;
}

/* === Table Pagination === */
.rsm-table-pagination {
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    background: #fafafa;
}

.rsm-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.rsm-pagination-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid #dcdcdc;
    border-radius: 6px;
    background: #fff;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 44px;
    justify-content: center;
}

.rsm-pagination-btn:hover:not(.disabled) {
    background: #f0f0f0;
    border-color: #2271b1;
    color: #2271b1;
}

.rsm-pagination-btn.active {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
}

.rsm-pagination-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.rsm-pagination-ellipsis {
    padding: 8px 4px;
    color: #999;
}

.rsm-pagination-info {
    text-align: center;
    margin-top: 12px;
    font-size: 13px;
    color: #666;
}

/* === Responsive Table === */
@media (max-width: 768px) {
    .rsm-table-controls {
        padding: 15px;
    }
    
    /* Listenansicht statt Tabelle */
    .rsm-table {
        display: block;
        width: 100%;
    }
    .rsm-table thead {
        display: none;
    }
    .rsm-table tbody {
        display: block;
        width: 100%;
    }
    .rsm-table tbody tr {
        display: block;
        background: #fff;
        border: 1px solid #e0e0e0;
        border-radius: 12px;
        margin: 12px 0;
        overflow: hidden;
        box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    }
    .rsm-table tbody td {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 12px 15px;
        border-bottom: 1px solid #f0f0f0;
    }
    .rsm-table tbody tr td:last-child {
        border-bottom: none;
    }
    .rsm-table tbody td::before {
        content: attr(data-label);
        min-width: 90px;
        font-weight: 600;
        color: #666;
    }
    
    .rsm-table th,
    .rsm-table td {
        padding: 12px 15px;
        font-size: 13px;
    }
    
    .rsm-table-logo {
        width: 50px;
    }
    
    .rsm-table-logo img {
        width: 40px;
        height: 40px;
    }
    
    .rsm-table-action-link {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .rsm-pagination {
        gap: 4px;
    }
    
    .rsm-pagination-btn {
        padding: 6px 12px;
        font-size: 13px;
        min-width: 36px;
    }
}

/* === Dark Mode für Table === */
@media (prefers-color-scheme: dark) {
    .rsm-table-wrapper {
        background: #1d2327;
        border-color: #3c434a;
    }
    
    .rsm-table-controls {
        background: transparent;
        border-bottom-color: #3c434a;
    }
    
    .rsm-table-container {
        background: #1d2327;
    }
    
    .rsm-table {
        background: #1d2327;
        color: #e0e0e0;
    }
    
    .rsm-table thead {
        background: linear-gradient(to bottom, #2c3338 0%, #23282d 100%);
        border-bottom-color: #3c434a;
    }
    
    .rsm-table th {
        color: #e0e0e0;
    }
    
    .rsm-table tbody tr {
        border-bottom-color: #3c434a;
    }
    
    .rsm-table tbody tr:hover {
        background-color: #2c3338;
    }
    
    .rsm-table td {
        color: #e0e0e0;
    }
    
    .rsm-table-name-link {
        color: #e0e0e0;
    }
    
    .rsm-table-name-link:hover {
        color: #2271b1;
    }
    
    .rsm-table-location {
        color: #b0b0b0;
    }
    
    .rsm-table-products {
        color: #c0c0c0;
    }
    
    .rsm-table-pagination {
        background: #23282d;
        border-top-color: #3c434a;
    }
    
    .rsm-pagination-btn {
        background: #32373c;
        border-color: #3c434a;
        color: #e0e0e0;
    }
    
    .rsm-pagination-btn:hover:not(.disabled) {
        background: #3c434a;
        border-color: #2271b1;
        color: #2271b1;
    }
    
    .rsm-pagination-info {
        color: #b0b0b0;
    }
}

}
