/* CSS Custom Properties */
:root {
    --brand-green: 0 149 51; /* #009533 - Gentile Ambiente brand color */
    --brand-green-light: 0 179 61; /* Lighter variant */
    --brand-green-dark: 0 119 41; /* Darker variant */
    --status-orange: 255 165 0; /* #FFA500 - In corso */
    --status-red: 255 0 0; /* #FF0000 - In chiusura */
    --status-green: 0 149 51; /* #009533 - Chiusi */
    --background: 248 250 252; /* #F8FAFC */
    --background-gradient: linear-gradient(135deg, hsl(210 30% 98%), hsl(200 20% 95%));
    --surface: 255 255 255; /* #FFFFFF */
    --text-primary: 51 51 51; /* #333333 - Brand text color */
    --text-secondary: 100 100 100; /* #646464 */
    --text-muted: 150 150 150; /* #969696 */
    --border: 230 230 230; /* #E6E6E6 */
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    --shadow-popup: 0 20px 60px rgba(0, 0, 0, 0.3);
    --border-radius: 16px;
    --border-radius-small: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--background-gradient);
    color: hsl(var(--text-primary));
    line-height: 1.6;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* App Container */
.app-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Search Container */
.search-container {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    z-index: 2000;
}

.search-bar {
    position: relative; /* Necessario per posizionamento dropdown filtri */
    background: white;
    border-radius: 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border: 1px solid white;
}

.search-icon {
    color: hsl(var(--text-muted));
    font-size: 16px;
    margin-right: 12px;
    flex-shrink: 0;
}

#search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    color: hsl(var(--text-primary));
    padding: 4px 0;
}

#search-input::placeholder {
    color: hsl(var(--text-muted));
    font-weight: 400;
}

.clear-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: hsl(var(--text-muted));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    font-size: 12px;
    margin-left: 8px;
    transition: var(--transition);
}

.clear-btn:hover {
    background: hsl(var(--text-secondary));
}

/* Filter Toggle Button */
.filter-toggle {
    width: 40px;
    height: 40px;
    border: none;
    background: rgb(0, 149, 51); /* #009533 - Verde Gentile Ambiente */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    font-size: 14px;
    margin-left: 8px;
    transition: var(--transition);
    flex-shrink: 0;
}

.filter-toggle:hover {
    background: rgb(0, 119, 41); /* Verde più scuro */
    transform: scale(1.05);
}

.filter-toggle.active {
    background: rgb(0, 119, 41); /* Verde più scuro */
    box-shadow: 0 0 0 3px rgba(0, 149, 51, 0.2);
}

/* Filter Dropdown */
.filter-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    min-width: 220px;
    border: 1px solid #e0e0e0;
    display: none;
    z-index: 99999; /* Z-index altissimo */
    pointer-events: auto; /* Assicura che sia cliccabile */
}

.filter-dropdown.show {
    display: block !important;
    animation: fadeInUp 0.2s ease-out;
    opacity: 1 !important;
    visibility: visible !important;
}

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

.filter-header {
    padding: 16px 20px;
    border-bottom: 1px solid hsl(var(--border));
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.filter-header span {
    font-weight: 600;
    color: #333333;
    font-size: 14px;
}

.clear-filters-btn {
    background: rgb(0, 149, 51); /* Verde Gentile Ambiente */
    border: none;
    color: white; /* Testo bianco */
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.clear-filters-btn:hover {
    background: rgb(0, 149, 51); /* Mantiene stesso verde */
    color: white; /* Mantiene testo bianco */
    transform: scale(1.05); /* Effetto ingrandimento leggero */
    box-shadow: 0 2px 8px rgba(0, 149, 51, 0.3); /* Ombra verde */
}

.filter-options {
    padding: 12px 0;
}

.filter-option {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    cursor: pointer;
    transition: var(--transition);
    gap: 12px;
    outline: none !important;
    border: none !important;
}

.filter-option:focus,
.filter-option:focus-within {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
}

.filter-option:hover {
    background: #f8f9fa;
}

.filter-option input[type="checkbox"] {
    display: none;
}

.filter-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid #ddd;
    border-radius: 4px;
    position: relative;
    transition: var(--transition);
    flex-shrink: 0;
}

.filter-option input[type="checkbox"]:checked + .filter-checkbox {
    background: rgb(0, 149, 51);
    border-color: rgb(0, 149, 51);
}

.filter-option input[type="checkbox"]:checked + .filter-checkbox::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.filter-option .filter-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
}

.filter-option .filter-icon.completati {
    background: rgb(0, 149, 51); /* Verde per completati */
}

.filter-option .filter-icon.in-corso {
    background: rgb(255, 165, 0); /* Arancione per in corso */
}

.filter-option .filter-icon.in-chiusura {
    background: rgb(220, 38, 38); /* Rosso per in chiusura */
}

.filter-option .filter-label {
    font-size: 14px;
    color: hsl(var(--text-primary));
    font-weight: 500;
}

/* Mobile Responsiveness for Filter Dropdown */
@media (max-width: 768px) {
    .filter-dropdown {
        right: 0;
        left: 0;
        min-width: auto;
        margin-top: 8px;
    }
    
    .filter-option {
        padding: 16px 20px;
    }
    
    .filter-option .filter-label {
        font-size: 16px;
    }
    
    .filter-header {
        padding: 20px;
    }
    
    .filter-header span {
        font-size: 16px;
    }
    
    .clear-filters-btn {
        font-size: 14px;
        padding: 6px 12px;
    }
}

/* Search Results */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow);
    margin-top: 8px;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid hsl(var(--border));
    display: none;
}

.search-results.show {
    display: block;
}

.search-result-item {
    padding: 16px 20px;
    border-bottom: 1px solid hsl(var(--border));
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: hsl(var(--background));
}

.search-result-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    flex-shrink: 0;
}

.search-result-icon.in-corso {
    background: hsl(var(--status-orange));
}

.search-result-icon.in-chiusura {
    background: hsl(var(--status-red));
}

.search-result-icon.chiusi {
    background: hsl(var(--status-green));
}

.search-result-content {
    flex: 1;
}

.search-result-name {
    font-weight: 600;
    color: hsl(var(--text-primary));
    font-size: 14px;
    margin-bottom: 2px;
}

.search-result-client {
    font-size: 12px;
    color: hsl(var(--text-secondary));
}

.search-result-status {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 12px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.search-result-status.in-corso {
    background: hsla(var(--status-orange), 0.1);
    color: hsl(var(--status-orange));
}

.search-result-status.in-chiusura {
    background: hsla(var(--status-red), 0.1);
    color: hsl(var(--status-red));
}

.search-result-status.chiusi {
    background: hsla(var(--status-green), 0.1);
    color: hsl(var(--status-green));
}

/* Filter Container */
.filter-container {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
    z-index: 2001;
    position: relative;
    width: 100%;
}

.filter-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid hsl(var(--border));
    border-radius: 20px;
    background: hsl(var(--surface));
    color: hsl(var(--text-secondary));
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
}

.filter-btn:hover {
    background: hsl(var(--background));
    border-color: hsl(var(--text-secondary));
}

.filter-btn.active {
    background: hsl(var(--brand-green));
    border-color: hsl(var(--brand-green));
    color: white;
    box-shadow: var(--shadow);
}

.filter-btn.active .filter-icon {
    filter: brightness(1.2);
}

.filter-icon {
    font-size: 12px;
    line-height: 1;
}

.filter-text {
    font-size: 12px;
    font-weight: 600;
}

/* Map Container */
.map-container {
    width: 100%;
    height: 100%;
    border-radius: 0;
    position: relative;
    z-index: 1;
}

/* Leaflet Map Customization */
.leaflet-container {
    font-family: 'Inter', sans-serif;
}

.leaflet-popup-content-wrapper {
    display: none !important;
}

.leaflet-popup-tip {
    display: none !important;
}

/* Override any Leaflet marker styles */
.leaflet-marker-icon .custom-marker {
    background-color: inherit !important;
}

.leaflet-div-icon {
    background: transparent !important;
    border: none !important;
    outline: none !important;
}

/* Rimuovi contorno giallo dai marker */
.leaflet-marker-icon:focus,
.leaflet-div-icon:focus,
.custom-marker:focus,
.leaflet-interactive:focus {
    outline: none !important;
    border: none !important;
}

/* Custom Marker Styles */
.custom-marker-wrapper {
    cursor: pointer !important;
    position: relative;
}

.custom-marker-wrapper .custom-marker,
.custom-marker {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    background-color: hsl(var(--text-muted));
    outline: none !important;
    position: relative;
}

/* Expand clickable area with pseudo-element */
.custom-marker-wrapper::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    cursor: pointer;
    z-index: 1;
}

.custom-marker:hover,
.custom-marker-wrapper:hover .custom-marker {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.15);
}

.custom-marker-wrapper .custom-marker.in-corso,
.custom-marker.in-corso {
    background-color: hsl(var(--status-orange)) !important;
}

.custom-marker-wrapper .custom-marker.in-chiusura,
.custom-marker.in-chiusura {
    background-color: hsl(var(--status-red)) !important;
}

.custom-marker-wrapper .custom-marker.chiusi,
.custom-marker.chiusi {
    background-color: hsl(var(--status-green)) !important;
}

/* Loading Container */
.loading-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--background-gradient);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

.loading-container.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid hsl(var(--border));
    border-top: 3px solid hsl(var(--brand-green));
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

.loading-container p {
    color: hsl(var(--text-secondary));
    font-weight: 500;
}

/* Popup Modal */
.popup-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    visibility: hidden;
    opacity: 0;
    transition: var(--transition);
}

.popup-modal.active {
    visibility: visible;
    opacity: 1;
}

.popup-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
}

/* Nuovo Design Popup */
.popup-content {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: white;
    border-radius: 20px 20px 0 0;
    box-shadow: var(--shadow-popup);
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 85vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.popup-modal.active .popup-content {
    transform: translateY(0);
}

/* Pulsante chiusura */
.popup-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: var(--transition);
    z-index: 10;
    backdrop-filter: blur(10px);
}

.popup-close-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

/* Container immagine con badge */
.popup-image-container {
    position: relative;
    width: 100%;
    height: 220px;
    overflow: hidden;
}

.cantiere-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cantiere-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgb(0, 149, 51), rgb(0, 179, 61));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.cantiere-placeholder i {
    font-size: 48px;
    opacity: 0.8;
}

/* Badge di stato sovrapposto */
.status-badge-overlay {
    position: absolute;
    top: 16px;
    left: 16px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.status-badge-overlay.in-corso {
    background: rgba(255, 165, 0, 0.9);
    color: white;
}

.status-badge-overlay.in-chiusura {
    background: rgba(255, 0, 0, 0.9);
    color: white;
}

.status-badge-overlay.chiusi {
    background: rgba(0, 149, 51, 0.9);
    color: white;
}

/* Sezione informazioni popup */
.popup-info {
    padding: 24px;
}

.cantiere-title {
    font-size: 24px;
    font-weight: 700;
    color: #333333;
    margin-bottom: 24px;
    line-height: 1.3;
}

.cantiere-details {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 16px;
}

.detail-icon {
    width: 48px;
    height: 48px;
    background: rgba(0, 149, 51, 0.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.detail-icon i {
    font-size: 20px;
    color: rgb(0, 149, 51);
    line-height: 1;
}

.detail-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: center;
}

.detail-label {
    font-size: 13px;
    font-weight: 600;
    color: hsl(var(--text-secondary));
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.2;
    margin-bottom: 2px;
}

.detail-value {
    font-size: 17px;
    font-weight: 500;
    color: #333333;
    line-height: 1.3;
}

/* Responsive Design */
@media (min-width: 768px) {
    .popup-content {
        left: 50%;
        transform: translateX(-50%) translateY(100%);
        width: 100%;
        max-width: 480px;
        border-radius: 20px;
        bottom: 40px;
    }
    
    .popup-modal.active .popup-content {
        transform: translateX(-50%) translateY(0);
    }
    
    .cantiere-title {
        font-size: 28px;
    }
    
    .popup-image-container {
        height: 260px;
    }
    
    .popup-info {
        padding: 32px;
    }
}

@media (min-width: 1024px) {
    .popup-content {
        max-width: 520px;
    }
    
    .popup-image-container {
        height: 280px;
    }
}

/* Touch optimizations for mobile */
@media (max-width: 767px) {
    .popup-content {
        padding-bottom: env(safe-area-inset-bottom, 20px);
    }
    
    .popup-close-btn {
        width: 44px;
        height: 44px;
        top: 12px;
        right: 12px;
    }
    
    .popup-info {
        padding: 20px;
    }
    
    .cantiere-title {
        font-size: 22px;
        margin-bottom: 20px;
    }
    
    .detail-item {
        gap: 12px;
    }
    
    .detail-icon {
        width: 44px;
        height: 44px;
    }
    
    .detail-value {
        font-size: 16px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
.close-btn:focus,
.custom-marker:focus {
    outline: 2px solid hsl(var(--brand-green));
    outline-offset: 2px;
}


/* Admin Login Button */
.admin-login-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    background: rgba(0, 149, 51, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    z-index: 1000;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.admin-login-btn:hover {
    background: rgba(0, 149, 51, 1);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 149, 51, 0.4);
    color: white;
}

.admin-login-btn i {
    font-size: 20px;
}

@media (max-width: 768px) {
    .admin-login-btn {
        bottom: 15px;
        left: 15px;
        width: 45px;
        height: 45px;
    }
    
    .admin-login-btn i {
        font-size: 18px;
    }
}
/* FORCE CACHE BUST FOR DEPLOYMENT */
/* DEPLOYMENT CACHE BUST v1751455400 */

/* Removed pin marker styles - using simple circles for stability */
