/* ========================================================================
   UDRINK · Tracking redesign · prototype
   Sistema de diseño cliente: Be Vietnam Pro · primario #1152D4 · success #10B981
   ======================================================================== */

:root {
    --ud-primary: #1152D4;
    --ud-primary-hover: #0F4BC4;
    --ud-secondary: #0A2540;
    --ud-success: #10B981;
    --ud-success-soft: #ECFDF5;
    --ud-warning: #D97706;
    --ud-danger: #C03030;
    --ud-ink: #0D121B;
    --ud-muted: #4C669A;
    --ud-line: #E7EBF3;
    --ud-bg: #F6F7F8;
    --ud-bg-card: #FFFFFF;
    --ud-radius-card: 16px;
    --ud-radius-control: 12px;
    --ud-shadow-card: 0 8px 20px -14px rgba(15, 23, 42, .18);
    --ud-shadow-pop: 0 16px 40px -22px rgba(15, 23, 42, .35);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: "Be Vietnam Pro", system-ui, sans-serif;
    color: var(--ud-ink);
    background: var(--ud-bg);
}

.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
    vertical-align: middle;
    line-height: 1;
}

/* ======================== HEADER ======================== */

.ud-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(255, 255, 255, .85);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--ud-line);
}

.ud-header-inner {
    max-width: 640px;
    margin: 0 auto;
    height: 60px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ud-brand {
    display: inline-flex;
    text-decoration: none;
    transition: transform .15s ease;
}
.ud-brand:active { transform: scale(.98); }

.ud-brand-mark {
    display: inline-flex;
    align-items: center;
    background: var(--ud-primary);
    color: #FFFFFF;
    font-weight: 900;
    font-size: 18px;
    letter-spacing: .02em;
    line-height: 1;
    padding: 8px 12px;
    border-radius: 8px;
}

.ud-brand-bar {
    display: inline-block;
    width: 4px;
    height: 18px;
    background: #FFFFFF;
    margin-left: 8px;
    border-radius: 2px;
}

.ud-icon-btn {
    appearance: none;
    border: 1px solid var(--ud-line);
    background: #FFFFFF;
    color: var(--ud-ink);
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}
.ud-icon-btn:hover { background: var(--ud-bg); border-color: #D6DBE5; }
.ud-icon-btn .material-symbols-outlined { font-size: 22px; }

/* ======================== WRAPPER ======================== */

.ud-wrap {
    flex: 1;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 20px 16px 32px;
}

.ud-card-shell {
    background: var(--ud-bg-card);
    border: 1px solid var(--ud-line);
    border-radius: 24px;
    box-shadow: var(--ud-shadow-card);
    overflow: hidden;
}

/* ======================== HERO ======================== */

.ud-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 22px 20px 6px;
}

.ud-hero-title {
    margin: 0;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -.015em;
    line-height: 1.15;
    color: var(--ud-ink);
}

/* ======================== STEPPER ======================== */

.ud-stepper {
    padding: 8px 20px 24px;
}

.ud-stepper-track {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.ud-stepper-track-bg,
.ud-stepper-track-fill {
    position: absolute;
    top: 18px;
    left: 18px;
    right: 18px;
    height: 3px;
    border-radius: 999px;
}

.ud-stepper-track-bg { background: var(--ud-line); }

/* La variable --progress (0..1) controla el ancho del fill Y la posición de la moto. */
.ud-stepper-track[data-state="paid"]       { --progress: 0; }
.ud-stepper-track[data-state="accepted"]   { --progress: 0.3333; }
.ud-stepper-track[data-state="on_the_way"] { --progress: 0.6667; }
.ud-stepper-track[data-state="delivered"]  { --progress: 1; }

.ud-stepper-track-fill {
    background: var(--ud-success);
    width: calc((100% - 36px) * var(--progress, 0));
    transition: width 3s cubic-bezier(.4, 0, .2, 1);
}

.ud-step {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    width: 64px;
}

.ud-step-dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--ud-line);
    color: var(--ud-muted);
    border: 3px solid #FFFFFF;
    box-shadow: 0 0 0 1px var(--ud-line);
    transition: background .25s ease, color .25s ease, box-shadow .25s ease, transform .25s ease;
}

.ud-step-dot .material-symbols-outlined { font-size: 18px; }

.ud-step-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ud-muted);
    text-align: center;
    line-height: 1.2;
}

.ud-step.is-done .ud-step-dot {
    background: var(--ud-success);
    color: #FFFFFF;
    box-shadow: 0 0 0 1px var(--ud-success);
}
.ud-step.is-done .ud-step-label { color: var(--ud-success); }

/* Activo · el dot se vuelve invisible para no tapar la moto que aterriza acá.
   La moto es el indicador visual del estado actual; el label en azul confirma cuál es. */
.ud-step.is-active .ud-step-dot {
    background: transparent;
    color: transparent;
    border-color: transparent;
    box-shadow: none;
    transform: none;
    animation: none;
}
.ud-step.is-active .ud-step-label { color: var(--ud-primary); }

/* ======================== MOTO marker (se desliza entre estados) ======================== */

.ud-moto-marker {
    position: absolute;
    top: 18px;
    /* Centro del dot · de 18px (centro del primer dot) a 100% - 18px (centro del último) */
    left: calc(18px + (100% - 36px) * var(--progress, 0));
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    color: var(--ud-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: left 3s cubic-bezier(.4, 0, .2, 1),
                color .4s ease,
                filter .4s ease;
    pointer-events: none;
    /* Solo ícono visible · sin círculo. Drop-shadow para legibilidad sobre cualquier fondo. */
    filter: drop-shadow(0 2px 3px rgba(15, 23, 42, .35));
}

.ud-moto-marker .material-symbols-outlined {
    font-size: 36px;
    font-variation-settings: 'FILL' 1, 'wght' 600;
}

/* Estado final · cuando llega a Entregado pasa a verde success */
.ud-stepper-track[data-state="delivered"] .ud-moto-marker {
    color: var(--ud-success);
    filter: drop-shadow(0 2px 4px rgba(16, 185, 129, .45));
}

/* ======================== Humo del tubo de escape ======================== */

.ud-moto-smoke {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 50%,
        rgba(170, 182, 200, .85) 0%,
        rgba(160, 174, 192, .55) 55%,
        rgba(150, 165, 185, 0) 100%);
    pointer-events: none;
    z-index: 4;
    transform: translate(-50%, -50%) scale(.35);
    opacity: 0;
    animation: udSmokePuff var(--smoke-duration, 1.1s) cubic-bezier(.25, .85, .35, 1) forwards;
    will-change: transform, opacity;
}

@keyframes udSmokePuff {
    0% {
        transform: translate(-50%, -50%) scale(.35);
        opacity: 0;
    }
    18% {
        opacity: .75;
    }
    100% {
        transform: translate(
            calc(-50% + var(--smoke-drift-x, 0px)),
            calc(-50% + var(--smoke-drift-y, -22px))
        ) scale(1.9);
        opacity: 0;
    }
}

/* ======================== MAPA ======================== */

.ud-map-card {
    margin: 0 16px 20px;
    background: #FFFFFF;
    border: 1px solid var(--ud-line);
    border-radius: var(--ud-radius-card);
    overflow: hidden;
    box-shadow: var(--ud-shadow-card);
}

.ud-map-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px 10px;
}

.ud-map-eyebrow {
    margin: 0;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .12em;
    color: var(--ud-primary);
}

.ud-eta-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--ud-primary);
    color: #FFFFFF;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 4px 12px -6px rgba(17, 82, 212, .55);
}
.ud-eta-pill .material-symbols-outlined {
    font-size: 14px;
    font-variation-settings: 'FILL' 0, 'wght' 600;
}
.ud-eta-pill strong { font-weight: 800; }

.ud-map-canvas {
    position: relative;
    width: 100%;
    height: 224px;
    background: linear-gradient(180deg, #EEF2F7 0%, #E5EAF2 100%);
}

.ud-map-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--ud-muted);
    font-size: 13px;
    font-weight: 600;
    pointer-events: none;
}

.ud-map-loading.is-hidden { display: none; }

.ud-spin {
    animation: udSpin 1.2s linear infinite;
}

@keyframes udSpin {
    to { transform: rotate(360deg); }
}

.ud-map-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 10px 16px 14px;
    font-size: 12px;
    color: var(--ud-muted);
}

.ud-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: var(--ud-ink);
}

.ud-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #FFFFFF;
    box-shadow: 0 0 0 1px var(--ud-line);
}
.ud-legend-dot.is-bh { background: var(--ud-primary); box-shadow: 0 0 0 1px var(--ud-primary); }
.ud-legend-dot.is-dest { background: var(--ud-danger); box-shadow: 0 0 0 1px var(--ud-danger); }

.ud-legend-sep { color: var(--ud-line); font-weight: 700; }

.ud-legend-note {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--ud-muted);
    margin-left: auto;
}
.ud-legend-note .material-symbols-outlined { font-size: 14px; }

/* ======================== TIMELINE ======================== */

.ud-timeline {
    padding: 4px 20px 20px;
}

.ud-timeline-eyebrow {
    margin: 0 0 10px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .12em;
    color: var(--ud-primary);
}

.ud-timeline-scroll {
    /* Aprox 3 ítems visibles · scroll vertical para los demás */
    max-height: 168px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 6px;
    mask-image: linear-gradient(180deg, #000 0%, #000 calc(100% - 24px), transparent 100%);
    -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 calc(100% - 24px), transparent 100%);
}
.ud-timeline-scroll::-webkit-scrollbar { width: 6px; }
.ud-timeline-scroll::-webkit-scrollbar-track { background: transparent; }
.ud-timeline-scroll::-webkit-scrollbar-thumb {
    background: var(--ud-line);
    border-radius: 999px;
}
.ud-timeline-scroll::-webkit-scrollbar-thumb:hover { background: #d6dbe5; }

.ud-timeline-list {
    list-style: none;
    margin: 0;
    padding: 0 0 0 12px;
    position: relative;
}
.ud-timeline-list::before {
    content: "";
    position: absolute;
    top: 8px;
    bottom: 8px;
    left: 4px;
    width: 2px;
    background: var(--ud-line);
    border-radius: 1px;
}

.ud-timeline-item {
    position: relative;
    padding: 6px 0 12px 18px;
    display: flex;
    gap: 0;
    flex-direction: column;
}

.ud-timeline-bullet {
    position: absolute;
    left: -8px;
    top: 9px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--ud-line);
    border: 2px solid #FFFFFF;
    box-shadow: 0 0 0 1px var(--ud-line);
}
.ud-timeline-item.is-current .ud-timeline-bullet {
    background: var(--ud-primary);
    box-shadow: 0 0 0 1px var(--ud-primary), 0 0 0 5px rgba(17, 82, 212, .15);
}

.ud-timeline-text {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--ud-ink);
    line-height: 1.4;
}

.ud-timeline-time {
    margin: 2px 0 0;
    font-size: 11px;
    color: var(--ud-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* ======================== SUMMARY ======================== */

.ud-summary {
    margin: 0 16px 16px;
    padding: 16px 18px;
    background: var(--ud-bg);
    border: 1px solid var(--ud-line);
    border-radius: var(--ud-radius-card);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ud-summary-title {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 800;
    color: var(--ud-ink);
}

.ud-summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ud-summary-row-divider {
    padding-bottom: 10px;
    border-bottom: 1px solid var(--ud-line);
    margin-bottom: 4px;
}

.ud-summary-label {
    font-size: 13px;
    color: var(--ud-muted);
}

.ud-summary-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--ud-ink);
}

.ud-summary-amount {
    color: var(--ud-primary);
    font-size: 15px;
}

.ud-summary-block {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 4px;
}

.ud-summary-eyebrow {
    margin: 0;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ud-muted);
}

.ud-summary-strong {
    margin: 0;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ud-ink);
    line-height: 1.45;
}

/* ======================== ACTIONS ======================== */

.ud-actions {
    padding: 0 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ud-btn {
    appearance: none;
    height: 48px;
    width: 100%;
    border-radius: var(--ud-radius-control);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: .01em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, border-color .15s ease, transform .1s ease, box-shadow .15s ease;
}
.ud-btn:active { transform: translateY(1px); }
.ud-btn .material-symbols-outlined { font-size: 18px; }

.ud-btn-primary {
    background: var(--ud-primary);
    color: #FFFFFF;
    box-shadow: 0 4px 12px -6px rgba(17, 82, 212, .55);
}
.ud-btn-primary:hover { background: var(--ud-primary-hover); }

.ud-btn-outline {
    background: #FFFFFF;
    color: var(--ud-ink);
    border-color: var(--ud-line);
}
.ud-btn-outline:hover { background: var(--ud-bg); border-color: #D6DBE5; }

.ud-btn-danger {
    background: #DC2626;
    color: #FFFFFF;
    box-shadow: 0 4px 12px -6px rgba(220, 38, 38, .55);
}
.ud-btn-danger:hover { background: #B91C1C; }

/* Overlay de modal bloqueante. Clase propia porque el CSS está precompilado (sin pipeline JIT):
   bg-slate-900/50 de Tailwind no estaba compilado y el fondo no se atenuaba. */
.ud-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(2px);
}

/* A3/H-16 · ventana honesta de recuperación. NO bloqueante (card inline, sin overlay): el cliente sigue
   viendo el tracking detrás. Prominente + ícono animado para comunicar que el sistema está gestionando. */
.ud-recovery-panel {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 0 0 16px;
    padding: 16px 18px;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(17, 82, 212, .08), rgba(17, 82, 212, .04));
    border: 1px solid rgba(17, 82, 212, .22);
}
.ud-recovery-icon {
    flex: 0 0 auto;
    color: var(--ud-primary);
    font-size: 26px;
    animation: udRecoveryPulse 1.6s ease-in-out infinite;
}
.ud-recovery-text { display: flex; flex-direction: column; gap: 4px; }
.ud-recovery-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #0d121b;
    line-height: 1.35;
}
.ud-recovery-desc {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    color: #4c669a;
    line-height: 1.4;
}
@keyframes udRecoveryPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.12); opacity: .75; }
}

/* ======================== FOOT ======================== */

.ud-foot {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 16px 18px;
    border-top: 1px solid var(--ud-line);
    color: var(--ud-muted);
    font-size: 12px;
    font-weight: 600;
}
.ud-foot .material-symbols-outlined { font-size: 14px; }

/* ======================== MAP markers (HTML overlay vía Google Maps OverlayView) ======================== */

.ud-bh-marker {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--ud-primary);
    border: 3px solid #FFFFFF;
    box-shadow: 0 0 0 1px rgba(17, 82, 212, .35), 0 4px 12px -4px rgba(17, 82, 212, .65);
    position: relative;
    transform: translate(-50%, -50%);
    pointer-events: auto;
}

.ud-bh-marker::after {
    content: "";
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 2px solid var(--ud-primary);
    opacity: 0;
    animation: udBhPulse 1.8s cubic-bezier(.4, 0, .2, 1) infinite;
    pointer-events: none;
}

@keyframes udBhPulse {
    0% { transform: scale(.7); opacity: .8; }
    100% { transform: scale(1.6); opacity: 0; }
}

.ud-dest-marker {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--ud-danger);
    border: 3px solid #FFFFFF;
    box-shadow: 0 0 0 1px rgba(192, 48, 48, .4), 0 4px 12px -4px rgba(192, 48, 48, .6);
    transform: translate(-50%, -50%);
    position: relative;
}

.ud-dest-marker::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translate(-50%, -2px);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid var(--ud-danger);
    filter: drop-shadow(0 1px 0 #FFFFFF);
}

.ud-dest-label {
    position: absolute;
    left: 50%;
    transform: translate(-50%, 16px);
    background: #FFFFFF;
    color: var(--ud-ink);
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid var(--ud-line);
    box-shadow: 0 4px 10px -6px rgba(15, 23, 42, .35);
    white-space: nowrap;
}

/* ======================== Responsive ======================== */

@media (max-width: 380px) {
    .ud-hero-title { font-size: 22px; }
    .ud-step { width: 56px; }
    .ud-step-label { font-size: 10px; }
    .ud-map-canvas { height: 192px; }
}

@media (min-width: 768px) {
    .ud-hero-title { font-size: 30px; }
    .ud-map-canvas { height: 256px; }
}

/* ==================== FINDING · zona viva (P1/A5 v2) ==================== */
/* El indicador alterna pulso↔puntos (toggle en C#) + frase; los latidos ya no van al feed. */
.ud-finding-live {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding: 12px 14px;
    background: var(--ud-primary-soft, #E8F0FF);
    border-radius: 14px;
}
.ud-finding-text {
    font-size: 13px;
    color: var(--ud-muted);
    font-weight: 600;
    line-height: 1.35;
    margin: 0;
}
/* Punto que late + anillo que se expande */
.ud-finding-dot {
    position: relative;
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--ud-primary);
    flex: 0 0 auto;
    animation: udFindingBeat 1.6s ease-in-out infinite;
}
.ud-finding-dot::after {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid var(--ud-primary);
    animation: udFindingRing 1.6s ease-out infinite;
    pointer-events: none;
}
@keyframes udFindingBeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.25); }
}
@keyframes udFindingRing {
    0% { transform: scale(.6); opacity: .7; }
    100% { transform: scale(1.6); opacity: 0; }
}
/* Tres puntitos "escribiendo" con stagger */
.ud-dotted-waiting {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    flex: 0 0 auto;
}
.ud-dotted-waiting span {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--ud-primary);
    animation: udFindingBounce 1.2s ease-in-out infinite;
}
.ud-dotted-waiting span:nth-child(2) { animation-delay: .18s; }
.ud-dotted-waiting span:nth-child(3) { animation-delay: .36s; }
@keyframes udFindingBounce {
    0%, 80%, 100% { transform: translateY(0); opacity: .35; }
    40% { transform: translateY(-6px); opacity: 1; }
}
