/* Road Freight Tracking - public widgets (tracker + quote)
   Design tokens */
.rft-tracker, .rft-quote {
    --rft-ink: #1B2430;
    --rft-canvas: #FAFAF8;
    --rft-line: #E3E0D9;
    --rft-accent: #E8A33D;
    --rft-accent-rgb: 232, 163, 61;
    --rft-accent-ink: #7A4E10;
    --rft-muted: #6B7280;
    --rft-success: #2F8F5B;
    --rft-success-rgb: 47, 143, 91;
    --rft-success-bg: #E7F4EC;
    --rft-info: #2E6F9E;
    --rft-info-rgb: 46, 111, 158;
    --rft-info-bg: #E8F1F8;
    --rft-alert: #C0392B;
    --rft-alert-bg: #FBEAE8;
    --rft-radius: 10px;
    --rft-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
    --rft-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;

    max-width: 640px;
    margin: 1.75em 0;
    font-family: var(--rft-font);
    color: var(--rft-ink);
}

/* ---------- Shared form controls ---------- */

.rft-tracker-form {
    display: flex;
    gap: 0.6em;
}

.rft-tracker-form input[type="text"],
.rft-field input,
.rft-field select {
    flex: 1;
    padding: 0.7em 0.9em;
    border: 1px solid var(--rft-line);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1em;
    color: var(--rft-ink);
    background: #fff;
}

.rft-tracker-form input[type="text"]:focus-visible,
.rft-field input:focus-visible,
.rft-field select:focus-visible,
.rft-tracker-form button:focus-visible,
.rft-quote-form button:focus-visible {
    outline: 2px solid var(--rft-accent);
    outline-offset: 2px;
}

.rft-tracker-form button,
.rft-quote-form button {
    padding: 0.7em 1.5em;
    background: var(--rft-ink);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95em;
    transition: background 150ms ease;
}

.rft-tracker-form button:hover,
.rft-quote-form button:hover {
    background: #303c4d;
}

.rft-quote-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1em;
}

.rft-quote-form .rft-field {
    display: flex;
    flex-direction: column;
    gap: 0.4em;
}

.rft-quote-form .rft-field label {
    font-size: 0.85em;
    color: var(--rft-muted);
}

.rft-quote-form button {
    grid-column: 1 / -1;
    justify-self: start;
}

.rft-city-autocomplete {
    position: relative;
}

.rft-city-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 20;
    margin: 4px 0 0;
    padding: 4px;
    list-style: none;
    background: #fff;
    border: 1px solid var(--rft-line);
    border-radius: 8px;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 8px 20px rgba(27, 36, 48, 0.1);
}

.rft-city-suggestions li {
    padding: 0.55em 0.7em;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
}

.rft-city-suggestions li:hover,
.rft-city-suggestions li:focus-visible {
    background: #F5EFE2;
    outline: none;
}

.rft-tracker-result, .rft-quote-result {
    margin-top: 1.5em;
}

/* ---------- Result card ---------- */

.rft-card {
    background: var(--rft-canvas);
    border: 1px solid var(--rft-line);
    border-radius: var(--rft-radius);
    padding: 1.5em 1.6em;
}

.rft-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1em;
    margin-bottom: 1.5em;
}

.rft-tracking-id {
    font-family: var(--rft-mono);
    font-size: 1.05em;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.rft-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    padding: 0.3em 0.85em;
    border-radius: 999px;
    font-size: 0.85em;
    font-weight: 600;
    background: #F5EFE2;
    color: var(--rft-accent-ink);
    white-space: nowrap;
}

.rft-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.rft-status--delivered { background: var(--rft-success-bg); color: var(--rft-success); }
.rft-status--en_route { background: var(--rft-success-bg); color: var(--rft-success); }
.rft-status--in_transit { background: var(--rft-alert-bg); color: var(--rft-alert); }
.rft-status--delayed, .rft-status--cancelled { background: var(--rft-alert-bg); color: var(--rft-alert); }

/* ---------- Mini map ---------- */

.rft-map-wrap {
    margin-bottom: 1.5em;
}

.rft-route-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5em;
    font-weight: 600;
    font-size: 0.95em;
}

.rft-route-labels > div {
    display: flex;
    flex-direction: column;
    gap: 0.1em;
}

.rft-route-labels > div:last-child {
    align-items: flex-end;
    text-align: right;
}

.rft-route-date {
    font-weight: 400;
    font-size: 0.82em;
    color: var(--rft-muted);
}

.rft-route-city--dest {
    text-align: right;
}

.rft-map {
    position: relative;
    border: 1px solid var(--rft-line);
    border-radius: 8px;
    overflow: hidden;
    background: linear-gradient(180deg, #EEF4FA 0%, #E2ECF6 100%);
}

.rft-map-badge {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--rft-success);
    color: #fff;
    font-size: 0.82em;
    font-weight: 700;
    padding: 0.4em 1.1em;
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(27, 36, 48, 0.15);
}

.rft-map svg {
    display: block;
    width: 100%;
    height: auto;
}

.rft-map-caption {
    margin-top: 0.5em;
    font-size: 0.78em;
    color: var(--rft-muted);
}

/* Live truck position: a soft glow that breathes behind the marker,
   signalling "this updates in real time" - the icon itself stays crisp
   and legible; only the halo behind it pulses. */
.rft-truck-pulse {
    transform-box: fill-box;
    transform-origin: center;
    animation: rft-pulse-halo 2.4s ease-in-out infinite;
}

@keyframes rft-pulse-halo {
    0%, 100% { opacity: 0.25; transform: scale(1); }
    50% { opacity: 0.65; transform: scale(1.3); }
}

@media (prefers-reduced-motion: reduce) {
    .rft-truck-pulse { animation: none; opacity: 0.3; }
}

/* ---------- Stat row ---------- */

.rft-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--rft-line);
    border: 1px solid var(--rft-line);
    border-radius: 8px;
    overflow: hidden;
    margin: 1.5em 0;
}

.rft-stat {
    background: #fff;
    padding: 0.75em 0.9em;
    display: flex;
    flex-direction: column;
    gap: 0.2em;
}

.rft-stat-label {
    font-size: 0.72em;
    color: var(--rft-muted);
}

.rft-stat-value {
    font-weight: 600;
    font-size: 0.9em;
    line-height: 1.25;
}

/* ---------- Arrival banner ---------- */

.rft-banner {
    display: flex;
    align-items: center;
    gap: 0.6em;
    justify-content: center;
    border-radius: 8px;
    padding: 0.9em 1.2em;
    margin-bottom: 1.5em;
    font-weight: 600;
    font-size: 0.98em;
    text-align: center;
}

.rft-banner svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.rft-banner--progress { background: var(--rft-success-bg); color: var(--rft-success); }
.rft-banner--success { background: var(--rft-success-bg); color: var(--rft-success); }
.rft-banner--alert { background: var(--rft-alert-bg); color: var(--rft-alert); }
.rft-banner--neutral { background: #F1F1EF; color: var(--rft-ink); }

/* ---------- Share row ---------- */

.rft-share-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
    margin-bottom: 1.5em;
}

.rft-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    padding: 0.5em 0.9em;
    border: 1px solid var(--rft-line);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85em;
    font-weight: 600;
    color: var(--rft-ink);
    transition: background 150ms ease;
}

.rft-share-btn:hover {
    background: #F5EFE2;
}

.rft-share-btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

@media print {
    .rft-tracker-form, .rft-share-row {
        display: none !important;
    }
}

/* ---------- Details table (sender / receiver / driver / ETA) ---------- */

.rft-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-top: 1px solid var(--rft-line);
    margin-bottom: 0.5em;
}

.rft-detail-cell {
    padding: 0.9em 1.1em;
    border-bottom: 1px solid var(--rft-line);
}

.rft-detail-cell:nth-child(odd) {
    border-right: 1px solid var(--rft-line);
}

.rft-detail-label {
    font-size: 0.78em;
    color: var(--rft-muted);
    margin-bottom: 0.2em;
}

.rft-detail-value {
    font-weight: 600;
    font-size: 0.98em;
}

.rft-detail-value--muted {
    font-weight: 400;
    color: var(--rft-muted);
}

.rft-detail-sub {
    font-size: 0.82em;
    color: var(--rft-muted);
    margin-top: 0.1em;
}

.rft-detail-sub a {
    color: var(--rft-info);
    text-decoration: none;
}

.rft-detail-sub a:hover {
    text-decoration: underline;
}

/* ---------- Quote result ---------- */

.rft-quote-price {
    display: flex;
    align-items: baseline;
    gap: 0.6em;
    margin-bottom: 1.5em;
}

.rft-quote-price-value {
    font-size: 2.1em;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1;
}

.rft-quote-price-label {
    font-size: 0.85em;
    color: var(--rft-muted);
}

.rft-route-track--quote {
    display: flex;
    align-items: center;
    justify-content: center;
}

.rft-route-distance {
    position: relative;
    background: var(--rft-canvas);
    padding: 0 0.6em;
    font-size: 0.78em;
    font-weight: 600;
    color: var(--rft-muted);
    white-space: nowrap;
}

.rft-quote-card .rft-meta-row {
    border-top: 1px solid var(--rft-line);
    border-bottom: none;
    padding-bottom: 0;
}

/* ---------- Route ---------- */

.rft-route {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1em;
    margin-bottom: 1.5em;
}

.rft-route-point {
    display: flex;
    flex-direction: column;
    gap: 0.15em;
    max-width: 9em;
}

.rft-route-point--destination {
    text-align: right;
    align-items: flex-end;
}

.rft-route-city {
    font-weight: 600;
    font-size: 1em;
    line-height: 1.25;
}

.rft-route-sub {
    font-size: 0.78em;
    color: var(--rft-muted);
}

.rft-route-track {
    position: relative;
    height: 24px;
}

.rft-route-line {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    transform: translateY(-50%);
    background-image: repeating-linear-gradient(
        to right,
        var(--rft-line) 0,
        var(--rft-line) 6px,
        transparent 6px,
        transparent 12px
    );
}

.rft-route-marker {
    position: absolute;
    top: 50%;
    left: calc(var(--rft-progress, 0) * 1%);
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--rft-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--rft-ink);
    box-shadow: 0 0 0 4px var(--rft-canvas);
    transition: left 700ms cubic-bezier(0.22, 1, 0.36, 1);
}

.rft-route-marker svg {
    width: 13px;
    height: 13px;
}

@media (prefers-reduced-motion: reduce) {
    .rft-route-marker {
        transition: none;
    }
}

/* ---------- Meta row ---------- */

.rft-meta-row {
    display: flex;
    gap: 2em;
    padding: 1em 0;
    margin-bottom: 0.5em;
    border-top: 1px solid var(--rft-line);
    border-bottom: 1px solid var(--rft-line);
}

.rft-meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.15em;
}

.rft-meta-label {
    font-size: 0.78em;
    color: var(--rft-muted);
}

.rft-meta-value {
    font-weight: 600;
}

/* ---------- Step history (tracking timeline) ---------- */

.rft-steps-heading {
    font-weight: 600;
    font-size: 0.95em;
    margin: 1.5em 0 0.75em;
}

.rft-steps {
    list-style: none;
    margin: 0;
    padding: 0;
}

.rft-step {
    display: flex;
    gap: 0.9em;
    padding: 0.8em 0.9em;
    border-radius: 8px;
    margin-bottom: 0.5em;
}

.rft-step:last-child {
    margin-bottom: 0;
}

.rft-step--completed {
    background: var(--rft-success-bg);
}

.rft-step--current {
    background: var(--rft-info-bg);
    border: 1px solid var(--rft-info);
    padding: calc(0.8em - 1px) calc(0.9em - 1px);
}

.rft-step--upcoming {
    border: 1px dashed var(--rft-line);
    padding: calc(0.8em - 1px) calc(0.9em - 1px);
}

.rft-step--upcoming .rft-step-title {
    color: var(--rft-muted);
}

.rft-step--alert {
    background: var(--rft-alert-bg);
}

.rft-step-icon {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(27, 36, 48, 0.15), inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.rft-step-icon svg {
    width: 14px;
    height: 14px;
}

.rft-step--completed .rft-step-icon { background: var(--rft-success); color: #fff; }
.rft-step--current .rft-step-icon {
    background: var(--rft-info);
    color: #fff;
    animation: rft-pulse-icon 2s ease-in-out infinite;
}
.rft-step--upcoming .rft-step-icon { border: 1.5px dashed var(--rft-line); color: var(--rft-muted); }
.rft-step--alert .rft-step-icon { background: var(--rft-alert); color: #fff; }

/* Current step: a gentle, continuous brightness breathe on the icon glow -
   signals "this is happening now" without implying an error/warning. */
@keyframes rft-pulse-icon {
    0%, 100% { box-shadow: 0 0 0 0 rgba(var(--rft-info-rgb), 0.5); }
    50% { box-shadow: 0 0 0 6px rgba(var(--rft-info-rgb), 0); }
}

@media (prefers-reduced-motion: reduce) {
    .rft-step--current .rft-step-icon { animation: none; }
}

.rft-step-body {
    flex: 1;
    min-width: 0;
}

.rft-step-title {
    font-weight: 600;
    font-size: 0.95em;
}

.rft-step-desc {
    font-size: 0.85em;
    color: var(--rft-muted);
    margin-top: 0.15em;
}

.rft-step-time {
    font-family: var(--rft-mono);
    font-size: 0.76em;
    color: var(--rft-muted);
    margin-top: 0.2em;
}

/* ---------- Errors / loading ---------- */

.rft-error {
    color: var(--rft-alert);
    padding: 0.85em 1em;
    background: var(--rft-alert-bg);
    border-radius: 8px;
    font-size: 0.95em;
}

.rft-loading {
    color: var(--rft-muted);
    padding: 0.5em 0;
    font-size: 0.95em;
}

/* ---------- Small screens ---------- */

@media (max-width: 440px) {
    .rft-quote-form {
        grid-template-columns: 1fr;
    }
    .rft-route-point {
        max-width: 6.5em;
    }
    .rft-card-top {
        flex-wrap: wrap;
    }
    .rft-details {
        grid-template-columns: 1fr;
    }
    .rft-detail-cell:nth-child(odd) {
        border-right: none;
    }
    .rft-stats {
        grid-template-columns: 1fr;
    }
}
