/* Assicura che la catena showactv → offcanvas-body → categoriesView → sidebar
   sia sempre a piena altezza con scroll interno */
#showactv {
    display: flex;
    flex-direction: column;
}

#showactv .offcanvas-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

#showactv #categoriesView {
    flex: 1;
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.vaporetti-sidebar {
    width: 100%;
    height: 100%;
    background: #f8f9fa;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
}

.route-section {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.section-header {
    padding: 16px;
    background: white;
    border-bottom: 1px solid #e9ecef;
    flex-shrink: 0;
}

.section-header h2 {
    margin: 0 0 12px 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.section-header p {
    margin: 8px 0 0 0;
    color: #666;
    font-size: 14px;
    line-height: 1.4;
}

.section-content {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
}

.hidden {
    display: none !important;
}

/* Filtro di ricerca */
.route-filter {
    margin-bottom: 0;
}

.filter-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    box-sizing: border-box;
}

.filter-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Liste */
.routes-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}

.routes-list li {
    padding: 12px 16px;
    margin: 4px 0;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #e9ecef;
    display: flex;
    align-items: center;
}

.routes-list li:hover {
    background: #f8f9fa;
    border-color: #007bff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.routes-list li.active {
    background: #007bff;
    color: white;
    border-color: #0056b3;
}

.loading-item {
    text-align: center;
    color: #666;
    font-style: italic;
    cursor: default !important;
}

.loading-item:hover {
    background: white !important;
    border-color: #e9ecef !important;
    transform: none !important;
    box-shadow: none !important;
}

/* Badge delle linee */
.route-badge-sidebar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 24px;
    padding: 0 8px;
    background: #007bff;
    color: white;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
    margin-right: 12px;
    flex-shrink: 0;
}

.route-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 20px;
    padding: 0 6px;
    background: #007bff;
    color: white;
    border-radius: 3px;
    font-weight: 600;
    font-size: 11px;
    margin: 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.route-badge:hover {
    background: #0056b3;
    transform: scale(1.05);
}

.route-badge small {
    margin-left: 4px;
    opacity: 0.8;
}

/* Pulsante indietro */
.back-button {
    display: inline-block;
    margin-bottom: 12px;
    color: #007bff;
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 0;
}

.back-button:hover {
    text-decoration: underline;
}

/* Azioni della linea */
.route-actions {
    margin: 16px 0;
}

.pdf-link {
    display: inline-block;
    background: #dc3545;
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.pdf-link:hover {
    background: #c82333;
    text-decoration: none;
}

/* Varianti delle linee */
.route-variants {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    border: 1px solid #e9ecef;
}

.variants-title {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
    color: #495057;
}

.variants-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.variant-badge {
    cursor: pointer;
    transition: all 0.2s ease;
}

.variant-badge:hover {
    transform: scale(1.1);
}

/* Controlli direzione */
.route-direction-controls {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    border: 1px solid #e9ecef;
}

.direction-title {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
    color: #495057;
}

.direction-buttons {
    display: flex;
    gap: 6px;
}

.direction-btn {
    flex: 1;
    padding: 8px 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    color: #495057;
}

.direction-btn:hover {
    background: #e9ecef;
    border-color: #007bff;
}

.direction-btn.active {
    background: #007bff;
    color: white;
    border-color: #0056b3;
}

/* Sezione fermate */
.stops-section h3 {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.count-badge {
    background: #6c757d;
    color: white;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.stops-list li {
    padding: 10px 12px;
    font-size: 14px;
}

.stop-sequence {
    color: #007bff;
    font-weight: 600;
    margin-right: 8px;
    min-width: 24px;
}

/* Responsive */
@media (max-width: 768px) {
    .vaporetti-sidebar {
        width: 100%;
        height: 100%;
        max-height: none;
    }
    
    .direction-buttons {
        flex-direction: column;
    }
    
    .direction-btn {
        flex: none;
    }
}

/* Varianti delle linee nella lista principale */
.route-variants-container {
    background: #f8f9fa;
    margin-top: 8px;
    border-radius: 4px;
    padding: 8px;
    border-left: 3px solid #007bff;
}

.route-variant {
    padding: 6px 8px;
    margin: 2px 0;
    background: white;
    border-radius: 3px;
    font-size: 13px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
}

.route-variant:hover {
    background: #e9ecef;
}

/* Popup styles */
.popup-content {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.popup-routes {
    margin-top: 8px;
    line-height: 1.6;
}

.popup-routes strong {
    display: block;
    margin-bottom: 6px;
    color: #495057;}

    /* Colori base per le linee - solo per badge grandi (dettaglio linea) */
.route-number.route-number-detail {
    display: flex;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 20px;
    justify-content: center;
    align-items: center;
    font-weight: 600;
}

/* Badge linee nella sidebar - dimensioni compatte */
.route-badge-sidebar.route-number {
    width: auto;
    height: 24px;
    border-radius: 4px;
    font-size: 12px;
}
.route-stop-marker[data-route="1"],
.route-number[data-route="1"] {
     background-color: #ffffff;
    border: 1px solid #000;
    color: #000;
 }
.route-stop-marker[data-route="2"],
.route-number[data-route="2"],
.route-number[data-route="2/"]  {
     background-color: #E95240;
    color: #fff;
}
.route-stop-marker[data-route="3"],
.route-number[data-route="3"] {
     background-color: #F6A352;
    color: #000;
}
.route-stop-marker[data-route="4.1"],
.route-stop-marker[data-route="4.2"],
.route-number[data-route="4.1"],
.route-number[data-route="4.2"] {
     background-color: #B83188;
     color: #fff;
}
.route-stop-marker[data-route="5.1"],
.route-stop-marker[data-route="5.2"],
.route-number[data-route="5.1"],
.route-number[data-route="5.2"] {
     background-color: #A0D3C3;
     color: #000; 
 }
 .route-stop-marker[data-route="6"],
.route-number[data-route="6"] {
    background-color: #0660A9;
    color: #fff;
}
.route-stop-marker[data-route="7"],
.route-number[data-route="7"] {
    background-color: #0660A9;
    color: #fff;
}
.route-stop-marker[data-route="8"],
.route-number[data-route="8"] {
    background-color: #81863D;
    color: #fff;
}
.route-stop-marker[data-route="9"],
.route-number[data-route="9"] { 
    background-color: #215FA9;
    color: #fff;
}
.route-stop-marker[data-route="10"],
.route-number[data-route="10"] {
    background-color: #62E6FF;
    color: #000;
}
.route-stop-marker[data-route="11"],
.route-number[data-route="11"] {
    background-color: #E3D60B;
    color: #000;
}
.route-stop-marker[data-route="12"],
.route-number[data-route="12"] { 
    background-color: #CCE26B;
    color: #000;
}
.route-stop-marker[data-route="13"],
.route-number[data-route="13"] { 
    background-color: #575AB3; 
    color: #fff;
}
.route-stop-marker[data-route="14"],
.route-number[data-route="14"] { background-color: #EDA45D; }
.route-stop-marker[data-route="N"],
.route-number[data-route="N"] { background-color: #212121; }
.route-stop-marker[data-route="NLN"],
.route-number[data-route="NLN"] { background-color: #3d3d3d; }
.route-stop-marker[data-route="NMU"],
.route-number[data-route="NMU"] { background-color: #3d3d3d; }

.custom-stop-marker {
    width: 16px;
    height: 16px;
    background-color: #9C27B0;
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.custom-stop-marker:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.custom-stop-marker.loading {
    background-color: #FFC107;
    animation: pulse 1s infinite;
}

.route-stop-marker {
    width: 16px;
    height: 16px;
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
}

.stop-tooltip {
    background-color: rgba(0,0,0,0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
#routeInfo h2 {
    font-size: 20px;
    font-weight: 600;
    color: #000;
}
#routeInfo p {
    font-size: 16px;
    font-weight: 400;
    color: #000;
}


@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Animazione hover */
.route-stop-marker:hover {
    animation: bounce 1s ease;
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(3); }
}

/* ===== Stop Info Layout - Two Rows ===== */
#stopInfo .section-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
}

#stopInfo .section-header .back-button {
    margin-bottom: 0;
}

#stopInfo .section-header h2 {
    margin: 0;
}

/* Timetable nella header su seconda riga */
#stopInfo .section-header #stopTimetableContainer {
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
}

/* ===== Route Info Layout - Two Rows (similar to Stop Info) ===== */
#routeInfo .section-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
}

#routeInfo .section-header .back-button {
    margin-bottom: 0;
}

#routeInfo .section-header h2 {
    margin: 0;
}

#routeInfo .section-header p {
    margin: 0;
}

/* Timetable nella header della route su seconda riga */
#routeInfo .section-header #routeTimetableContainer {
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
}

/* Compatta il timetable nell'header (sia per stopInfo che routeInfo) */
#stopInfo .section-header #stopTimetableContainer .timetable-title,
#routeInfo .section-header #routeTimetableContainer .timetable-title {
    font-size: 0.75rem;
    padding: 0;
    margin-bottom: 0.5rem;
}

#stopInfo .section-header #stopTimetableContainer .timetable-list,
#routeInfo .section-header #routeTimetableContainer .timetable-list {
    background: white;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
}

#stopInfo .section-header #stopTimetableContainer .timetable-item,
#routeInfo .section-header #routeTimetableContainer .timetable-item {
    padding: 0.6rem 0.75rem;
    gap: 0.5rem;
}

#stopInfo .section-header #stopTimetableContainer .timetable-icon,
#routeInfo .section-header #routeTimetableContainer .timetable-icon {
    width: 40px;
    height: 40px;
    font-size: 1.3rem;
    border-radius: 10px;
}

#stopInfo .section-header #stopTimetableContainer .route-badge-timetable,
#routeInfo .section-header #routeTimetableContainer .route-badge-timetable {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    min-width: 36px;
}

#stopInfo .section-header #stopTimetableContainer .timetable-headsign,
#routeInfo .section-header #routeTimetableContainer .timetable-headsign {
    font-size: 0.85rem;
}

#stopInfo .section-header #stopTimetableContainer .arrival-time,
#routeInfo .section-header #routeTimetableContainer .arrival-time {
    font-size: 1.2rem;
}

#stopInfo .section-header #stopTimetableContainer .countdown,
#routeInfo .section-header #routeTimetableContainer .countdown {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

#stopInfo .section-header #stopTimetableContainer .delay,
#routeInfo .section-header #routeTimetableContainer .delay {
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
}

#stopInfo .section-header #stopTimetableContainer .loading-timetable,
#stopInfo .section-header #stopTimetableContainer .timetable-error,
#stopInfo .section-header #stopTimetableContainer .no-timetable,
#routeInfo .section-header #routeTimetableContainer .loading-timetable,
#routeInfo .section-header #routeTimetableContainer .timetable-error,
#routeInfo .section-header #routeTimetableContainer .no-timetable {
    padding: 1rem 0.75rem;
}

#stopInfo .section-header #stopTimetableContainer .loading-timetable i,
#stopInfo .section-header #stopTimetableContainer .timetable-error i,
#stopInfo .section-header #stopTimetableContainer .no-timetable i,
#routeInfo .section-header #routeTimetableContainer .loading-timetable i,
#routeInfo .section-header #routeTimetableContainer .timetable-error i,
#routeInfo .section-header #routeTimetableContainer .no-timetable i {
    font-size: 1.5rem;
}

/* ===== Timetable Section - Modern Design ===== */
.stop-timetable-section {
    margin-top: 0;
    margin-bottom: 0;
    padding: 0;
    background: transparent;
    border: none;
    padding-bottom: 0;
}

.timetable-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    margin-top: 0.5rem;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 1rem;
}

.timetable-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.timetable-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    transition: background 0.2s ease;
    position: relative;
}

.timetable-item:hover {
    background: #f8f9fa;
}

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

/* Icona vaporetto a sinistra */
.timetable-icon {
    width: 56px;
    height: 56px;
    background: white;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 2px solid #e5e7eb;
}

/* Badge linea e destinazione sulla stessa riga */
.timetable-route {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex: 1;
    min-width: 0;
    gap: 0.5rem;
}

.timetable-route-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.route-badge-timetable {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-weight: 700;
    color: white;
    min-width: 28px;
    text-align: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.timetable-headsign {
    font-size: 0.85rem;
    color: #1a1a1a;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
    flex: 1;
    min-width: 0;
}

.timetable-destination {
    font-size: 0.8rem;
    color: #6b7280;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Orari a destra */
.timetable-time {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    flex-shrink: 0;
}

.arrival-time {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1;
}

.countdown {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.7rem;
    color: white;
    background: #3656AF;
    padding: 0.2rem 0.5rem;
    border-radius: 8px;
    font-weight: 600;
}

.countdown i {
    font-size: 0.75rem;
}

.countdown.arriving {
    background: #4ade80;
    animation: pulse-arriving 2s infinite;
}

@keyframes pulse-arriving {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

/* Indicatore ritardo/anticipo */
.delay {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 10px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.delay.delayed {
    background: #fee2e2;
    color: #dc2626;
}

.delay.early {
    background: #d1fae5;
    color: #059669;
}

.delay i {
    font-size: 0.7rem;
}

/* Stati loading ed errore */
.loading-timetable {
    text-align: center;
    padding: 2rem 1.25rem;
    color: #9ca3af;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.loading-timetable i {
    font-size: 2rem;
    color: #3656AF;
    animation: spin 1s linear infinite;
}

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

.timetable-error {
    text-align: center;
    color: #dc2626;
    padding: 2rem 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.timetable-error i {
    font-size: 2rem;
    color: #dc2626;
}

.no-timetable {
    text-align: center;
    color: #9ca3af;
    padding: 2rem 1.25rem;
    font-style: normal;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.no-timetable i {
    font-size: 2.5rem;
    color: #d1d5db;
}

/* Inline timetable nella lista fermate - Modern Design */
.stop-inline-timetable {
    margin-top: 0.4rem;
    padding: 0;
    background: transparent;
    width: 100%;
}

.route-item.expanded {
    background: #f8f9fa;
    flex-direction: column;
    align-items: flex-start;
}

.stop-header {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.inline-times-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.25rem 0 0.25rem 0;
}

.inline-time {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.6rem;
    background: white;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    min-width: 0;
    width: 100%;
}

.inline-time:hover {
    border-color: #3656AF;
    box-shadow: 0 2px 6px rgba(54, 86, 175, 0.15);
    transform: translateY(-2px);
}

.inline-time .time {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1;
    margin-bottom: 0;
}

.inline-time .countdown {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: white;
    background: #3656AF;
    padding: 0.3rem 0.5rem;
    border-radius: 10px;
    font-weight: 600;
    white-space: nowrap;
}

.inline-time .countdown.arriving {
    background: #4ade80;
    animation: pulse-arriving 2s infinite;
}

.inline-time .countdown i {
    font-size: 0.65rem;
}

/* Applica colori delle linee anche ai badge timetable */
.route-badge-timetable[data-route="1"] { background-color: #ffffff; border: 1px solid #000; color: #000; }
.route-badge-timetable[data-route="2"],
.route-badge-timetable[data-route="2/"] { background-color: #E95240; color: #fff; }
.route-badge-timetable[data-route="3"] { background-color: #F6A352; color: #000; }
.route-badge-timetable[data-route="4.1"],
.route-badge-timetable[data-route="4.2"] { background-color: #B83188; color: #fff; }
.route-badge-timetable[data-route="5.1"],
.route-badge-timetable[data-route="5.2"] { background-color: #A0D3C3; color: #000; }
.route-badge-timetable[data-route="6"] { background-color: #0660A9; color: #fff; }
.route-badge-timetable[data-route="7"] { background-color: #0660A9; color: #fff; }
.route-badge-timetable[data-route="8"] { background-color: #81863D; color: #fff; }
.route-badge-timetable[data-route="9"] { background-color: #215FA9; color: #fff; }
.route-badge-timetable[data-route="10"] { background-color: #62E6FF; color: #000; }
.route-badge-timetable[data-route="11"] { background-color: #E3D60B; color: #000; }
.route-badge-timetable[data-route="12"] { background-color: #CCE26B; color: #000; }
.route-badge-timetable[data-route="13"] { background-color: #575AB3; color: #fff; }
.route-badge-timetable[data-route="14"] { background-color: #EDA45D; color: #000; }
.route-badge-timetable[data-route="N"] { background-color: #212121; color: #fff; }
.route-badge-timetable[data-route="NLN"],
.route-badge-timetable[data-route="NMU"] { background-color: #3d3d3d; color: #fff; }

/* ===== Popup Next Departure - Modern Design ===== */
.popup-content {
    padding: 0.75rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.popup-content > strong {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 0.6rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid #e5e7eb;
    line-height: 1.3;
}

.popup-next-departure {
    margin-bottom: 1rem;
    padding: 0.875rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 12px;
    border: 2px solid #e5e7eb;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.next-departure-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.next-departure-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.route-badge-popup {
    font-size: 0.9rem;
    padding: 0.4rem 0.7rem;
    border-radius: 10px;
    font-weight: 700;
    color: white;
    min-width: 42px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

/* Applica colori delle linee ai badge popup */
.route-badge-popup[data-route="1"] { background-color: #ffffff; border: 2px solid #000; color: #000; }
.route-badge-popup[data-route="2"],
.route-badge-popup[data-route="2/"] { background-color: #E95240; color: #fff; }
.route-badge-popup[data-route="3"] { background-color: #F6A352; color: #000; }
.route-badge-popup[data-route="4.1"],
.route-badge-popup[data-route="4.2"] { background-color: #B83188; color: #fff; }
.route-badge-popup[data-route="5.1"],
.route-badge-popup[data-route="5.2"] { background-color: #A0D3C3; color: #000; }
.route-badge-popup[data-route="6"] { background-color: #0660A9; color: #fff; }
.route-badge-popup[data-route="7"] { background-color: #0660A9; color: #fff; }
.route-badge-popup[data-route="8"] { background-color: #81863D; color: #fff; }
.route-badge-popup[data-route="9"] { background-color: #215FA9; color: #fff; }
.route-badge-popup[data-route="10"] { background-color: #62E6FF; color: #000; }
.route-badge-popup[data-route="11"] { background-color: #E3D60B; color: #000; }
.route-badge-popup[data-route="12"] { background-color: #CCE26B; color: #000; }
.route-badge-popup[data-route="13"] { background-color: #575AB3; color: #fff; }
.route-badge-popup[data-route="14"] { background-color: #EDA45D; color: #000; }
.route-badge-popup[data-route="N"] { background-color: #212121; color: #fff; }
.route-badge-popup[data-route="NLN"],
.route-badge-popup[data-route="NMU"] { background-color: #3d3d3d; color: #fff; }

.next-departure-headsign {
    font-size: 0.9rem;
    color: #1a1a1a;
    font-weight: 600;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.next-departure-time {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.next-departure-time .time {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1;
}

.next-departure-time .countdown {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: white;
    background: #3656AF;
    padding: 0.35rem 0.6rem;
    border-radius: 10px;
    font-weight: 600;
    white-space: nowrap;
}

.next-departure-time .countdown i {
    font-size: 0.7rem;
}

.next-departure-time .countdown.arriving {
    background: #4ade80;
    animation: pulse-arriving 2s infinite;
}

.popup-routes {
    padding-top: 0.5rem;
    margin-top: 0.5rem;
}

.popup-routes strong {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 0.4rem;
    padding-bottom: 0;
    border-bottom: none;
    display: block;
}

.popup-routes .route-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
    margin: 0.15rem 0.15rem 0.15rem 0;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #3656AF;
    color: white;
    border: none;
    min-width: 24px;
    height: 22px;
}

.popup-routes .route-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 6px rgba(54, 86, 175, 0.3);
}

.popup-routes .route-badge small {
    margin-left: 0.15rem;
    font-size: 0.6rem;
    opacity: 0.9;
}
/* Popup Timetable Styles */
.popup-timetable {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e5e7eb;
}

.popup-timetable strong {
    font-size: 0.7rem;
    font-weight: 600;
    color: #6b7280;
    display: block;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.popup-times-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: 0.4rem;
}

.popup-time-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    margin-bottom: 0.5rem;
    box-sizing: border-box;
}

.popup-time-item:last-child {
    margin-bottom: 0;
}

.popup-time-item .route-badge-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    width: 28px;
    height: 28px;
    padding: 0;
    background: #3656AF;
    color: white;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.popup-time-item .destination {
    color: #374151;
    font-size: 0.8rem;
    font-weight: 500;
    flex: 1;
    min-width: 0;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.popup-time-item .time {
    font-weight: 700;
    color: #1f2937;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.popup-time-item .countdown {
    font-size: 0.65rem;
    color: white;
    background: #3656AF;
    padding: 0.2rem 0.4rem;
    border-radius: 8px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.popup-timetable .timetable-loading,
.popup-timetable .no-timetable,
.popup-timetable .timetable-error {
    padding: 0.75rem;
    text-align: center;
    font-size: 0.85rem;
    color: #6b7280;
    font-style: italic;
    background: #f9fafb;
    border-radius: 8px;
    margin-top: 0.5rem;
}

.popup-timetable .timetable-error {
    color: #ef4444;
    background: #fef2f2;
}

.popup-timetable .no-timetable {
    color: #9ca3af;
}

.popup-details-btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 7px 0;
    background: #00A8E8;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}

/* Colori badge linee nel popup orari */
.popup-time-item .route-badge-small[data-route="1"] { background-color: #ffffff; border: 1px solid #000; color: #000; }
.popup-time-item .route-badge-small[data-route="2"],
.popup-time-item .route-badge-small[data-route="2/"] { background-color: #E95240; }
.popup-time-item .route-badge-small[data-route="3"] { background-color: #F6A352; color: #000; }
.popup-time-item .route-badge-small[data-route="4.1"],
.popup-time-item .route-badge-small[data-route="4.2"] { background-color: #B83188; }
.popup-time-item .route-badge-small[data-route="5.1"],
.popup-time-item .route-badge-small[data-route="5.2"] { background-color: #A0D3C3; color: #000; }
.popup-time-item .route-badge-small[data-route="6"],
.popup-time-item .route-badge-small[data-route="7"] { background-color: #0660A9; }
.popup-time-item .route-badge-small[data-route="8"] { background-color: #81863D; }
.popup-time-item .route-badge-small[data-route="9"] { background-color: #215FA9; }
.popup-time-item .route-badge-small[data-route="10"] { background-color: #62E6FF; color: #000; }
.popup-time-item .route-badge-small[data-route="11"] { background-color: #E3D60B; color: #000; }
.popup-time-item .route-badge-small[data-route="12"] { background-color: #CCE26B; color: #000; }
.popup-time-item .route-badge-small[data-route="13"] { background-color: #575AB3; }
.popup-time-item .route-badge-small[data-route="14"] { background-color: #EDA45D; color: #000; }
.popup-time-item .route-badge-small[data-route="N"] { background-color: #212121; }
.popup-time-item .route-badge-small[data-route="NLN"],
.popup-time-item .route-badge-small[data-route="NMU"] { background-color: #3d3d3d; }

/* Miglioramenti generali Leaflet popup */
.leaflet-popup-content {
    margin: 0 !important;
    padding: 12px !important;
    min-width: 150px;
    max-width: 300px !important;
}

/* Popup fermate ACTV - larghezza fissa */
.leaflet-popup-content:has(.popup-content) {
    width: 280px !important;
    padding: 0 !important;
}

.leaflet-popup-content-wrapper {
    border-radius: 12px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15) !important;
    padding: 0 !important;
    overflow: hidden;
}

.leaflet-popup {
    max-width: 300px !important;
}
