/* ════════════════════════════════════════════════════════════════════
   REPARTO AUTOMATIZADO — botón bajo la hamburguesa y ventana del plan
   La ventana, la animación y el orbe son los mismos de "pedido con IA"
   (clases pr-*): aquí solo va lo propio del reparto.
   ════════════════════════════════════════════════════════════════════ */
.ra-boton {
    position: absolute; top: 118px; right: 10px; z-index: 1000;
    display: flex; align-items: center; gap: 8px;
    padding: 9px 14px 9px 11px; border: none; border-radius: 999px;
    background: linear-gradient(135deg, #6d28d9 0%, #2563eb 60%, #0ea5e9 100%);
    color: #fff; font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 13.5px; font-weight: 600; cursor: pointer;
    box-shadow: 0 4px 14px rgba(37, 99, 235, .38);
    transition: transform .18s, box-shadow .18s;
}
.ra-boton:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(37, 99, 235, .5); }
.ra-boton .flore-f {
    width: 22px; height: 22px; border-radius: 50%;
    background: rgba(255, 255, 255, .22);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 800; flex-shrink: 0;
}

/* ── La ventana es un poco más ancha: caben las rutas ── */
.ra-ventana { width: min(720px, 100%); }

.ra-cuerpo { padding: 20px 22px 18px; }
.ra-etiqueta { display: block; font-size: 13.5px; color: #475569; font-weight: 600; margin-bottom: 8px; }
#raFecha {
    width: 100%; padding: 12px 14px; font-size: 15px;
    border: 1.5px solid #e2e8f0; border-radius: 12px; color: #0f172a;
    font-family: inherit; outline: none; transition: border-color .2s;
}
#raFecha:focus { border-color: #6d28d9; }
.ra-cuenta { font-size: 13px; color: #64748b; margin-top: 10px; min-height: 18px; }
.ra-cuenta b { color: #0f172a; }

/* ── Personalizar reparto: el interruptor y su panel ── */
.ra-toggle {
    display: flex; align-items: center; gap: 10px;
    margin-top: 14px; cursor: pointer; user-select: none;
}
.ra-toggle input { display: none; }
.ra-toggle-pista {
    width: 40px; height: 22px; border-radius: 999px; flex-shrink: 0;
    background: #e2e8f0; position: relative; transition: background .2s;
}
.ra-toggle-bola {
    position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
    border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(15,23,42,.3);
    transition: left .2s;
}
.ra-toggle input:checked + .ra-toggle-pista { background: linear-gradient(135deg, #6d28d9, #2563eb); }
.ra-toggle input:checked + .ra-toggle-pista .ra-toggle-bola { left: 20px; }
.ra-toggle-texto { font-size: 13.5px; font-weight: 600; color: #475569; }
.ra-toggle input:checked ~ .ra-toggle-texto { color: #4c1d95; }

.ra-personal {
    margin-top: 12px; padding: 14px;
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px;
    display: flex; flex-direction: column; gap: 14px;
}
.ra-personal-titulo { font-size: 12.5px; font-weight: 700; color: #334155; margin-bottom: 7px; }
.ra-personal-titulo i { color: #6d28d9; margin-right: 4px; }
.ra-personal-fila { display: flex; gap: 8px; }
.ra-personal-fila select {
    flex: 1; min-width: 0; padding: 8px 10px; font-size: 13px;
    border: 1.5px solid #e2e8f0; border-radius: 9px; color: #0f172a;
    background: #fff; font-family: inherit; outline: none;
}
.ra-personal-fila select:focus { border-color: #6d28d9; }
.ra-anadir {
    flex-shrink: 0; width: 36px; border: none; border-radius: 9px; cursor: pointer;
    background: linear-gradient(135deg, #6d28d9, #2563eb); color: #fff; font-size: 13px;
}
.ra-anadir:hover { filter: brightness(1.1); }
.ra-personal-lista { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ra-personal-lista:empty { display: none; }
.ra-ficha {
    display: inline-flex; align-items: center; gap: 7px;
    background: #ede9fe; color: #4c1d95; border: 1px solid #ddd6fe;
    border-radius: 999px; padding: 4px 6px 4px 11px;
    font-size: 12.5px; font-weight: 600;
}
.ra-ficha button {
    border: none; background: rgba(109, 40, 217, .14); color: #6d28d9;
    width: 18px; height: 18px; border-radius: 50%; cursor: pointer;
    font-size: 10px; display: flex; align-items: center; justify-content: center;
}
.ra-ficha button:hover { background: rgba(109, 40, 217, .28); }
/* Los conductores quitados del reparto, en rojo: no es una pareja, es un veto */
.ra-ficha.excluido { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.ra-ficha.excluido button { background: rgba(153, 27, 27, .12); color: #991b1b; }
.ra-ficha.excluido button:hover { background: rgba(153, 27, 27, .25); }

/* ── Deshacer reparto ── */
.ra-botones-pie { display: flex; gap: 10px; flex-wrap: wrap; }
.ra-deshacer {
    display: inline-flex; align-items: center; gap: 7px;
    border: 1.5px solid #fecaca; border-radius: 12px; padding: 11px 16px;
    background: #fff; color: #b91c1c; cursor: pointer;
    font-size: 13.5px; font-weight: 600; font-family: inherit;
    transition: background .15s;
}
.ra-deshacer:hover { background: #fef2f2; }
.ra-deshacer:disabled { opacity: .5; cursor: wait; }
.ra-deshacer-caja {
    margin-top: 12px; padding: 12px 14px;
    background: #fef2f2; border: 1px solid #fecaca; border-radius: 12px;
    font-size: 13px; color: #991b1b;
}
.ra-deshacer-caja .ra-deshacer-botones { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.ra-deshacer-caja button {
    border: none; border-radius: 9px; padding: 8px 14px; cursor: pointer;
    font-size: 12.5px; font-weight: 600; font-family: inherit;
}
.ra-deshacer-caja .ra-si { background: #dc2626; color: #fff; }
.ra-deshacer-caja .ra-si:hover { background: #b91c1c; }
.ra-deshacer-caja .ra-no { background: #fff; color: #475569; border: 1px solid #e2e8f0; }

@media (max-width: 768px) {
    .ra-personal-fila { flex-direction: column; }
    .ra-anadir { width: 100%; padding: 9px; }
    .ra-botones-pie { width: 100%; }
    .ra-botones-pie .pr-crear, .ra-botones-pie .ra-deshacer { flex: 1; justify-content: center; }
}

/* ── El plan ── */
.ra-plan { display: none; padding: 18px 22px 20px; }
.ra-plan.visible { display: block; animation: pr-aparecer .25s ease; }
.ra-resumen {
    background: #f5f3ff; border: 1px solid #ddd6fe; border-radius: 12px;
    padding: 12px 15px; font-size: 13.5px; color: #4c1d95; line-height: 1.6;
    margin-bottom: 14px; white-space: pre-wrap;
}
.ra-rutas { display: flex; flex-direction: column; gap: 12px; }
.ra-ruta {
    border: 1px solid #e2e8f0; border-radius: 14px; overflow: hidden;
    background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
}
.ra-ruta-cab {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 11px 14px; background: #f8fafc; border-bottom: 1px solid #eef2f7;
}
.ra-conductor { font-weight: 700; color: #0f172a; font-size: 14px; }
.ra-chapa {
    font-family: 'Segoe UI', monospace; font-weight: 700; font-size: 12.5px;
    color: #1e293b; background: #fff; border: 1.5px solid #cbd5e1;
    border-radius: 6px; padding: 2px 8px; letter-spacing: .5px;
}
.ra-zona {
    font-size: 12px; color: #0369a1; background: #e0f2fe;
    border-radius: 999px; padding: 3px 10px;
}
.ra-carga { margin-left: auto; font-size: 12.5px; color: #475569; text-align: right; }
.ra-carga b { color: #0f172a; }
.ra-carga.apretado b { color: #b45309; }
.ra-motivo {
    padding: 9px 14px; font-size: 12.5px; color: #64748b;
    border-bottom: 1px solid #f1f5f9; font-style: italic;
}
.ra-paradas { list-style: none; margin: 0; padding: 6px 0; counter-reset: parada; }
.ra-parada {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 7px 14px; font-size: 13px; color: #334155;
}
.ra-parada::before {
    counter-increment: parada; content: counter(parada);
    width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
    background: #ede9fe; color: #6d28d9;
    font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.ra-parada-cliente { font-weight: 600; color: #0f172a; }
.ra-parada-detalle { color: #64748b; font-size: 12px; }
.ra-parada-aviso { color: #b45309; font-size: 12px; }

.ra-sobras:not(:empty) {
    margin-top: 14px; padding: 12px 15px;
    background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px;
    font-size: 13px; color: #92400e;
}
.ra-sobras ul { margin: 6px 0 0; padding-left: 18px; }
.ra-sobras.malo { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

.ra-acciones { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.ra-aplicar, .ra-cancelar {
    display: inline-flex; align-items: center; gap: 7px;
    border-radius: 10px; padding: 11px 18px; cursor: pointer;
    font-size: 14px; font-weight: 600; border: none; font-family: inherit;
    transition: transform .15s, box-shadow .15s, opacity .15s;
}
.ra-aplicar { background: linear-gradient(135deg, #15803d, #22c55e); color: #fff; box-shadow: 0 3px 10px rgba(34, 197, 94, .35); }
.ra-aplicar:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(34, 197, 94, .45); }
.ra-aplicar:disabled { opacity: .5; cursor: not-allowed; }
.ra-cancelar { background: #f1f5f9; color: #475569; }
.ra-cancelar:hover { background: #e2e8f0; }

@media (max-width: 768px) {
    .ra-boton { top: 108px; padding: 8px; }
    .ra-boton-texto { display: none; }
    .ra-carga { margin-left: 0; width: 100%; text-align: left; }
}

/* ─── Viaje, orden de salida y horario de descarga ───
   Tres cosas que antes no se veían en el plan: si un equipo hace un segundo
   viaje, en qué orden salen las rutas, y a qué horas recibe cada cliente. */
.ra-turno {
    font-size: 11px; font-weight: 700; color: #6d28d9;
    background: #ede9fe; border-radius: 999px; padding: 2px 9px;
}
.ra-salida {
    font-size: 11px; font-weight: 700; color: #0369a1;
    background: #e0f2fe; border-radius: 999px; padding: 2px 9px;
}
.ra-parada-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; margin-right: 6px;
    background: #1e293b; color: #fff; border-radius: 50%;
    font-size: 11px; font-weight: 700; vertical-align: middle;
}
.ra-parada-horario {
    color: #92400e; font-size: 12px; font-weight: 600;
    background: #fffbeb; border-left: 3px solid #f59e0b;
    border-radius: 4px; padding: 2px 7px; margin-top: 3px;
    display: inline-block;
}

/* Hora de salida de la nave (solo hay dos: 6:00 y 7:00) y a qué distancia
   queda cada parada, que es lo que decide el orden dentro de la ruta. */
.ra-hora {
    font-size: 11px; font-weight: 700; color: #92400e;
    background: #fef3c7; border-radius: 999px; padding: 2px 9px;
}
.ra-parada-km { color: #64748b; font-size: 11.5px; margin-top: 2px; }

/* ─── Una ruta que no se puede hacer ───
   Antes los fallos salían todos juntos en una caja al final, y la ruta que
   los provocaba se pintaba arriba con su aspecto de siempre: un camión
   averiado se veía igual que uno bueno. Ahora se ve dónde está el problema. */
.ra-ruta.con-fallo { border-color: #fca5a5; background: #fff5f5; }
.ra-ruta-fallo {
    display: flex; gap: 8px; align-items: flex-start;
    background: #fee2e2; color: #991b1b;
    border-radius: 8px; padding: 7px 10px; margin-bottom: 8px;
    font-size: 12.5px; font-weight: 600; line-height: 1.45;
}
.ra-ruta-fallo > i { margin-top: 2px; }
