/* Location Gallery Widget Styles */

.aliabdelhady-location-gallery {
    position: relative !important;
    width: 100%;
    min-height: 300px !important;
    display: block !important;
    box-sizing: content-box !important;
}

/* Map Container - CRITICAL: Must use content-box for Leaflet */
.elementor-widget-aliabdelhady_location_gallery .location-gallery-map,
.elementor-element .location-gallery-map,
.aliabdelhady-location-gallery .location-gallery-map,
div.location-gallery-map {
    width: 100% !important;
    height: 600px !important;
    border-radius: 12px;
    overflow: hidden !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    position: relative !important;
    z-index: 1 !important;
    min-height: 300px !important;
    max-width: 100% !important;
    display: block !important;
    box-sizing: content-box !important;
}

/* CRITICAL FIX: All Leaflet elements MUST use content-box */
.location-gallery-map *,
.location-gallery-map *:before,
.location-gallery-map *:after {
    box-sizing: content-box !important;
}

/* Ensure Leaflet container is visible and properly sized */
.location-gallery-map .leaflet-container,
.location-gallery-map.leaflet-container {
    width: 100% !important;
    height: 100% !important;
    min-height: 300px !important;
    position: relative !important;
    overflow: hidden !important;
    z-index: 1 !important;
    box-sizing: content-box !important;
}

/* Fix Leaflet panes - they need absolute positioning */
.location-gallery-map .leaflet-map-pane {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    z-index: 1 !important;
    box-sizing: content-box !important;
}

.location-gallery-map .leaflet-tile-pane {
    position: absolute !important;
    z-index: 2 !important;
    box-sizing: content-box !important;
}

.location-gallery-map .leaflet-overlay-pane {
    position: absolute !important;
    z-index: 4 !important;
    box-sizing: content-box !important;
}

.location-gallery-map .leaflet-shadow-pane {
    position: absolute !important;
    z-index: 5 !important;
    box-sizing: content-box !important;
}

.location-gallery-map .leaflet-marker-pane {
    position: absolute !important;
    z-index: 6 !important;
    box-sizing: content-box !important;
}

.location-gallery-map .leaflet-tooltip-pane {
    position: absolute !important;
    z-index: 7 !important;
    box-sizing: content-box !important;
}

.location-gallery-map .leaflet-popup-pane {
    position: absolute !important;
    z-index: 8 !important;
    box-sizing: content-box !important;
}

/* Tile container and tiles must be visible and use content-box */
.location-gallery-map .leaflet-tile-container {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    box-sizing: content-box !important;
}

.location-gallery-map .leaflet-tile {
    position: absolute !important;
    visibility: visible !important;
    opacity: 1 !important;
    box-sizing: content-box !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
}

/* Zoom animation layers */
.location-gallery-map .leaflet-zoom-animated {
    transition: transform 0.25s cubic-bezier(0,0,0.25,1);
    box-sizing: content-box !important;
}

.location-gallery-map .leaflet-layer {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    box-sizing: content-box !important;
}

/* Control containers */
.location-gallery-map .leaflet-control-container {
    position: relative !important;
    height: 100% !important;
    box-sizing: content-box !important;
}

.location-gallery-map .leaflet-control {
    box-sizing: content-box !important;
}

/* Ensure consistent dimensions */
.location-gallery-map img {
    box-sizing: content-box !important;
    border: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Custom Marker Styles */
.location-gallery-marker {
    width: 40px;
    height: 50px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.location-gallery-marker:hover {
    transform: rotate(-45deg) scale(1.1);
}

.location-gallery-marker svg {
    transform: rotate(45deg);
    margin-bottom: 8px;
}

.location-gallery-marker .marker-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #fff;
    color: #333;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    transform: rotate(45deg);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Cluster Icon Styles */
.location-gallery-cluster-icon {
    text-align: center;
}

.location-gallery-cluster-icon div {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    border: 3px solid rgba(255, 255, 255, 0.9);
    transition: all 0.3s ease;
}

.location-gallery-cluster-icon div:hover {
    transform: scale(1.15);
}

.location-gallery-cluster-icon span {
    color: white;
    font-weight: bold;
    font-size: 16px;
}

/* Popup Styles */
.location-gallery-popup {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.location-gallery-popup .leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    padding: 0;
}

.location-gallery-popup .leaflet-popup-content {
    margin: 0;
    width: 280px !important;
}

.popup-content {
    padding: 20px;
}

.popup-content h4 {
    margin: 0 0 10px;
    font-size: 18px;
    color: #333;
    font-weight: 600;
}

.popup-content .photo-count {
    margin: 0 0 15px;
    font-size: 14px;
    color: #666;
}

.popup-preview {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 15px;
    position: relative;
}

.popup-preview img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.popup-preview img:hover {
    transform: scale(1.05);
}

.popup-preview .more-photos {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
}

.popup-view-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #2596be 0%, #1b6f8d 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.popup-view-btn:hover {
    background: linear-gradient(135deg, #1b6f8d 0%, #2596be 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 150, 190, 0.4);
}

/* Slide Gallery View */
.location-gallery-view {
    margin-top: 30px;
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.gallery-title {
    margin: 0;
    font-size: 28px;
    color: #333;
    font-weight: 700;
}

.gallery-close {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-close:hover {
    background: #f0f0f0;
    transform: rotate(90deg);
}

.gallery-close svg {
    color: #666;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 25px;
}

.gallery-item {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    cursor: pointer;
}

.gallery-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.gallery-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.gallery-item-info {
    padding: 15px;
}

.gallery-item-info .item-title {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-item-info .item-date {
    margin: 0;
    font-size: 14px;
    color: #999;
}

/* Empty State */
.location-gallery-empty {
    padding: 60px 20px;
    text-align: center;
    color: #999;
    font-size: 18px;
    background: #f9f9f9;
    border-radius: 12px;
    border: 2px dashed #ddd;
}

/* GLightbox Customization */
.glightbox-clean .gslide-description {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 8px;
}

.glightbox-clean .gslide-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .location-gallery-map {
        height: 400px;
    }

    .popup-content {
        padding: 15px;
    }

    .popup-content h4 {
        font-size: 16px;
    }

    .popup-preview {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .popup-preview img {
        height: 60px;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }

    .gallery-item img {
        height: 150px;
    }

    .gallery-title {
        font-size: 22px;
    }

    .location-gallery-view {
        padding: 20px 15px;
    }
}

@media (max-width: 480px) {
    .location-gallery-map {
        height: 350px;
        border-radius: 8px;
    }

    .popup-preview {
        grid-template-columns: 1fr;
    }

    .gallery-grid {
        grid-template-columns: 1fr;
    }
}

/* Loading Animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.location-gallery-map.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2596be;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
/* CRITICAL FIX - Force absolute positioning for Leaflet elements */
.location-gallery-map .leaflet-pane,
.location-gallery-map .leaflet-map-pane,
.location-gallery-map .leaflet-tile-pane,
.location-gallery-map .leaflet-overlay-pane,
.location-gallery-map .leaflet-shadow-pane,
.location-gallery-map .leaflet-marker-pane,
.location-gallery-map .leaflet-tooltip-pane,
.location-gallery-map .leaflet-popup-pane {
    position: absolute !important;
}

.location-gallery-map .leaflet-tile,
.location-gallery-map .leaflet-tile-container,
.location-gallery-map .leaflet-layer {
    position: absolute !important;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}