body:has(.map-layout) main {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
}

body:has(.map-layout) {
    overflow: auto;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body:has(.map-layout) .footer {
    display: none;
}

.map-layout {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    margin: 0;
    overflow: hidden;
}

main {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
}

.map-layout .sidebar {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 1000;
    width: min(420px, calc(100% - 32px));
    height: auto;
    max-height: clamp(280px, calc(100% - 32px), 760px);
    overflow: auto;
    background: #fff;
    padding: 16px 16px 24px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    box-sizing: border-box;
}

.como-chegar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
}

.como-chegar-back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    text-decoration: none;
    color: #172554;
    background: #f5f5f5;
    border: 1px solid #e5e7eb;
    position: absolute;
    left: 0;
}

.como-chegar-back:hover {
    background: #e9eef8;
}

.como-chegar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    justify-content: center;
}

.como-chegar-logo {
    height: 28px;
    width: auto;
    display: block;
}

.como-chegar-brand-text {
    font-family: "Poppins", sans-serif;
    font-weight: 700;
    font-size: 18px;
    color: #3F3F63;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

#map2 {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

#address {
    flex: 1 1 300px;
    max-width: 400px;
    min-width: 250px;
    box-sizing: border-box;
}

.autocomplete-container {
    position: relative;
}

.autocomplete-container.geo-origin .form-control {
    padding-right: 44px !important;
}

.autocomplete-container.geo-dest .form-control {
    padding-right: 44px !important;
}

.origin-geolocate-btn {
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    color: #64748b;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 2;
}

.origin-geolocate-btn:hover {
    background: #f1f5f9;
    color: #1e40af;
    transform: translateY(-50%) scale(1.1);
}

.origin-geolocate-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.origin-geolocate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: translateY(-50%);
    color: #94a3b8;
}

.origin-geolocate-btn i {
    font-size: 1.1em;
    transition: transform 0.3s ease;
    display: inline-block;
}

.swap-addresses-btn {
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    color: #64748b;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 2;
}

.swap-addresses-btn:hover {
    background: #f1f5f9;
    color: #1e40af;
    transform: translateY(-50%) scale(1.1);
}

.swap-addresses-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.swap-addresses-btn i {
    font-size: 1.1em;
    transition: transform 0.3s ease;
    transform: rotate(90deg);
    display: inline-block;
}

.swap-addresses-btn:hover i {
    transform: rotate(-90deg);
}

@keyframes comoChegarSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 1100;
    display: none;
    max-height: 260px;
    overflow: auto;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.suggestion-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f1f1f1;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: #f7f7f7;
}

.hidden {
    display: none !important;
}

#loading {
    margin-top: 12px;
}

#error {
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid #fed7d7;
    background: #fff5f5;
    color: #c53030;
    border-radius: 6px;
}

#results {
    margin-top: 16px;
}

.map-layout .bottom-results {
    position: absolute;
    left: 1rem;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    z-index: 900;
    width: min(26.25rem, calc(100% - 2rem));
    max-height: 44dvh;
    overflow: auto;
    background: #fff;
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.15);
    box-sizing: border-box;
}

.map-layout .bottom-results .results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.map-layout .bottom-results .results-title {
    font-size: 18px;
    font-weight: 700;
    color: #172554;
    flex: 1 1 auto;
    min-width: 0;
}

.map-layout .bottom-results .results-header .form-select {
    width: auto;
    min-width: 150px;
    flex: 0 0 auto;
}

.map-layout .bottom-results .results-toggle-icon {
    flex: 0 0 auto;
    width: 40px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    padding: 0;
    margin: 0;
    color: #172554;
}

.map-layout .bottom-results .results-toggle-icon::after {
    content: "";
    width: 10px;
    height: 10px;
    border-right: 2px solid #172554;
    border-bottom: 2px solid #172554;
    transform: rotate(45deg);
    flex: 0 0 auto;
}

.map-layout .bottom-results.collapsed {
    max-height: 56px;
    height: 56px;
    overflow: hidden;
    padding-top: 12px;
    padding-bottom: 12px;
}

.map-layout .bottom-results.collapsed #itineraries-sort {
    display: none;
}

.map-layout .bottom-results.collapsed .results-toggle-icon::after {
    transform: rotate(-135deg);
}

.map-layout .bottom-results #routes-container {
    border-top: 1px solid #e5e7eb;
    padding-top: 12px;
}

.map-layout .bottom-results.collapsed #routes-container {
    display: none;
}


/* Para tela até 980px */
@media (max-width: 780px) {
    .map-layout {
        --panel-gap: 12px;
        font-size: 17px;
        line-height: 1.3;
    }

    .leaflet-control-zoom {
        display: none !important;
    }

    .map-layout .sidebar {
        top: 12px;
        left: 12px;
        width: calc(100% - 24px);
        height: auto;
        min-height: unset;
        max-height: 46dvh;
        padding: 10px 10px 14px 10px;
    }

    .map-layout .bottom-results {
        left: 0.75rem;
        bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
        width: calc(100% - 1.5rem);
        padding: 0.625rem 0.75rem;
        max-height: 38dvh;
    }
}

/* Para tela até 420px */
@media (max-width: 420px) {
    .map-layout {
        --panel-gap: 10px;
    }

    .map-layout .sidebar {
        top: 10px;
        left: 10px;
        width: calc(100% - 20px);
        height: auto;
        min-height: unset;
        max-height: 46dvh;
        padding: 10px 10px 14px 10px;
    }

    .map-layout .bottom-results {
        left: 0.625rem;
        bottom: calc(0.375rem + env(safe-area-inset-bottom, 0px));
        width: calc(100% - 1.25rem);
        padding: 0.625rem 0.75rem;
        height: auto;
        min-height: unset;
        max-height: 42dvh;
    }

    .input-group label {
        font-size: 18px;
        margin-bottom: 8px;
        font-weight: 600;
    }

    .form-control,
    .form-select {
        font-size: 17px !important;
        padding: 10px 12px !important;
        min-height: 44px;
    }

    .btn-buscar {
        font-size: 17px;
        padding: 10px 14px;
        min-height: 44px;
        font-weight: 600;
    }

    .como-chegar-brand-text {
        font-size: 20px;
    }

    .como-chegar-logo {
        height: 34px;
    }

    .como-chegar-back {
        width: 48px;
        height: 48px;
        font-size: 24px;
    }

    .suggestion-item {
        padding: 18px 20px;
        font-size: 18px;
    }

    .route-card {
        padding: 20px;
        margin-bottom: 18px;
    }

    .route-title {
        font-size: 20px;
    }

    .stat {
        font-size: 18px;
    }

    .leg-title {
        font-size: 19px;
    }

    .leg-meta,
    .leg-places {
        font-size: 18px;
    }

    .leg-icon {
        width: 40px;
        font-size: 22px;
    }

    .titulo-card-paradas {
        font-size: 26px;
    }

    #loading {
        font-size: 19px;
        padding: 16px;
    }

    #error {
        font-size: 18px;
        padding: 16px 18px;
    }
}

/* Para telas com pouca altura (ex: celular deitado) */
@media (max-height: 740px) {
    .map-layout .sidebar {
        max-height: 45dvh;
    }

    .map-layout .bottom-results {
        max-height: 45dvh;
    }
}

/* Para telas muito baixas
@media (max-height: 600px) {
    .map-layout .sidebar {
        top: 10px;
        left: 10px;
        width: calc(100% - 20px);
        max-height: 40dvh;
    }

    .map-layout .bottom-results {
        left: 10px;
        bottom: 10px;
        width: calc(100% - 20px);
        max-height: 40dvh;
    }
} */

.route-card {
    border: 1px solid #e5e7eb;
    background: #fff;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 12px;
    cursor: pointer;
}

.route-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    position: relative;
}

.route-title {
    font-weight: 700;
}

.route-card.route-active .route-title {
    font-size: 1.05em;
    font-weight: 800;
    color: #1d4ed8;
}

.route-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.route-info-icon {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid #cbd5e1;
    padding: 0;
    margin: 0;
    color: #334155;
    cursor: pointer;
    position: relative;
    font-size: 14px;
    border-radius: 999px;
    line-height: 1;
}

.route-info-icon:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.route-info-icon::before {
    content: "i";
    font-weight: 700;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

.route-info-tooltip-floating {
    position: absolute;
    left: 0;
    top: 0;
    display: none;
    width: 360px;
    max-width: calc(100vw - 24px);
    padding: 12px;
    background: #111827;
    color: #fff;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
    z-index: 3000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.route-info-tooltip-floating.visible {
    display: block;
}

.route-info-tooltip-floating.measuring {
    display: block;
    visibility: hidden;
}

.route-stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.stat {
    font-size: 0.9rem;
    color: #374151;
}

.route-details {
    margin-top: 12px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transform: translateY(-4px);
    transition: max-height 240ms ease, opacity 180ms ease, transform 180ms ease;
}

.route-card.expanded .route-details {
    max-height: 1000px;
    opacity: 1;
    transform: translateY(0);
}

.leg {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-top: 1px solid #f3f4f6;
}

.leg-transfer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-top: 10px;
    border-top: 1px dashed #cbd5e1;
    border-bottom: 1px dashed #cbd5e1;
    background: #f8fafc;
    border-radius: 8px;
}

.leg-transfer-icon {
    width: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0f172a;
}

.leg-transfer-text {
    font-size: 0.9rem;
    font-weight: 700;
    color: #0f172a;
}

.leg-icon {
    width: 28px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    color: #111827;
}

.leg-title {
    font-weight: 600;
}

.leg-meta,
.leg-places {
    font-size: 0.9rem;
    color: #4b5563;
}

.leg-places {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.leg-places .place-kind {
    font-weight: 600;
    color: #374151;
}

.btn-buscar {
    display: flex;
    text-decoration: none;
    justify-content: center;
    align-items: center;
    background-color: #162652;
    color: white;
    border-radius: 8px;
    transition: background-color 0.3s ease;
    padding: 0.6rem 0.8rem;
    font-size: 14px;
    border-radius: 4px;
    border: solid 1px #4c4c7a;
    white-space: nowrap;
    min-width: fit-content;
    margin-top: 1em;
    gap: 0.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.pin-label-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    vertical-align: middle;
    margin-left: 6px;
}

.map-layout .form-select {
    border-color: var(--bs-border-color) !important;
 }

 .time-controls .form-select,
 .time-controls .form-control {
    width: 100%;
 }

 .time-controls #trip-time-mode {
    width: 160px;
    flex: 0 0 auto;
 }

 .time-controls #trip-time {
    width: 120px;
    flex: 0 0 auto;
 }

 @media (max-width: 680px) {
   .time-controls {
     flex-wrap: wrap;
   }

   .time-controls #trip-time-mode,
   .time-controls #trip-time {
     width: 100%;
   }
 }

 .time-mode {
    border: var(--bs-border-width) solid var(--bs-border-color) !important;
}

.titulo-card-paradas {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 20px;
  text-align: center;
}

.route-endpoint-popup .leaflet-popup-content-wrapper {
   border-radius: 10px;
   padding: 0;
   background: #ffffff;
   color: #0f172a;
   box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
 }

 .route-endpoint-popup .leaflet-popup-content {
   margin: 0;
   padding: 10px 12px;
   font-size: 13px;
   line-height: 1.45;
   min-width: 220px;
   max-width: 320px;
 }

 .route-endpoint-popup .leaflet-popup-tip {
   background: #ffffff;
 }

 .route-endpoint-popup .leaflet-popup-close-button {
   width: 30px;
   height: 30px;
   border-radius: 8px;
   margin: 6px 6px 0 0;
   color: #334155;
 }

 .route-endpoint-popup .leaflet-popup-close-button:hover {
   background: #f1f5f9;
   color: #0f172a;
 }