/* Stili generali */
body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    overflow-x: hidden;
    box-sizing: border-box;
}

* {
    box-sizing: border-box;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
}

.title {
    width: 100%;
    text-align: center;
    font-size: 12px;
    margin-top: 6px;
    margin-bottom: 6px;


}

/* Stili per il form di caricamento */
.upload-form {
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.upload-form input[type="text"] {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    flex: 1;
    min-width: 200px;
}

.upload-form input[type="file"] {
    flex: 2;
    min-width: 200px;
}

.upload-form button {
    padding: 8px 16px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.upload-form button:hover {
    background-color: #45a049;
}

/* Stili per la mappa */
#map {
    width: 100%;
    height: 500px;
    border-radius: 8px;
    margin-bottom: 20px;
}

/* Stili per la legenda */
.legend {
    position: static;
    background-color: white;
    padding: 10px;
    border-radius: 4px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
    margin-top: 20px;
    width: calc(100% - 20px);
    font-size: 14px;
    box-sizing: border-box;
}

.legend-title {
    font-weight: bold;
    margin-bottom: 10px;
    font-size: 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.legend-color {
    width: 20px;
    height: 16px;
    margin-right: 10px;
}

.legend-label-container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.track-name {
    font-weight: normal;
}

.max-speed-label {
    cursor: pointer;
    transition: color 0.2s;
    font-size: 14px;
    color: red;
    font-weight: bold;
    margin-left: 10px;
}

.max-speed-label:hover {
    color: #ff6666;
    text-decoration: underline;
}

.track-toggle {
    cursor: pointer;
}

/* Stili per la legenda delle velocità */
.speed-legend {
    margin-top: 15px;
    margin-bottom: 15px;
}

.speed-gradient {
    height: 20px;
    width: 100%;
    background: linear-gradient(to right, #00ff00, #ff0000, #ff00ff);
    margin-bottom: 5px;
    border-radius: 3px;
}

.speed-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
}

/* Stili per il popup delle velocità massime */
.max-speed-popup h3 {
    margin: 0 0 5px 0;
    color: #333;
    font-size: 14px;
}

.max-speed-popup p {
    margin: 5px 0;
}

/* Stili per il popup */
.track-popup {
    min-width: 250px;
}

.popup-container {
    display: flex;
    align-items: flex-start;
}

.popup-image {
    flex: 0 0 80px;
    margin-right: 10px;
}

.image-placeholder {
    width: 80px;
    height: 80px;
    background-color: #f0f0f0;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 10px;
}

.image-placeholder::before {
    content: 'Immagine';
}

.popup-content {
    flex: 1;
}

.popup-content h3 {
    margin: 0 0 5px 0;
    font-size: 16px;
    color: #333;
}

.popup-content p {
    margin: 5px 0;
    font-size: 12px;
    color: #666;
}

.popup-content .date {
    font-style: italic;
}

.popup-content .speed {
    font-weight: bold;
    color: #4CAF50;
}

/* Personalizzazione del popup di Leaflet */
.leaflet-popup-close-button {
    /* Posiziona il bottone di chiusura correttamente */
    top: 12px !important; 
    right: 12px !important;
}
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    padding: 0;
}

.leaflet-popup-content {
    margin: 12px;
    line-height: 1.4;
}

/* Media queries per responsive design */

/* Stili specifici per il popup su mobile */
@media (max-width: 768px) {
    .upload-form input[type="text"] {
        width: 100%;
    }
    
    .legend {
        width: 100%;
        margin: 10px 0;
        padding: 10px;
        max-width: none;
        right: 0;
        left: 0;
        bottom: 0;
    }
    
    .legend-title {
        font-size: 14px;
    }
    
    .max-speed-label {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .leaflet-popup-content-wrapper {
        /* Riduci la larghezza massima del popup su schermi piccoli */
        max-width:  140px; /* O un valore che preferisci */
        width: auto !important; /* Permetti al contenuto di determinare la larghezza */
    }
    
    .track-popup .popup-container {
        /* Assicura che il contenuto interno si adatti */
        max-width: 100%;
    }
    
    .popup-image {
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .popup-container {
        flex-direction: column;
    }
}

/* Rimuovo la media query duplicata e ripristino quella corretta per 480px */
/* @media (max-width: 768px) { */ /* Questa sezione era duplicata e viene rimossa */

/* La media query corretta per 768px è già presente sopra, quindi non serve ripeterla */

/* La media query per 480px è stata spostata sopra, quindi questa parte viene rimossa */
/* @media (max-width: 480px) { */
    .upload-form input[type="text"] {
        width: 100%;
    }
    
    .legend {
        width: 100%;
        margin: 10px 0;
        padding: 10px;
        max-width: none;
        right: 0;
        left: 0;
        bottom: 0;
    }
    
    .legend-title {
        font-size: 14px;
    }
    
    .max-speed-label {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .popup-container {
        flex-direction: column;
    }
    
    .popup-image {
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .legend {
        width: 100%;
        margin: 10px 0;
        padding: 10px;
        border-radius: 4px;
        max-width: 100%;
        box-sizing: border-box;
        left: 0;
        right: 0;
    }
    
    .container {
        padding: 10px;
        width: 100%;
        overflow-x: hidden;
    }
    
    .upload-form {
        width: 100%;
    }
    
    .upload-form input[type="text"] {
        max-width: 100%;
    }
    
    .upload-form input[type="file"] {
        width: 100%;
    }
    
    #map {
        width: 100%; 
        border-radius: 4px;
    }
    
    .legend-item {
        margin-bottom: 8px;
    }
    
    .legend-label-container {
        flex-wrap: wrap;
    }
    
    body, html {
        overflow-x: hidden;
        width: 100%;
        position: relative;
    }
}

/* Stili personalizzati per l'applicazione */

/* Stili per l'intestazione */
h1 {
    color: #333;
    margin-bottom: 20px;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

/* Stili per il contenitore della mappa */
#map {
    width: 100%;
    height: 70vh;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 0;
}

/* Stili per il form di upload */
.upload-form {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.upload-form input[type="text"] {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 300px;
    font-size: 14px;
}

.upload-form button {
    padding: 8px 16px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.upload-form button:hover {
    background-color: #45a049;
}

/* Stile per l'icona del cestino */
.delete-track-icon {
    cursor: pointer;
    color: #999;
    margin-left: 10px;
    font-size: 16px;
    transition: color 0.3s;
}

.delete-track-icon:hover {
    color: #ff0000;
}

/* Stile per l'icona del cestino come emoji */
.trash-icon {
    display: inline-block;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.3s, transform 0.3s;
}

.trash-icon:hover {
    opacity: 1;
    transform: scale(1.2);
}

/* Aggiungiamo un po' di stile per il contenitore della legenda per allineare gli elementi */
.legend-actions {
    display: flex;
    align-items: center;
    margin-left: auto;
}