/**
 * Leaflet Polygon Search CSS
 * Stili per il dialog di ricerca poligonale con Leaflet
 */

/* Overlay principale */
.leaflet-polygon-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(3px);
}

/* Dialog principale */
.leaflet-polygon-dialog {
    background: white;
    border-radius: 4px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    animation: slideIn 0.3s ease-out;
}

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

/* Header del dialog */
.leaflet-polygon-header {
    background: linear-gradient(135deg, var(--second-color, #00523d) 0%, #00523d 100%);
    color: white;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.leaflet-polygon-header h3 {
    margin: 0;
    font-size: 1.2em;
    font-weight: 600;
    color: white;
}

.leaflet-polygon-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.leaflet-polygon-close-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Contenuto del dialog */
.leaflet-polygon-content {
    padding: 20px;
}

#leaflet-polygon-map {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 15px;
}

.leaflet-polygon-instructions {
    padding: 0px;
    margin-top: 10px;
}

.leaflet-polygon-instructions p {
    margin: 0;
    color: #666;
    font-size: 0.9em;
    line-height: 1.4;
}

/* Footer con pulsanti */
.leaflet-polygon-footer {
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    border-top: 1px solid #e0e0e0;
}

.leaflet-polygon-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 100px;
}

.leaflet-polygon-btn-reset {
    background: #6c757d;
    color: white;
}

.leaflet-polygon-btn-reset:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.leaflet-polygon-btn-confirm {
    background: var(--second-color, #bda450);
    color: white;
}

.leaflet-polygon-btn-confirm:hover:not(:disabled) {
    background: #00523d !important;
    transform: translateY(-1px);
}

.leaflet-polygon-btn-confirm:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.leaflet-polygon-btn-close {
    background: #dc3545;
    color: white;
}

.leaflet-polygon-btn-close:hover {
    background: #c82333;
    transform: translateY(-1px);
}

.leaflet-control {
    display: none !important;
}

/* Stili per i controlli di Leaflet */
.leaflet-draw-toolbar {
    margin-top: 10px !important;
}

.leaflet-draw-toolbar a {
    background-color: white !important;
    border: 2px solid var(--second-color, #00523d) !important;
    color: var(--second-color, #00523d) !important;
}

.leaflet-draw-toolbar a:hover {
    background-color: var(--second-color, #00523d) !important;
    color: white !important;
}

.leaflet-draw-toolbar .leaflet-draw-draw-polygon {
    background-image: none !important;
}

.leaflet-draw-toolbar .leaflet-draw-draw-polygon:before {
    content: "🔲";
    font-size: 16px;
    line-height: 26px;
    text-align: center;
    display: block;
}

/* Responsive design */
@media (max-width: 768px) {
    .leaflet-polygon-dialog {
        width: 95%;
        max-width: none;
        margin: 10px;
    }
    
    .leaflet-polygon-header {
        padding: 15px;
    }
    
    .leaflet-polygon-content {
        padding: 15px;
    }
    
    #leaflet-polygon-map {
        height: 300px !important;
    }
    
    .leaflet-polygon-footer {
        padding: 15px;
        flex-direction: column;
    }
    
    .leaflet-polygon-btn {
        width: 100%;
        margin-bottom: 5px;
    }
}

/* Stili per la compatibilità con il design esistente */
.mapsearch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--second-color, #bda450);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    position: relative;
}

.mapsearch:hover {
    background: #a89840;
    transform: translateY(-1px);
    color: white;
    text-decoration: none;
}

.mapsearch i {
    font-size: 1.1em;
}

/* Stili per il pulsante quando c'è un poligono attivo */
.mapsearch.has-active-polygon {
    background: #28a745;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.3);
}

.mapsearch.has-active-polygon:hover {
    background: #218838;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.4);
}

/* Animazione per l'indicatore del poligono attivo */
@keyframes polygonPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(40, 167, 69, 0.4);
    }
    50% {
        opacity: 0.9;
        transform: scale(1.1);
        box-shadow: 0 4px 16px rgba(40, 167, 69, 0.6);
    }
}

.polygon-active-indicator {
    position: absolute !important;
    top: -8px !important;
    right: -8px !important;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
    color: white !important;
    width: 24px !important;
    height: 24px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 12px !important;
    font-weight: bold !important;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.4) !important;
    border: 2px solid white !important;
    animation: polygonPulse 2s infinite !important;
    z-index: 10 !important;
    cursor: pointer !important;
}

.polygon-active-indicator:hover {
    transform: scale(1.05) !important;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.6) !important;
}

.polygon-active-indicator svg {
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

/* Indicatore area selezionata */
.update-poly {
    margin-top: 10px;
    padding: 10px;
    background: #e8f5e8;
    border: 1px solid #28a745;
    border-radius: 4px;
    color: #155724;
    font-size: 0.9em;
}

.update-poly:before {
    content: "✓ ";
    color: #28a745;
    font-weight: bold;
}

.leaflet-polygon-instructions {
    border-left: 0px;
    padding: 0px;
    border-radius: 0px;
    margin-top: 10px;
}

.update-poly:after {
    content: "Area di ricerca selezionata sulla mappa";
}

/* Nascondere gli elementi Google Maps specifici */
.dot2dot-overlay,
.dot2dot-dialog {
    display: none !important;
}

/* Override degli stili di Leaflet per una migliore integrazione */
.leaflet-container {
    font-family: inherit;
}

.leaflet-popup-content-wrapper {
    border-radius: 6px;
}

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