/* ----- GLOBAL STYLING ----- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f4f0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

/* ----- HEADER ----- */
.map-header {
    width: 100%;
    max-width: 1300px;
    background: linear-gradient(135deg, #1e3c2c, #2d5a3d);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    border-radius: 0 0 18px 18px;
    box-shadow: 0 8px 24px rgba(0, 20, 0, 0.3);
    margin-bottom: 8px;
    color: #f5faf5;
}

.map-header h1 {
    font-size: 1.8rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.map-header h1 small {
    font-size: 1rem;
    font-weight: 400;
    opacity: 0.8;
    margin-left: 6px;
}

.map-header .badge {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(4px);
    padding: 8px 18px;
    border-radius: 40px;
    font-size: 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
}

.map-header .badge span {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #7fc97f;
    animation: pulse-dot 1.8s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.4;
        transform: scale(0.7);
    }
}

/* ----- MAP CONTAINER ----- */
#map {
    width: 100%;
    max-width: 1300px;
    height: 620px;
    border-radius: 18px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    border: 3px solid #ffffff;
    margin: 0 20px;
    transition: all 0.2s;
    background: #e8edf0;
}

/* ----- LEGENDA (posodobljena) ----- */
.legend-container {
    width: 100%;
    max-width: 1300px;
    margin-top: 14px;
    padding: 0 10px 20px 10px;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 20px 40px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    padding: 18px 28px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    justify-content: space-between;
}

.legend-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
}

.legend-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: #1e3c2c;
    margin-bottom: 4px;
    border-bottom: 2px solid rgba(30, 60, 44, 0.15);
    padding-bottom: 4px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #2a3f2a;
}

.legend-marker {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: white;
    border: 2px solid rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

/* Barvni obroči za različne tipe */
.legend-marker.town { border-color: #c0392b; }
.legend-marker.church { border-color: #8e44ad; }
.legend-marker.sight { border-color: #2980b9; }
.legend-marker.school { border-color: #2c6e49; }
.legend-marker.library { border-color: #d4a017; }
.legend-marker.post { border-color: #f39c12; }
.legend-marker.restaurant { border-color: #e67e22; }
.legend-marker.cafe { border-color: #6c3483; }
.legend-marker.atm { border-color: #27ae60; }
.legend-marker.shop { border-color: #3498db; }
.legend-marker.bus { border-color: #2c3e50; }
.legend-marker.parking { border-color: #1a5276; }
.legend-marker.wc { border-color: #7f8c8d; }
.legend-marker.trail { border-color: #8e44ad; }
.legend-marker.hill { border-color: #2c6e49; }
.legend-marker.fire_station { border-color: #e74c3c; }
.legend-marker.industrial { border-color: #7f8c8d; }

/* ----- GUMB ZA LEGENDO (poleg gumba za lokacijo) ----- */
.legend-toggle-btn {
    background: white;
    border: 2px solid rgba(0,0,0,0.15);
    border-radius: 4px;
    width: 34px;
    height: 34px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    transition: all 0.2s;
    margin-top: 4px;
    outline: none; /* odstrani morebiten osnovni okvir */
}
.legend-toggle-btn:hover {
    background: #f0f4f0;
    border-color: #1e3c2c;
}
.legend-toggle-btn:focus {
    outline: none; /* prepreči modri okvir pri fokusu */
}

/* ----- RESPONSIVE za legendo ----- */
@media (max-width: 760px) {
    .legend {
        flex-direction: column;
        gap: 12px;
        padding: 14px 18px;
    }
    .legend-section {
        min-width: auto;
        width: 100%;
    }
    .legend-title {
        font-size: 0.8rem;
    }
    .legend-item {
        font-size: 0.8rem;
    }
    .legend-marker {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .legend {
        padding: 10px 14px;
        gap: 10px;
    }
    .legend-marker {
        width: 20px;
        height: 20px;
        font-size: 10px;
    }
}

/* ----- POPUP (Leaflet) ----- */
.leaflet-popup-content {
    font-size: 0.95rem;
    line-height: 1.5;
    min-width: 150px;
    color: #1e2e1e;
}
.leaflet-popup-content strong {
    color: #1e3c2c;
    font-size: 1.05rem;
}
.leaflet-popup-content .elev {
    display: inline-block;
    background: #eef4ee;
    padding: 2px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    color: #2d5a3d;
    margin-top: 4px;
}
.leaflet-popup-content .desc {
    font-size: 0.85rem;
    opacity: 0.75;
    margin-top: 4px;
}

/* ----- MODAL (obvestilo ob odprtju) ----- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(30, 40, 30, 0.4);
    backdrop-filter: blur(6px) saturate(1.2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-glass {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border-radius: 40px;
    padding: 2px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.3);
    max-width: 480px;
    width: 90%;
}

.modal-content {
    background: rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 38px;
    padding: 32px 28px;
    text-align: center;
    color: #1a2a1a;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.modal-content h2 {
    font-size: 1.9rem;
    font-weight: 600;
    margin-bottom: 12px;
    letter-spacing: -0.3px;
}

.modal-content p {
    font-size: 1rem;
    line-height: 1.6;
    margin: 8px 0;
    opacity: 0.9;
}

.modal-content strong {
    color: #1e3c2c;
    font-weight: 600;
}

.modal-btn {
    background: rgba(30, 60, 44, 0.9);
    border: none;
    border-radius: 60px;
    padding: 12px 34px;
    font-size: 1rem;
    font-weight: 500;
    color: #f5faf5;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.2s;
    box-shadow: 0 6px 20px rgba(30, 60, 44, 0.2);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.modal-btn:hover {
    background: rgba(44, 90, 60, 0.95);
    transform: scale(1.02);
    box-shadow: 0 8px 28px rgba(30, 60, 44, 0.3);
}

.modal-btn:active {
    transform: scale(0.97);
}

/* ----- RESPONSIVE (splošno) ----- */
@media (max-width: 760px) {
    .map-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 16px 20px;
    }
    .map-header h1 {
        font-size: 1.3rem;
        flex-wrap: wrap;
    }
    .map-header h1 small {
        font-size: 0.85rem;
        display: block;
        margin-left: 0;
    }
    #map {
        height: 450px;
        margin: 0 8px;
    }
    .legend {
        padding: 10px 16px;
        gap: 10px 18px;
        border-radius: 28px;
    }
    .modal-glass {
        max-width: 92%;
    }
    .modal-content {
        padding: 24px 18px;
    }
    .modal-content h2 {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    #map {
        height: 340px;
    }
    .map-header h1 {
        font-size: 1.1rem;
    }
    .legend-item {
        font-size: 0.75rem;
    }
    .legend-marker {
        width: 16px;
        height: 16px;
    }
}

/* ----- LEGENDA MODAL (prekrivno okno) ----- */
.legend-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
    transition: opacity 0.3s ease, backdrop-filter 0.3s ease;
}

.legend-modal-content {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 24px;
    max-width: 90%;
    max-height: 90%;
    width: 700px;
    padding: 30px 28px 25px;
    box-shadow: 0 25px 70px rgba(0,0,0,0.35);
    overflow-y: auto;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.legend-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    padding-bottom: 14px;
    margin-bottom: 18px;
}

.legend-modal-header h3 {
    margin: 0;
    font-size: 1.6rem;
    color: #1e3c2c;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.legend-modal-close {
    background: #1e3c2c;
    border: none;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    padding: 10px 22px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 14px rgba(30, 60, 44, 0.25);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 0.3px;
}

.legend-modal-close:hover {
    background: #2d5a3d;
    transform: scale(1.03);
    box-shadow: 0 6px 20px rgba(30, 60, 44, 0.35);
}

.legend-modal-close:active {
    transform: scale(0.97);
}

/* Dodamo ikono za zapiranje (mali križec) pred besedo */
.legend-modal-close::before {
    content: "✕ ";
    font-weight: 300;
    font-size: 1.2rem;
}

.legend-modal-body {
    max-height: 65vh;
    overflow-y: auto;
    padding-right: 4px;
}

/* Prilagoditev legende znotraj modala */
.legend-modal-body .legend {
    background: transparent;
    box-shadow: none;
    padding: 0;
    border: none;
    backdrop-filter: none;
    gap: 16px 30px;
}

.legend-modal-body .legend-section {
    min-width: 120px;
}

/* ----- MOBILNI: zemljevid čez cel zaslon ----- */
@media (max-width: 760px) {
    .map-header {
        padding: 10px 15px;
        border-radius: 0;
    }
    .map-header h1 {
        font-size: 1.2rem;
    }
    .map-header .badge {
        font-size: 0.7rem;
        padding: 4px 12px;
    }
    #map {
        height: calc(100vh - 60px);
        max-height: none;
        margin: 0;
        border-radius: 0;
        border: none;
        width: 100%;
        max-width: 100%;
    }
    body {
        background: #e8edf0;
    }
    .legend-modal-content {
        width: 95%;
        max-height: 92%;
        padding: 20px 16px;
        border-radius: 20px;
    }
    .legend-modal-header h3 {
        font-size: 1.3rem;
    }
    .legend-modal-close {
        font-size: 0.9rem;
        padding: 8px 16px;
    }
    .legend-modal-body .legend {
        gap: 12px 16px;
    }
}

@media (max-width: 480px) {
    .legend-modal-content {
        padding: 16px 12px;
    }
    .legend-modal-header h3 {
        font-size: 1.1rem;
    }
    .legend-modal-close {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
    .legend-modal-body .legend-item {
        font-size: 0.75rem;
    }
    .legend-modal-body .legend-marker {
        width: 22px;
        height: 22px;
        font-size: 11px;
    }
}