/* ============================================================================================
   Diálogos del módulo de tráficos (/flota/traficos).

   Van en una hoja compartida y no en cuatro `.razor.css` porque los cuatro modales usan la misma
   estructura —tira de contexto, cuerpo con scroll y pie fijo— y duplicarla cuatro veces habría
   garantizado que se desincronizaran a la primera corrección.

   Prefijo `tfd-` para no chocar con `tf-` de TraficosIndex ni con las clases de Radzen.
   ============================================================================================ */

.tfd {
    display: flex;
    flex-direction: column;
    max-height: 78vh;
}

/* --- Tira de contexto: en qué tráfico estamos ------------------------------------------- */

.tfd-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding: 0.6rem 0.85rem;
    border-radius: 10px;
    background: var(--rs-primary-subtle, #eef2f9);
    border: 1px solid rgba(0, 0, 0, 0.06);
    margin-bottom: 0.85rem;
}

.tfd-head-ef {
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.15;
}

.tfd-head-sub {
    font-size: 0.75rem;
    opacity: 0.7;
}

.tfd-head-spacer {
    flex: 1;
}

.tfd-chip {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.07);
    white-space: nowrap;
}

.tfd-chip--ok {
    background: var(--rs-success-subtle, #e6f6ec);
    color: var(--rs-success, #1c7a3e);
}

.tfd-chip--warn {
    background: var(--rs-warning-subtle, #fff5e6);
    color: var(--rs-warning, #a06800);
}

/* --- Cuerpo y pie ------------------------------------------------------------------------ */

.tfd-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.3rem;
}

/* El pie mezcla un texto de ayuda con los botones. Va con `wrap` y con el texto en su propio
   flex-item elástico para que, cuando el diálogo se estrecha, el texto baje a su línea en vez de
   estrujar los botones contra él. Los botones van agrupados aparte: nunca se separan entre sí. */
.tfd-foot {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem 1.25rem;
    padding-top: 0.8rem;
    margin-top: 0.6rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background: inherit;
}

.tfd-foot-info {
    flex: 1 1 260px;
    /* Sin esto un flex-item no baja de su min-content y desborda sobre los botones. */
    min-width: 0;
    font-size: 0.75rem;
    line-height: 1.35;
    opacity: 0.65;
}

.tfd-foot-acciones {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 0 0 auto;
    margin-left: auto;
}

/* --- Tarjeta de elemento (una ruta, un contacto) ----------------------------------------- */

.tfd-card {
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-left: 3px solid var(--rs-primary, #1f3864);
    border-radius: 10px;
    padding: 0.7rem 0.8rem;
    margin-bottom: 0.65rem;
    background: #fff;
}

.tfd-card:hover {
    border-color: rgba(0, 0, 0, 0.18);
    border-left-color: var(--rs-primary, #1f3864);
}

.tfd-card--incompleta {
    border-left-color: var(--rs-warning, #e0a800);
    background: var(--rs-warning-subtle, #fffdf7);
}

.tfd-card-top {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}

.tfd-orden {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--rs-primary, #1f3864);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tfd-card-principal {
    flex: 1;
    min-width: 180px;
}

.tfd-card-acciones {
    display: flex;
    gap: 0.2rem;
    flex: 0 0 auto;
}

/* --- Rejilla de campos ------------------------------------------------------------------- */

.tfd-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(122px, 1fr));
    gap: 0.5rem 0.65rem;
}

.tfd-grid--ancha {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.tfd-field {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.tfd-field--full {
    grid-column: 1 / -1;
}

.tfd-lbl {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.045em;
    text-transform: uppercase;
    opacity: 0.6;
}

.tfd-field .rz-textbox,
.tfd-field .rz-numeric,
.tfd-field .rz-dropdown {
    width: 100%;
}

/* --- Contacto en modo lectura ------------------------------------------------------------ */

/* Un contacto se consulta mucho más de lo que se edita, así que por defecto se lee. Los inputs
   solo aparecen al entrar en edición: si no, mirar la lista parecía rellenar un formulario. */
.tfd-ct-nombre {
    font-weight: 700;
    font-size: 0.92rem;
    line-height: 1.2;
}

.tfd-ct-nombre--vacio {
    opacity: 0.45;
    font-style: italic;
    font-weight: 600;
}

.tfd-ct-cargo {
    font-size: 0.76rem;
    opacity: 0.65;
}

.tfd-ct-datos {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 1.1rem;
    margin-top: 0.15rem;
}

.tfd-ct-dato {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.82rem;
    color: inherit;
    text-decoration: none;
    word-break: break-all;
}

a.tfd-ct-dato:hover {
    text-decoration: underline;
    color: var(--rs-primary, #1f3864);
}

.tfd-ct-dato .rzi,
.tfd-ct-dato .rz-icon {
    font-size: 0.95rem !important;
    opacity: 0.5;
}

/* Genéricas: las usan tanto los contactos como las rutas en modo lectura. */
.tfd-nota-vacia {
    font-size: 0.78rem;
    opacity: 0.45;
    font-style: italic;
    margin-top: 0.15rem;
}

.tfd-obs {
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    border-top: 1px dashed rgba(0, 0, 0, 0.09);
    font-size: 0.78rem;
    opacity: 0.75;
    line-height: 1.35;
}

/* --- Ruta en modo lectura ---------------------------------------------------------------- */

.tfd-rt-trayecto {
    font-weight: 700;
    font-size: 0.92rem;
    line-height: 1.2;
}

.tfd-rt-trayecto--vacio {
    opacity: 0.5;
    font-style: italic;
    font-weight: 600;
}

.tfd-rt-km {
    font-size: 0.72rem;
    font-weight: 400;
    opacity: 0.6;
}

/* Solo se pintan los campos que tienen valor: una ruta con tres datos no debe ocupar lo mismo
   que una con siete, que era justo lo que pasaba cuando todo eran cajas de texto. */
.tfd-rt-datos {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem 1.5rem;
    margin-top: 0.4rem;
}

.tfd-rt-dato {
    min-width: 0;
}

/* `.tfd-lbl` es un <span> y aquí no vive dentro del flex-column de `.tfd-field`. */
.tfd-rt-dato .tfd-lbl {
    display: block;
}

.tfd-rt-val {
    font-size: 0.85rem;
    font-weight: 600;
}

/* Afordancia del doble clic, igual que en el grid de la pantalla. */
.tfd-card--leyendo {
    cursor: cell;
}

.tfd-card--leyendo:hover {
    background: var(--rs-primary-lighter, #f7f9fc);
}

/* --- Estado vacío ------------------------------------------------------------------------ */

.tfd-empty {
    text-align: center;
    padding: 2rem 1rem;
    border: 1px dashed rgba(0, 0, 0, 0.16);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.015);
}

.tfd-empty-icon {
    font-size: 2.2rem !important;
    opacity: 0.28;
}

.tfd-empty-txt {
    margin: 0.5rem 0 0.9rem;
    font-size: 0.85rem;
    opacity: 0.7;
}

/* --- Aviso de datos personales ----------------------------------------------------------- */

.tfd-privacidad {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    padding: 0.55rem 0.75rem;
    border-radius: 9px;
    background: var(--rs-warning-subtle, #fff5e6);
    border: 1px solid var(--rs-warning, #e0a800);
    font-size: 0.78rem;
    line-height: 1.35;
    margin-bottom: 0.8rem;
}

/* --- Línea de tiempo del histórico -------------------------------------------------------- */

.tfd-tl {
    position: relative;
    margin: 0;
    padding: 0 0 0 1.15rem;
    list-style: none;
}

/* El hilo vertical que une los cambios. */
.tfd-tl::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: rgba(0, 0, 0, 0.09);
}

.tfd-tl-item {
    position: relative;
    padding: 0 0 0.85rem;
}

.tfd-tl-item::before {
    content: "";
    position: absolute;
    left: -1.15rem;
    top: 0.35rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--rs-primary, #1f3864);
    border: 2px solid #fff;
}

.tfd-tl-meta {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    font-size: 0.72rem;
    opacity: 0.7;
}

.tfd-tl-campo {
    font-weight: 700;
    font-size: 0.82rem;
    opacity: 1;
}

.tfd-tl-cambio {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    margin-top: 0.15rem;
    font-size: 0.84rem;
}

.tfd-tl-antes {
    opacity: 0.55;
    text-decoration: line-through;
    word-break: break-word;
}

.tfd-tl-despues {
    font-weight: 600;
    word-break: break-word;
}

/* --- Secciones de la ficha ---------------------------------------------------------------- */

.tfd-seccion {
    margin: 0 0 0.6rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #92407d;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.tfd-seccion + .tfd-grid {
    margin-bottom: 1.1rem;
}

@media (max-width: 700px) {
    .tfd {
        max-height: 86vh;
    }
}
