/* Mapa Punktów Zbiórki - V3 - Sidebar Absolute */

:root {
    --radius-m: clamp(1rem, calc(0.19vw + 0.94rem), 1.2rem);
}

/* ===== LAYOUT WRAPPER ===== */
.mapa-punktow-wrapper {
    font-family: 'Roboto', sans-serif;
    max-width: 100%;
    min-height: 600px;
    position: relative;
}

/* ===== SIDEBAR DESKTOP - ABSOLUTE POSITIONED ===== */
.mapa-sidebar {
    position: absolute;
    left: 0px;
    top: 50%;
    transform: translateY(-50%);
    width: 340px;
    max-height: calc(100% - 40px);
    background: #fff;
    border-top-right-radius: var(--radius-m);
    border-bottom-right-radius: var(--radius-m);
    z-index: 600;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.mapa-sidebar.sidebar-collapsed {
    transform: translate(-100%, -50%);
    /* Opacity removed - sidebar container stays visible for toggle button */
}

.mapa-sidebar.sidebar-collapsed .mapa-sidebar-inner {
    opacity: 0; /* Hide sidebar content */
    pointer-events: none; /* Disable clicks on content */
}

.mapa-sidebar.sidebar-collapsed .sidebar-toggle-btn {
    pointer-events: auto; /* Keep toggle button clickable */
}

/* Sidebar toggle button - INSIDE sidebar */
.sidebar-toggle-btn {
    position: absolute;
    left: 100%; /* Positioned at the right edge of sidebar */
    top: 20px;
    width: 40px;
    height: 60px;
    background: #2a3a88;
    color: #fff;
    border: none;
    border-radius: 0 var(--radius-m) var(--radius-m) 0;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    z-index: 601;
}

.sidebar-toggle-btn:hover {
    background: #1e2a60;
}

.sidebar-toggle-icon {
    transition: transform 0.3s;
}

.mapa-sidebar.sidebar-collapsed .sidebar-toggle-icon {
    transform: rotate(180deg);
}

.mapa-sidebar-inner {
    padding: 25px 20px;
    /*overflow-y: auto;*/
    flex: 1;
    transition: opacity 0.4s ease;
}

/* Custom scrollbar for sidebar */
.mapa-sidebar-inner::-webkit-scrollbar {
    width: 6px;
}

.mapa-sidebar-inner::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.mapa-sidebar-inner::-webkit-scrollbar-thumb {
    background: #2a3a88;
    border-radius: 3px;
}

.mapa-sidebar-inner::-webkit-scrollbar-thumb:hover {
    background: #1e2a60;
}

.mapa-sidebar-title {
    margin: 0 0 20px 0;
    font-size: 20px;
    font-weight: 600;
    color: #2a3a88;
}

/* ===== MOBILE PANEL ===== */
.mapa-mobile-panel {
    display: none;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    position: relative;
    z-index: 500;
}

.btn-toggle {
    width: 100%;
    padding: 15px 20px;
    background: #2a3a88;
    color: #fff;
    border: none;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.3s;
}

.btn-toggle:hover {
    background: #1e2a60;
}

.toggle-icon {
    transition: transform 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-icon svg {
    display: block;
}

.toggle-icon.rotated {
    transform: rotate(180deg);
}

.mapa-mobile-filters {
    padding: 15px;
    background: #f9f9f9;
}

/* ===== FILTER GROUPS ===== */
.mapa-filter-group {
    margin-bottom: 18px;
}

.mapa-filter-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: #2a3a88;
}

.mapa-filter-group input[type="text"],
.mapa-filter-group select {
    width: 100%;
    padding: 0 12px;
    height: 44px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Roboto', sans-serif;
    color: #000;
    background: #fff;
    transition: border-color 0.3s;
}

.mapa-filter-group input[type="text"]:focus,
.mapa-filter-group select:focus {
    outline: none;
    border-color: #2a3a88;
}

.mapa-filter-group select:disabled {
    background: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

/* Placeholder styling - darker color */
.mapa-filter-group input::placeholder {
    color: #666;
    opacity: 1;
}

.mapa-filter-group input::-webkit-input-placeholder {
    color: #666;
    opacity: 1;
}

.mapa-filter-group input::-moz-placeholder {
    color: #666;
    opacity: 1;
}

.mapa-filter-group input:-ms-input-placeholder {
    color: #666;
    opacity: 1;
}

.help-text {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #666;
    font-style: italic;
}

/* ===== LOCATION INPUT WITH BUTTON ===== */
.location-input-wrapper {
    display: flex;
    gap: 8px;
}

.location-input-wrapper input {
    flex: 1;
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    background: #2a3a88;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
    flex-shrink: 0;
}

.btn-icon:hover {
    background: #1e2a60;
}

.btn-icon:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.icon-location,
.icon-search {
    display: block;
    line-height: 1;
}

/* ===== RADIUS INPUT WRAPPER (with clear button) ===== */
.radius-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.radius-input-wrapper select {
    flex: 1;
    padding-right: 40px; /* Space for X button */
}

.btn-clear-radius {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    color: #999;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-clear-radius:hover {
    color: #e74c3c;
}

.btn-clear-radius span {
    display: block;
    line-height: 1;
}

/* ===== FILTER GROUP ROW (2 COLUMNS) ===== */
.mapa-filter-group-row {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.mapa-filter-group-half {
    flex: 1;
}

.mapa-filter-group-half:only-child {
    max-width: 100%;
}

.mapa-filter-group-half label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: #2a3a88;
}

.mapa-filter-group-half select {
    width: 100%;
    padding: 0 12px;
    height: 44px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Roboto', sans-serif;
    color: #000;
    background: #fff;
    transition: border-color 0.3s;
}

.mapa-filter-group-half select:focus {
    outline: none;
    border-color: #2a3a88;
}

.mapa-filter-group-half select:disabled {
    background: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

/* ===== GEOLOCATION BUTTON ===== */
.btn-geolocation {
    width: 100%;
    height: 44px;
    padding: 0 16px;
    background: #2a3a88;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: 'Roboto', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.btn-geolocation:hover {
    background: #1e2a60;
}

/* ===== FILTERS SECTION ===== */
.mapa-filters-section {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.filters-toggle {
    width: 100%;
    padding: 12px 16px;
    background: #f0f0f0;
    color: #2a3a88;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    font-family: 'Roboto', sans-serif;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
    margin-bottom: 15px;
}

.filters-toggle:hover {
    background: #e8e8e8;
    border-color: #2a3a88;
}

.filters-toggle-icon {
    transition: transform 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.filters-toggle-icon svg {
    display: block;
}

.filters-toggle-icon.rotated {
    transform: rotate(180deg);
}

.mapa-filters-content {
    padding-top: 10px;
    max-height: 300px;
    overflow-y: auto;
}

/* Custom scrollbar for filters */
.mapa-filters-content::-webkit-scrollbar {
    width: 6px;
}

.mapa-filters-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.mapa-filters-content::-webkit-scrollbar-thumb {
    background: #2a3a88;
    border-radius: 3px;
}

.mapa-filters-content::-webkit-scrollbar-thumb:hover {
    background: #1e2a60;
}

.filters-title {
    margin: 0 0 15px 0;
    font-size: 16px;
    font-weight: 600;
    color: #2a3a88;
}

/* ===== ACTIONS BUTTONS ===== */
.mapa-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}

.btn-primary,
.btn-secondary {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: 'Roboto', sans-serif;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.btn-primary {
    background: #2a3a88;
    color: #fff;
}

.btn-primary:hover {
    background: #1e2a60;
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

/* ===== COUNTER ===== */
.mapa-counter {
    margin-top: 20px;
    padding: 12px 15px;
    background: #f9f9f9;
    border-radius: 4px;
    text-align: center;
}

.mapa-counter span {
    font-size: 14px;
    color: #333;
}

.mapa-counter strong {
    color: #2a3a88;
    font-size: 18px;
}

/* ===== MAP CONTENT ===== */
.mapa-content {
    width: 100%;
    position: relative;
    min-height: 600px;
}

#mapa-punktow {
    width: 100%;
    height: 100%;
    min-height: 600px;
    border-radius: var(--radius-m);
    overflow: hidden;
}

/* Move zoom controls to top-right */
#mapa-punktow .leaflet-top.leaflet-left {
    left: auto;
    right: 10px;
}

/* ===== LOADING INDICATOR ===== */
#map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 25px 40px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

#map-loading span {
    font-weight: 500;
    color: #2a3a88;
    font-size: 14px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e0e0e0;
    border-top-color: #2a3a88;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Small loading spinner for popups */
.loading-spinner-small {
    width: 24px;
    height: 24px;
    border: 3px solid #e0e0e0;
    border-top-color: #2a3a88;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 10px auto;
}

/* ===== MARKER CLUSTERS ===== */
.marker-cluster {
    background-color: #2a3a88;
    border-radius: 50%;
    text-align: center;
    font-weight: bold;
    color: #fff;
}

.marker-cluster div {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: rgba(42, 58, 136, 0.8);
}

.marker-cluster-small {
    width: 30px !important;
    height: 30px !important;
    font-size: 12px;
}

.marker-cluster-medium {
    width: 40px !important;
    height: 40px !important;
    font-size: 14px;
}

.marker-cluster-large {
    width: 50px !important;
    height: 50px !important;
    font-size: 16px;
}

/* ===== SPIDERFY LINES (cluster decluttering lines) ===== */
/* Target all possible spiderfy line selectors */
.marker-cluster-spider-leg,
.leaflet-cluster-spider-leg,
path.leaflet-cluster-spider-leg,
polyline.marker-cluster-spider-leg {
    stroke: #2a3a88 !important;
    stroke-width: 2px !important;
    stroke-opacity: 0.15 !important;
    fill: none !important;
}

/* More specific for polylines in cluster context */
#mapa-punktow .leaflet-overlay-pane svg polyline {
    stroke: #2a3a88 !important;
    stroke-opacity: 0.15 !important;
    stroke-width: 2px !important;
}

/* ===== USER LOCATION MARKER ===== */
.user-location-marker {
    background: transparent;
    border: none;
}

.user-marker-dot {
    width: 20px;
    height: 20px;
    background: #2a3a88;
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ===== POPUP STYLING ===== */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.leaflet-popup-content {
    margin: 1rem 1.25rem !important;
    line-height: 1.5rem !important;
    font-size: 1.2rem !important;
}

.punkt-popup h3 {
    margin: 0 0 15px 0;
    font-size: 18px;
    color: #2a3a88;
    font-weight: 600;
}

.punkt-popup .punkt-adres {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
    line-height: 1.6;
}

.punkt-popup .punkt-details p {
    margin: 8px 0;
    font-size: 14px;
    line-height: 1.5;
}

.punkt-popup strong {
    color: #2a3a88;
}

/* ===== RESPONSIVE - TABLET ===== */
@media (max-width: 1024px) {
    .mapa-sidebar {
        width: 280px;
    }
    
    .mapa-sidebar-inner {
        padding: 20px 15px;
    }
}

/* ===== RESPONSIVE - MOBILE ===== */
@media (max-width: 768px) {
    .mapa-punktow-wrapper {
        min-height: auto;
    }
    
    /* Hide desktop sidebar and toggle button */
    .mapa-sidebar,
    .sidebar-toggle-btn {
        display: none;
    }
    
    /* Show mobile panel */
    .mapa-mobile-panel {
        display: block;
    }
    
    /* Mobile border-radius adjustments */
    .btn-toggle {
        border-top-right-radius: var(--radius-m);
        border-top-left-radius: var(--radius-m);
    }
    
    .mapa-content {
        min-height: 500px;
    }
    
    #mapa-punktow {
        min-height: 500px;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }
    
    .mapa-mobile-filters .mapa-filter-group {
        margin-bottom: 15px;
    }
    
    .mapa-actions {
        flex-direction: column;
    }
    
    .btn-primary,
    .btn-secondary {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .mapa-content {
        min-height: 400px;
    }
    
    #mapa-punktow {
        min-height: 400px;
    }
    
    .mapa-sidebar-title {
        font-size: 18px;
    }
    
    .mapa-filter-group label {
        font-size: 13px;
    }
    
    .mapa-filter-group input,
    .mapa-filter-group select {
        font-size: 13px;
        padding: 9px 10px;
    }
    
    .btn-primary,
    .btn-secondary {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    #map-loading {
        padding: 20px 30px;
    }
    
    #map-loading span {
        font-size: 13px;
    }
    
    .loading-spinner {
        width: 32px;
        height: 32px;
    }
}

/* ===== RESPONSIVE - SMALL MOBILE (480px) ===== */
@media (max-width: 480px) {
    .mapa-filter-group input,
    .mapa-filter-group select {
        font-size: 13px;
        padding: 0px 10px;
    }
}

/* ===== NETWORK-SPECIFIC MARKERS ===== */
.leaflet-marker-icon {
    transition: transform 0.2s ease;
}

.leaflet-marker-icon:hover {
    transform: scale(1.15);
    z-index: 1000 !important;
}

/* Custom select with icons for network filter */
.custom-select-wrapper {
    position: relative;
}

.custom-select {
    position: relative;
    cursor: pointer;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    min-height: 42px;
    transition: all 0.2s;
}

.custom-select-trigger:hover {
    border-color: #999;
}

.custom-select.open .custom-select-trigger {
    border-color: #2a3a88;
}

.custom-select-trigger .network-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    flex-shrink: 0;
}

.custom-select-trigger .selected-text {
    flex: 1;
    font-size: 14px;
    color: #333;
}

.custom-select-trigger .arrow {
    margin-left: auto;
    transition: transform 0.2s;
}

.custom-select.open .arrow {
    transform: rotate(180deg);
}

.custom-select-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-top: 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
}

.custom-select.open .custom-select-options {
    display: block;
}

.custom-select-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.custom-select-option:hover {
    background: #f5f5f5;
}

.custom-select-option.selected {
    background: #e8eaf6;
}

.custom-select-option .network-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    flex-shrink: 0;
}

.custom-select-option .option-text {
    flex: 1;
    font-size: 14px;
    color: #333;
}

/* Hide original select when custom select is active */
.custom-select-wrapper select {
    display: none;
}

/* Allow dropdown to overflow from filter group */
.mapa-filter-group {
    overflow: visible !important;
}

.mapa-filters-content {
    overflow: visible !important;
}

/* Button loading state */
.btn-primary.loading,
.btn-secondary.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-primary.loading::after,
.btn-secondary.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    right: 12px;
    margin-top: -8px;
    border: 2px solid #fff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: button-spin 0.6s linear infinite;
}

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