/* Viaje se estila desde acá (global) y no con un .razor.css scoped: el marcador
   del simulador lo inyecta viajeMap.js dentro del mapa, y el scope de Blazor no
   llega a un elemento creado por JS. */
.trip-shell {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--nexpro-spacing-xl) * 2);
    overflow: hidden;
}

.trip-header {
    flex-shrink: 0;
}

.trip-plate-badge-styled {
    background-color: var(--nexpro-primary);
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-weight: bold;
}

.trip-body {
    display: flex;
    flex-direction: row;
    flex-grow: 1;
    min-height: 0;
    gap: 16px;
}

.trip-sidebar {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background-color: var(--nexpro-bg-card);
    border: 1px solid var(--nexpro-border-color);
    border-radius: 8px;
    padding: 16px;
    overflow-y: auto;
    overflow-x: visible;
    transition: width 0.3s ease, padding 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
}

    .trip-sidebar.collapsed {
        width: 0;
        padding-left: 0;
        padding-right: 0;
        border: none;
        opacity: 0;
        margin-right: -16px;
        overflow: hidden;
    }

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--nexpro-border-color);
}

    .sidebar-section:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

.sidebar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--nexpro-text-muted);
    margin: 0;
    white-space: nowrap;
}

.sidebar-title__bar {
    width: 3px;
    height: 13px;
    border-radius: 2px;
    background: var(--nexpro-primary);
    flex-shrink: 0;
}

/* ── Selector de unidad (combobox con búsqueda) ─────────────────────── */
.trip-unit-picker {
    position: relative;
}

.trip-unit-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 40;
    background: var(--nexpro-bg-card);
    border: 1px solid var(--nexpro-border-color);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    max-height: 260px;
    overflow-y: auto;
    padding: 4px;
}

.trip-unit-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    background: none;
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--nexpro-text-main);
    cursor: pointer;
    text-align: left;
}

    .trip-unit-option:hover {
        background: color-mix(in srgb, var(--nexpro-primary) 10%, transparent);
    }

    .trip-unit-option span {
        font-size: 0.75rem;
        color: var(--nexpro-text-muted);
    }

.trip-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.trip-stat {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    padding: 9px 10px;
    background: var(--nexpro-gray-50);
    border: 1px solid var(--nexpro-border-color);
    border-radius: 8px;
}

.trip-stat__head {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--nexpro-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

    .trip-stat__head i {
        font-size: 0.85rem;
        color: var(--nexpro-primary);
    }

.trip-stat__value {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--nexpro-text-main);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trip-stat--danger .trip-stat__head i {
    color: var(--nexpro-danger);
}

.trip-stat--success .trip-stat__head i {
    color: var(--nexpro-success);
}

.trip-toggle-new {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.82rem;
    color: var(--nexpro-text-main);
    cursor: pointer;
    white-space: nowrap;
}

    .trip-toggle-new input[type="checkbox"] {
        appearance: none;
        -webkit-appearance: none;
        position: relative;
        width: 34px;
        height: 18px;
        flex-shrink: 0;
        border-radius: var(--nexpro-border-radius-full);
        background: var(--nexpro-gray-300);
        cursor: pointer;
        transition: background 0.2s ease;
    }

        .trip-toggle-new input[type="checkbox"]::after {
            content: "";
            position: absolute;
            top: 2px;
            left: 2px;
            width: 14px;
            height: 14px;
            border-radius: 50%;
            background: #fff;
            box-shadow: var(--nexpro-shadow-sm);
            transition: transform 0.2s ease;
        }

        .trip-toggle-new input[type="checkbox"]:checked {
            background: var(--nexpro-primary);
        }

            .trip-toggle-new input[type="checkbox"]:checked::after {
                transform: translateX(16px);
            }

.trip-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100%;
    gap: 16px;
    position: relative;
}

/* Centrado vertical: arriba a la izquierda pisaba los botones +/- de Leaflet,
   que viven en el topleft del mapa. */
.nc-sidebar-toggle-btn {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1050;
    background: var(--nexpro-primary);
    color: white;
    border: none;
    border-radius: 0 6px 6px 0;
    width: 26px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 3px 0 6px rgba(0,0,0,0.15);
    transition: background 0.2s;
}

    .nc-sidebar-toggle-btn:hover {
        background: #1d4ed8;
    }

/* La flecha de colapsar vive pegada al borde izquierdo, centrada vertical; el
   control de capas de Leaflet cae abajo a la izquierda y con el mapa bajo se
   tocan. Lo corremos a la derecha lo justo para que la flecha quede libre. */
.trip-map-wrap .leaflet-bottom.leaflet-left {
    margin-left: 34px;
}

/* El mapa es el protagonista del módulo: se lleva ~2/3 del alto y la tabla el
   resto. Antes era 380px fijos y quedaba incómodo para seguir un recorrido. */
.trip-map-section {
    flex: 2 1 0;
    min-height: 340px;
    display: flex;
    flex-direction: column;
    background-color: var(--nexpro-bg-card);
    border: 1px solid var(--nexpro-border-color);
    border-radius: 8px;
    overflow: hidden;
}

.trip-map-wrap {
    position: relative;
    flex-grow: 1;
    min-height: 0;
}

.trip-map-inner {
    height: 100%;
    width: 100%;
}

.trip-map-empty {
    position: absolute;
    inset: 0;
    z-index: 400;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    padding: 2rem;
    color: var(--nexpro-text-muted);
    background: color-mix(in srgb, var(--nexpro-bg-app) 55%, transparent);
    pointer-events: none;
}

    .trip-map-empty i {
        font-size: 2rem;
        opacity: 0.4;
    }

    .trip-map-empty span {
        max-width: 260px;
        font-size: 0.85rem;
    }

/* Agrupa los controles flotantes de la esquina superior derecha del mapa (volver
   a vista dividida + toggle del tablero) en una columna, para que nunca se pisen
   entre sí sin importar cuáles estén visibles en un momento dado. */
.trip-map-controls-topright {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.trip-map-restore {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.7rem;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--nexpro-bg-card);
    color: var(--nexpro-text-main);
    border: 1px solid var(--nexpro-border-color);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}

    .trip-map-restore:hover {
        background: var(--nexpro-primary);
        color: #fff;
        border-color: var(--nexpro-primary);
    }

/* Botón para mostrar/ocultar el tablero flotante (NcTablero). Cerrado por defecto:
   el tablero es información de detalle, no algo que deba tapar el mapa apenas
   se abre un viaje. */
.trip-tablero-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.3rem;
    height: 2.3rem;
    flex-shrink: 0;
    background: var(--nexpro-bg-card);
    color: var(--nexpro-text-main);
    border: 1px solid var(--nexpro-border-color);
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    cursor: pointer;
    font-size: 1.05rem;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

    .trip-tablero-toggle:hover {
        background: var(--nexpro-primary);
        color: #fff;
        border-color: var(--nexpro-primary);
    }

    .trip-tablero-toggle.is-active {
        background: var(--nexpro-primary);
        color: #fff;
        border-color: var(--nexpro-primary);
    }

/* Flecha del simulador: tipo Google Maps, apunta hacia arriba por defecto y rota
   según el rumbo (Curso) que manda viajeMap.js vía transform. */
.viaje-sim-arrow {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-origin: 50% 50%;
    transition: transform 0.25s linear;
}

    .viaje-sim-arrow i {
        font-size: 1.6rem;
        color: var(--nexpro-primary);
        filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 2px #fff) drop-shadow(0 1px 3px rgba(0,0,0,.5));
    }

.trip-player-new {
    background-color: var(--nexpro-bg-card);
    border-top: 1px solid var(--nexpro-border-color);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.trip-player-btn-play {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 0;
}

.trip-player-slider-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 0 16px;
}

.trip-player-time-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--nexpro-text-muted);
    font-weight: 600;
}

.trip-grid-section {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    min-height: 200px;
    background-color: var(--nexpro-bg-card);
    border: 1px solid var(--nexpro-border-color);
    border-radius: 8px;
    overflow: hidden;
}

/* Con las columnas del legacy la tabla no entra a lo ancho: scroll propio, sin
   empujar el layout ni romper el ancho de la página. */
.trip-grid-section .nc-datatable__scroll {
    overflow-x: auto;
}

.trip-grid-section .trip-table {
    min-width: 1100px;
}

.trip-search-wrap {
    max-width: 220px;
}

.trip-search-input {
    height: 2rem;
}

.trip-grid-section .trip-table {
    width: 100%;
}

.trip-row-active {
    background-color: color-mix(in srgb, var(--nexpro-primary) 8%, transparent) !important;
    border-left: 3px solid var(--nexpro-primary);
}

.trip-cell-nowrap {
    white-space: nowrap;
}

/* ── Vistas: dividido (default) / solo tabla / solo mapa ────────────── */
.trip-main--table .trip-map-section {
    display: none;
}

.trip-main--map .trip-grid-section {
    display: none;
}

.trip-main--map .trip-map-section {
    flex: 1;
}

@media (max-width: 992px) {
    .trip-body {
        flex-direction: column;
    }

    .trip-sidebar {
        width: 100%;
        max-height: none;
    }

        .trip-sidebar.collapsed {
            display: none;
        }

    .nc-sidebar-toggle-btn {
        display: none;
    }

    .trip-map-section {
        flex: 0 0 320px;
    }
}
