body {
    font-family: 'Inter', sans-serif;
    background-color: var(--color-bg-gray);
    margin: 0;
    padding: 0;
}

/* Header Verde */
.header-green {
    background: var(--color-primary-green);
    padding: 2rem 1.5rem 4rem;
    color: white;
    clip-path: polygon(0 0, 100% 0, 100% 75%, 0 100%);
    margin-bottom: -2rem;
    position: relative;
    z-index: 1;
}

.header-title {
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: 28px;
    line-height: 1.2;
    margin-top: 1rem;
}

.back-button {
    color: white;
    text-decoration: none;
    font-size: 24px;
    display: inline-block;
}

/* Main Content */
.main-content {
    padding: 0 1.5rem 1.5rem;
    position: relative;
    z-index: 2;
}

/* Route Summary */
.route-summary {
    background: var(--color-white);
    box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 15px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.route-stops {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.route-stop {
    flex: 1;
}

.route-stop-label {
    font-family: 'SF Pro', sans-serif;
    font-size: 12px;
    color: var(--color-text-gray);
    margin-bottom: 0.25rem;
}

.route-stop-name {
    font-family: 'SF Pro', sans-serif;
    font-weight: 700;
    font-size: 16px;
    color: var(--color-black);
}

.route-arrow {
    font-size: 24px;
    color: var(--color-primary-green);
}

.route-datetime {
    font-family: 'SF Pro', sans-serif;
    font-size: 14px;
    color: #666;
    margin-top: 0.5rem;
}

/* Section Title */
.section-title {
    font-family: 'SF Pro', sans-serif;
    font-weight: 600;
    font-size: 18px;
    color: var(--color-black);
    margin: 1.5rem 0 0.75rem;
}

/* Route Card */
.route-card {
    background: var(--color-white);
    box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 15px;
    padding: 1.25rem 1.25rem 0 1.25rem;
    /* Remove bottom padding for flush button */
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
    /* Clip button corners */
}

.route-card:active {
    transform: scale(0.98);
    box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.15);
}

.route-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.route-time {
    font-family: 'SF Pro', sans-serif;
    font-weight: 700;
    font-size: 20px;
    color: var(--color-black);
}

.route-duration {
    font-family: 'SF Pro', sans-serif;
    font-size: 14px;
    color: #666;
}

.route-details {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.line-badge {
    background: var(--color-primary-blue);
    border-radius: 7px;
    color: var(--color-white);
    font-family: 'SF Pro', sans-serif;
    font-weight: 700;
    font-size: 14px;
    padding: 6px 12px;
    display: inline-block;
}

.walking-icon {
    width: 20px;
    height: 20px;
    display: block;
    margin: 0 auto;
}

.line-badge.badge-walking {
    background: #F4B942 !important;
    color: #101817 !important;
}

.route-info {
    font-family: 'SF Pro', sans-serif;
    font-size: 14px;
    color: var(--color-text-gray);
}

.no-routes {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
}

.no-routes-icon {
    font-size: 48px;
    margin-bottom: 1rem;
}

.no-routes-text {
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    margin-bottom: 0.5rem;
}

.no-routes-subtext {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--color-text-muted);
}

.loading {
    text-align: center;
    padding: 3rem 1rem;
}

.spinner {
    border: 3px solid var(--color-spinner-base);
    border-top: 3px solid var(--color-primary-green);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

    100% {
        transform: rotate(360deg);
    }
}

.btn-back {
    background: var(--color-primary-blue);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 1rem;
    width: 100%;
    font-family: 'SF Pro', sans-serif;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    margin-top: 1.5rem;
    transition: all 0.2s ease;
}

.btn-back:active {
    transform: scale(0.98);
    background: var(--color-primary-blue-dark);
}

/* New Timeline Styles */
.route-header-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-family: 'SF Pro', sans-serif;
    font-size: 14px;
    color: var(--color-black);
    font-weight: 600;
}

.route-timeline {
    position: relative;
    padding-left: 10px;
}

.timeline-item {
    display: flex;
    align-items: flex-start;
    position: relative;
    z-index: 2;
}

/* Linea verticale continua che collega i cerchietti (parte dal centro del
   marker e prosegue verso il basso, dietro al marker successivo). */
.timeline-item::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 8px;
    bottom: 0;
    width: 2px;
    background: var(--color-primary-green);
    z-index: 1;
}

.timeline-item:last-child::before {
    display: none;
}

.timeline-marker {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 3px solid var(--color-primary-green);
    /* Green */
    background: var(--color-white);
    margin-right: 15px;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.timeline-marker.start {
    border-color: var(--color-primary-blue);
}

/* Blue */
.timeline-marker.transfer {
    border-color: var(--color-orange);
}

/* Orange */
.timeline-marker.end {
    border-color: var(--color-primary-green);
}

/* Green */

.timeline-content {
    padding-bottom: 0;
}

.stop-name {
    font-weight: 700;
    font-size: 16px;
    color: var(--color-black);
}

.stop-time {
    font-size: 14px;
    color: var(--color-text-gray);
}

.timeline-connector {
    margin-left: 7px;
    /* Center with marker (16px width -> center at 8px) */
    border-left: 2px solid var(--color-primary-green);
    padding-left: 22px;
    /* 15px margin + 7px offset */
    padding-top: 10px;
    padding-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.connector-info {
    font-size: 13px;
    color: var(--color-text-gray);
}

.route-footer {
    padding: 0;
    margin-top: 1rem;
    border-top: none;
    margin-left: -1.25rem;
    margin-right: -1.25rem;
}

.walk-info {
    font-size: 14px;
    color: var(--color-black);
    font-weight: 500;
}

.btn-select {
    background: var(--color-primary-green);
    color: white;
    border: none;
    border-radius: 0;
    /* Full width, no radius */
    padding: 15px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.btn-select:hover {
    background: #008552;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    /* Bottom sheet on mobile */
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.modal-content {
    background: var(--color-white);
    width: 100%;
    max-width: 600px;
    border-radius: 20px 20px 0 0;
    padding: 1.5rem;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 80vh;
    overflow-y: auto;
}

@media (min-width: 600px) {
    .modal-overlay {
        align-items: center;
    }

    .modal-content {
        border-radius: 20px;
        transform: translateY(20px);
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    }
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-family: 'SF Pro', sans-serif;
    font-weight: 700;
    font-size: 20px;
}

.modal-close {
    background: var(--color-bg-light);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--color-text-dark);
}

.detail-row {
    display: flex;
    margin-bottom: 1rem;
    position: relative;
}

.detail-time {
    width: 60px;
    font-weight: 600;
    font-size: 14px;
    color: var(--color-text-dark);
    flex-shrink: 0;
}

.detail-content {
    flex: 1;
    padding-left: 15px;
    border-left: 2px solid var(--color-lighter-gray);
    padding-bottom: 15px;
}

.detail-row:last-child .detail-content {
    border-left: none;
}

.detail-title {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 4px;
}

.detail-subtitle {
    font-size: 14px;
    color: var(--color-text-gray);
}

.badge-line {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--color-white);
    font-weight: 700;
    font-size: 12px;
    margin-right: 5px;
    background: var(--color-primary-blue);
}

/* Section Title Row */
.section-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1.5rem 0 0.75rem;
}

.section-title-row .section-title {
    margin: 0;
}

/* Compare Toggle Button */
.btn-compare-toggle {
    background: none;
    border: 2px solid var(--color-primary-blue);
    color: var(--color-primary-blue);
    border-radius: 20px;
    padding: 6px 16px;
    font-family: 'SF Pro', sans-serif;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-compare-toggle.active {
    background: var(--color-primary-blue);
    color: var(--color-white);
}

/* Compare Mode Cards */
.route-card.compare-mode {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.route-card.compare-selected {
    border: 2px solid var(--color-primary-blue);
    box-shadow: 0 0 0 1px var(--color-primary-blue), 0px 2px 8px rgba(0, 0, 0, 0.1);
}

.route-card-body {
    flex: 1;
    min-width: 0;
}

.compare-checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid var(--color-light-gray);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 4px;
    transition: all 0.2s ease;
    font-size: 14px;
    color: var(--color-white);
}

.compare-checkbox.checked {
    background: var(--color-primary-blue);
    border-color: var(--color-primary-blue);
}

/* Compare Bar (sticky bottom) */
.compare-bar {
    position: fixed;
    bottom: 76px;
    left: 0;
    right: 0;
    background: var(--color-white);
    padding: 12px 1.5rem;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 110;
}

.compare-bar span {
    font-family: 'SF Pro', sans-serif;
    font-size: 14px;
    color: var(--color-text-gray);
}

.btn-compare {
    background: var(--color-primary-blue);
    color: var(--color-white);
    border: none;
    border-radius: 10px;
    padding: 10px 20px;
    font-family: 'SF Pro', sans-serif;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-compare:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Compare Modal */
.compare-modal-content {
    max-height: 85vh;
}

.compare-map-shell {
    position: relative;
}

.compare-map {
    width: 100%;
    height: 320px;
    margin: -0.25rem 0 0.5rem;
    border: 1px solid var(--color-border-gray);
    border-radius: 14px;
    overflow: hidden;
    background: #dfeae6;
}

.compare-map-expand {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 500;
    width: 40px;
    min-height: 40px;
    padding: 0;
    border: 1px solid rgba(16,35,31,.18);
    border-radius: 10px;
    background: rgba(255,255,255,.94);
    color: #10231f;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(16,35,31,.16);
}

.compare-map-shell.is-expanded {
    position: fixed;
    inset: 12px;
    z-index: 1200;
    padding: 0;
    background: var(--color-white);
}

.compare-map-shell.is-expanded .compare-map {
    height: 100%;
    margin: 0;
    border-radius: 16px;
}

.compare-map-status {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    color: var(--color-text-gray);
    font-size: 12px;
}

.compare-map-status span { display: inline-flex; align-items: center; gap: 5px; }
.compare-map-status i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.compare-map .leaflet-marker-icon,
.compare-map .leaflet-interactive,
.compare-map svg path.leaflet-interactive { cursor: pointer !important; }
.compare-stop-popup { min-width: 190px; font-size: 12px; }
.compare-stop-name { display: block; margin-bottom: 8px; font-size: 14px; }
.compare-stop-line { display: flex; align-items: flex-start; gap: 7px; line-height: 1.35; }
.compare-stop-line + hr { margin: 7px 0; border: 0; border-top: 1px solid #d9e1de; }
.compare-stop-route-badge { flex: 0 0 auto; padding: 2px 5px; border-radius: 5px; background: #087df5; color: #fff; font-size: 10px; font-weight: 700; white-space: nowrap; }
.compare-stop-time { color: var(--color-text-gray); font-size: 11px; }
.compare-stop-direction { display: inline-block; margin-right: 4px; font-size: 19px; font-weight: 800; line-height: .75; vertical-align: -2px; }
.compare-stop-direction-down { color: #d26a00; }
.compare-stop-direction-up { color: #087df5; }
.route-wait-time { color: var(--color-text-gray); font-size: .72em; font-weight: 500; white-space: nowrap; }
.vehicle-live-info { display: flex; align-items: center; gap: 6px; margin-top: 5px; color: var(--color-primary-green); font-size: 12px; font-weight: 700; }
.vehicle-live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-primary-green); box-shadow: 0 0 0 4px rgba(0,158,97,.14); display: inline-block; flex: 0 0 auto; }
.compare-vehicle-marker-shell { background: transparent; border: 0; }
.compare-vehicle-marker { min-width: 42px; height: 30px; padding: 0 7px; border: 3px solid #fff; border-radius: 16px; background: var(--vehicle-color); color: #fff; box-shadow: 0 3px 10px rgba(16,35,31,.34); display: inline-flex; align-items: center; justify-content: center; gap: 4px; font-size: 13px; white-space: nowrap; }
.compare-vehicle-marker b { font-size: 11px; }
.compare-live-count { margin-left: auto; color: var(--color-primary-green); font-weight: 700; }
.compare-wait-time { display: block; color: var(--color-text-gray); font-size: .72em; font-weight: 500; white-space: nowrap; }

@media (min-width: 760px) {
    .compare-map {
        height: 360px;
    }

    .compare-bar {
        bottom: 108px;
    }
}

.compare-table {
    width: 100%;
}

.compare-row {
    display: flex;
    border-bottom: 1px solid var(--color-lighter-gray);
    padding: 10px 0;
    align-items: center;
}

.compare-row:last-child {
    border-bottom: none;
}

.compare-header-row {
    font-weight: 700;
    border-bottom: 2px solid var(--color-border-gray);
}

.compare-label {
    width: 80px;
    flex-shrink: 0;
    font-family: 'SF Pro', sans-serif;
    font-size: 13px;
    color: var(--color-text-gray);
    font-weight: 600;
}

.compare-cell {
    flex: 1;
    text-align: center;
    font-family: 'SF Pro', sans-serif;
    font-size: 14px;
    color: var(--color-black);
    padding: 0 4px;
}

.compare-route-label {
    font-weight: 700;
    font-size: 13px;
    color: var(--color-primary-blue);
}

.best-value {
    color: var(--color-primary-green);
    font-weight: 700;
}

.compare-cell .line-badge {
    font-size: 12px;
    padding: 3px 8px;
    margin: 2px;
}

.compare-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-lighter-gray);
}

.btn-select-compare {
    background: var(--color-primary-green);
    color: var(--color-white);
    border: none;
    border-radius: 10px;
    padding: 12px;
    font-family: 'SF Pro', sans-serif;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-select-compare:active {
    transform: scale(0.98);
    background: #008552;
}

/* Direction Tabs (Andata / Ritorno) */
.direction-tabs {
    display: flex;
    gap: 8px;
    background: var(--color-white);
    padding: 6px;
    border-radius: 14px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.direction-tab {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--color-text-gray);
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 15px;
    padding: 10px 0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.direction-tab.active {
    background: var(--color-primary-green);
    color: var(--color-white);
}
