/**
 * FOEN Map - Frontend Styles
 */

/* Main wrapper */
.foen-map-wrapper {
    display: flex;
    gap: 0;
    width: 100%;
    max-width: 100%;
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    /* Kluczowe: wymuszamy jednakową wysokość kolumn */
    align-items: stretch;
}

/* Sidebar */
.foen-map-sidebar {
    width: 350px;
    min-width: 350px;
    max-width: 350px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e5e5e5;
    /* Sidebar nie może rosnąć ponad wysokość mapy */
    overflow: hidden;
}

.foen-sidebar-right {
    border-right: none;
    border-left: 1px solid #e5e5e5;
}

.foen-sidebar-header {
    padding: 20px;
    background: #67459b;
    color: white;
    flex-shrink: 0;
}

.foen-sidebar-header h3 {
    margin: 0 0 15px 0;
    font-size: 1.5em;
    font-weight: 600;
    color: #fff;
}

.foen-search-wrapper {
    position: relative;
}

.foen-search-input {
    width: 100%;
    padding: 12px 40px 12px 15px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
    outline: none;
    transition: box-shadow 0.2s;
}

.foen-search-input:focus {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.foen-search-input::placeholder {
    color: #999;
}

.foen-search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    pointer-events: none;
}

.foen-markers-count {
    margin-top: 12px;
    font-size: 13px;
    opacity: 0.9;
}

.foen-visible-count {
    font-weight: 700;
    font-size: 1.1em;
}

/* Markers list */
.foen-markers-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    /* Lista zajmuje pozostałą przestrzeń i ma scroll */
    min-height: 0;
}

.foen-no-results {
    padding: 30px 20px;
    text-align: center;
    color: #888;
    font-size: 14px;
}

.foen-marker-item {
    display: flex;
    gap: 12px;
    padding: 15px;
    margin-bottom: 8px;
    background: #f9f9f9;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.foen-marker-item:hover {
    background: #fff;
    border-color: #f39247;
    box-shadow: 0 2px 8px rgba(243, 146, 71, 0.15);
    transform: translateX(3px);
}

.foen-item-image {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.foen-item-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.foen-item-content {
    flex: 1;
    min-width: 0;
}

.foen-item-title {
    margin: 0 0 4px 0;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.foen-item-address {
    margin: 0 0 8px 0;
    font-size: 12px;
    color: #666;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.foen-item-actions {
    display: flex;
    gap: 6px;
}

.foen-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: #fff;
    border: 1px solid #ddd;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
}

.foen-btn:hover {
    background: #f39247;
    border-color: #f39247;
    transform: scale(1.1);
}

/* Map container */
.foen-map-container {
    flex: 1;
    min-width: 0;
    /* Mapa kontroluje wysokość całego wrappera */
}

.foen-map {
    width: 100%;
    height: 600px;
    background: #e8e8e8;
}

/* Custom marker icon */
.foen-marker-div-icon {
    background: transparent !important;
    border: none !important;
}

.foen-marker-icon {
    width: 32px;
    height: 40px;
}

.foen-marker-icon svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
}

/* Cluster styles */
.foen-cluster-icon {
    background: transparent !important;
    border: none !important;
}

.foen-cluster {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: white;
    font-weight: 700;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
    border: 3px solid rgba(255, 255, 255, 0.8);
    animation: foen-pulse 2s infinite;
}

.foen-cluster-small {
    width: 36px;
    height: 36px;
    font-size: 13px;
}

.foen-cluster-medium {
    width: 44px;
    height: 44px;
    font-size: 15px;
}

.foen-cluster-large {
    width: 52px;
    height: 52px;
    font-size: 17px;
}

@keyframes foen-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(243, 146, 71, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(243, 146, 71, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(243, 146, 71, 0);
    }
}

/* Popup styles */
.foen-popup .leaflet-popup-content-wrapper {
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.foen-popup .leaflet-popup-content {
    margin: 0;
    min-width: 200px;
}

.foen-popup .leaflet-popup-tip {
    background: white;
}

.foen-popup-content {
    padding: 15px;
}

.foen-popup-image {
    margin: -15px -15px 15px -15px;
    height: 80px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
}

.foen-popup-image img {
    max-height: 60px;
    max-width: 150px;
    object-fit: contain;
}

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

.foen-popup-content p {
    margin: 6px 0;
    font-size: 13px;
    color: #555;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.foen-popup-content .foen-icon {
    flex-shrink: 0;
}

.foen-popup-content a {
    color: #f39247;
    text-decoration: none;
}

.foen-popup-content a:hover {
    text-decoration: underline;
}

/* Leaflet overrides */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
}

.leaflet-control-zoom a {
    border: none !important;
    color: #333 !important;
}

.leaflet-control-zoom a:hover {
    background: #f39247 !important;
    color: white !important;
}

/* Responsive styles */
@media (max-width: 900px) {
    .foen-map-wrapper {
        flex-direction: column;
    }
    
    .foen-map-sidebar {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        max-height: 300px !important;
        height: auto !important;
        border-right: none;
        border-bottom: 1px solid #e5e5e5;
    }
    
    .foen-sidebar-left {
        order: 2;
    }
    
    .foen-map-container {
        order: 1;
    }
    
    .foen-sidebar-header {
        padding: 15px;
    }
    
    .foen-sidebar-header h3 {
        font-size: 1.2em;
    }
    
    .foen-markers-list {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 10px;
        padding: 10px;
    }
    
    .foen-marker-item {
        flex-shrink: 0;
        width: 250px;
        margin-bottom: 0;
    }
}

@media (max-width: 480px) {
    .foen-map-sidebar {
        max-height: 250px;
    }
    
    .foen-marker-item {
        width: 200px;
        padding: 12px;
    }
    
    .foen-item-image {
        width: 50px;
        height: 50px;
    }
    
    .foen-item-title {
        font-size: 14px;
    }
    
    .foen-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
}

/* Scrollbar styling */
.foen-markers-list::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.foen-markers-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.foen-markers-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.foen-markers-list::-webkit-scrollbar-thumb:hover {
    background: #f39247;
}
