/* ==========================================================================
   SHIPMENT TRACKING — SHARED STYLESHEET
   Used by BOTH:
     track.html             (public, Option A — minimal)
     track-my-shipment.html (dashboard, Option B — full detail)

   Sections:
     1. Shared utilities (loading, error)
     2. PUBLIC page styles  (.pub-*)
     3. DASHBOARD page styles (.dash-*)
     4. Mobile responsiveness
   ========================================================================== */


/* ──────────────────────────────────────────────────────────────────────────
   1. SHARED UTILITIES
   ────────────────────────────────────────────────────────────────────── */

.track-loading {
    text-align: center;
    color: #64748b;
    font-size: 0.95rem;
    padding: 2rem 0;
}

.track-error {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 1rem;
}


/* ──────────────────────────────────────────────────────────────────────────
   2. PUBLIC PAGE — Option A (track.html / track-shipment.js)
   ────────────────────────────────────────────────────────────────────── */

.pub-result-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 1.5rem;
    margin-top: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.04);
}

.pub-result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.pub-invoice-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.1;
}

.pub-status-pill {
    display: inline-block;
    margin-top: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #185FA5;
    background: #E6F1FB;
    border-radius: 999px;
    padding: 4px 12px;
}

.pub-load-badge {
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 999px;
    padding: 5px 12px;
}

.pub-load-badge.pub-load-full {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.pub-load-badge.pub-load-partial {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.pub-status-message {
    font-size: 0.95rem;
    color: #475569;
    margin-bottom: 4px;
}

.pub-updated {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 1.25rem;
}

/* Route bar */
.pub-route-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #1e293b;
    flex-wrap: nowrap;
}

.pub-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.pub-dot-origin { background: #185FA5; }
.pub-dot-dest   { background: #0F6E56; }

.pub-route-city {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pub-route-line {
    flex: 1;
    min-width: 12px;
    height: 1px;
    background: #cbd5e1;
}

.pub-mode-tag {
    font-size: 0.72rem;
    font-weight: 600;
    color: #64748b;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    padding: 2px 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Horizontal progress rail — full lifecycle, 10 steps.
   Each .pub-rail-step groups its icon + label as ONE flex item, so
   centering is guaranteed by structure rather than by two separate rows
   (icons, labels) staying visually in sync via matching justify-content —
   which breaks once label lengths vary a lot across 10 real statuses. */
/* Wraps .pub-rail so we can show a fade-out edge cue on mobile without
   affecting the scroll container itself (the fade lives on the wrapper,
   the scrolling lives on .pub-rail — keeps the gradient fixed in place
   while content scrolls underneath it). */
.pub-rail-wrap {
    position: relative;
}

.pub-rail {
    display: flex;
    align-items: flex-start;
    margin-bottom: 8px;
    /* Hide the native scrollbar — the fade + swipe motion is the cue on
       mobile; on desktop the rail doesn't overflow, so this is inert. */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.pub-rail::-webkit-scrollbar {
    display: none;
}

.pub-rail-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    width: 68px;
}

.pub-rail-node {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #94a3b8;
    flex-shrink: 0;
    margin-bottom: 6px;
    transition: all 0.2s ease;
}

.pub-rail-node.done {
    background: #1e293b;
    border-color: #1e293b;
    color: #ffffff;
}

.pub-rail-node.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
    box-shadow: 0 0 0 4px rgba(37,99,235,0.15);
}

/* Attention state (RETURNED TO HUB) — amber, overrides .active blue.
   Matches the .active specificity (two classes) so it wins by source
   order rather than relying on !important. */
.pub-rail-node.pub-rail-node-alert {
    background: #d97706;
    border-color: #d97706;
    box-shadow: 0 0 0 4px rgba(217,119,6,0.18);
}

/* Connector sits between steps, vertically pinned to the node's center
   (40px node / 2 = 20px, minus half the 2px line = 19px) so it lines up
   regardless of label height/wrapping below it. */
.pub-rail-conn {
    flex: 1;
    min-width: 8px;
    height: 2px;
    background: #e2e8f0;
    margin-top: 19px;
}

.pub-rail-conn.done {
    background: #1e293b;
}

.pub-rail-label {
    font-size: 0.7rem;
    color: #94a3b8;
    text-align: center;
    line-height: 1.25;
    word-break: break-word;
}

.pub-rail-step.done .pub-rail-label,
.pub-rail-step.active .pub-rail-label {
    color: #1e293b;
    font-weight: 600;
}

.pub-rail-step.pub-rail-step-alert .pub-rail-label {
    color: #92400e;
}

/* Attention styling for the status pill/message — only applied while the
   invoice is actually at RETURNED TO HUB, never a permanent state. */
.pub-status-pill-alert {
    color: #92400e;
    background: #fffbeb;
}

.pub-status-message-alert {
    color: #92400e;
    font-weight: 600;
}


/* ──────────────────────────────────────────────────────────────────────────
   3. DASHBOARD PAGE — Option B (track-my-shipment.html / track-my-shipment.js)
   ────────────────────────────────────────────────────────────────────── */

/* Dashboard lookup form (shown before invoices load, hidden after) */
.track-my-shipment-wrapper { padding: 0; }

.track-lookup-form {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1.5rem;
}

.track-lookup-form .form-group {
    flex: 1;
    min-width: 220px;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}

.track-lookup-form label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.5rem;
}

.track-lookup-form select {
    padding: 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    color: #1e293b;
    background-color: #fff;
}

.btn-track-submit {
    padding: 0.78rem 1.75rem;
    background-color: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    white-space: nowrap;
}

.btn-track-submit:hover { background-color: #1d4ed8; }

/* Main tracker card */
.dash-tracker-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    overflow: hidden;
}

/* Invoice tabs */
.dash-tabs-bar {
    display: flex;
    overflow-x: auto;
    background: #74d0f3;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 1rem;
    gap: 0;
    scrollbar-width: none;
}

.dash-tabs-bar::-webkit-scrollbar { display: none; }

.dash-tab {
    font-size: 0.82rem;
    font-weight: 500;
    padding: 10px 14px;
    color: #64748b;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    transition: color 0.15s ease;
    background-color: #74d0f3;
}

.dash-tab:hover { color: #1e293b; }

.dash-tab.active {
    color: #1e293b;
    border-bottom-color: #2563eb;
    font-weight: 600;
}

/* Two-column body */
.dash-tracker-body {
    display: flex;
    align-items: stretch;
}

.dash-left-col {
    flex: 1;
    padding: 1.5rem;
    min-width: 0;
    overflow-y: auto;
}

.dash-right-col {
    width: 260px;
    flex-shrink: 0;
    padding: 1.5rem;
    border-left: 1px dashed #e2e8f0;
    position: sticky;
    top: 0;
    max-height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

/* Card header — invoice + status + balance */
.dash-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.dash-card-invoice {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.1;
}

.dash-card-status-row {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 5px;
    flex-wrap: wrap;
}

.dash-status-pill {
    font-size: 0.75rem;
    font-weight: 600;
    color: #185FA5;
    background: #E6F1FB;
    border-radius: 999px;
    padding: 3px 10px;
}

.dash-load-badge {
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 999px;
    padding: 3px 10px;
}

.dash-load-badge.dash-load-full {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.dash-load-badge.dash-load-partial {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.dash-balance-badge {
    font-size: 0.8rem;
    font-weight: 600;
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 999px;
    padding: 5px 14px;
    white-space: nowrap;
}

.dash-balance-badge.dash-balance-paid {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

/* Route bar */
.dash-route-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.65rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #1e293b;
    flex-wrap: nowrap;
}

.dash-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dash-dot-origin { background: #2563eb; }
.dash-dot-dest   { background: #16a34a; }
.dash-route-city { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-route-line { flex: 1; min-width: 12px; height: 1px; background: #cbd5e1; }

/* 4-node rail */
.dash-rail {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
}

.dash-rail-node {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #94a3b8;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.dash-rail-node.done {
    background: #1e293b;
    border-color: #1e293b;
    color: #ffffff;
}

.dash-rail-node.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.dash-rail-conn { flex: 1; height: 2px; background: #e2e8f0; }
.dash-rail-conn.done { background: #1e293b; }

.dash-phase-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.68rem;
    color: #94a3b8;
    margin-bottom: 1rem;
    padding: 0 2px;
}

/* Metrics */
.dash-metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 1rem;
}

.dash-metric {
    background: #f8fafc;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
}

.dash-metric-label {
    font-size: 0.7rem;
    color: #64748b;
    margin-bottom: 2px;
}

.dash-metric-val {
    font-size: 0.88rem;
    font-weight: 600;
    color: #1e293b;
}

.dash-metric-placeholder {
    color: #94a3b8;
    font-style: italic;
    font-weight: 400;
}

/* Detail grid */
.dash-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    padding: 1rem 0;
    border-top: 1px dashed #e2e8f0;
    border-bottom: 1px dashed #e2e8f0;
    margin-bottom: 1rem;
}

.dash-detail-label {
    font-size: 0.7rem;
    color: #64748b;
    margin-bottom: 3px;
    font-weight: 600;
}

.dash-detail-val {
    font-size: 0.85rem;
    color: #1e293b;
    font-weight: 500;
}

/* Items */
.dash-items-section { padding-bottom: 0.5rem; }

.dash-item-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #475569;
    padding: 6px 0;
    border-bottom: 1px dashed #e2e8f0;
}

.dash-item-row:last-child { border-bottom: none; }

.dash-no-items {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-top: 6px;
}

/* Right column: full 10-step vertical timeline */
.dash-tl-heading {
    font-size: 0.88rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.dash-timeline {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.dash-tl-item {
    display: flex;
    gap: 8px;
    position: relative;
    flex: 1;
    min-height: 0;
}

.dash-tl-item::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 14px;
    bottom: 0;
    width: 1px;
    background: #e2e8f0;
}

.dash-tl-item:last-child::before { display: none; }
.dash-tl-item.done::before { background: #16a34a; }

.dash-tl-marker {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #e2e8f0;
    flex-shrink: 0;
    margin-top: 3px;
    z-index: 1;
    transition: all 0.2s ease;
}

.dash-tl-item.done .dash-tl-marker { background: #16a34a; }
.dash-tl-item.active .dash-tl-marker {
    background: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.2);
}

.dash-tl-content { flex: 1; min-width: 0; }

.dash-tl-title {
    font-size: 0.72rem;
    font-weight: 500;
    color: #94a3b8;
    display: block;
    text-transform: capitalize;
    line-height: 1.3;
}

.dash-tl-item.done .dash-tl-title,
.dash-tl-item.active .dash-tl-title { color: #1e293b; }

.dash-tl-time {
    font-size: 0.65rem;
    color: #2563eb;
    font-weight: 600;
    display: block;
}

.dash-tl-desc {
    font-size: 0.65rem;
    color: #94a3b8;
    margin: 1px 0 0 0;
    line-height: 1.3;
}

.dash-tl-item.done .dash-tl-desc,
.dash-tl-item.active .dash-tl-desc { color: #64748b; }

.dash-tl-fallback {
    font-size: 0.85rem;
    color: #475569;
}


/* Mobile-only timeline — shown below rail on small screens, hidden on desktop */
.dash-timeline-mobile {
    display: none;
    margin: 1rem 0;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.dash-timeline-list {
    display: flex;
    flex-direction: column;
}

.dash-timeline-list .dash-tl-item {
    flex: 0 0 auto;
    padding-bottom: 12px;
}

.dash-timeline-list .dash-tl-item::before {
    top: 14px;
    bottom: 0;
}

/* ──────────────────────────────────────────────────────────────────────────
   4. MOBILE RESPONSIVENESS
   ────────────────────────────────────────────────────────────────────── */

@media (max-width: 700px) {
    /* Public */
    .pub-result-card { padding: 1.25rem 1rem; }
    .pub-invoice-number { font-size: 1.25rem; }

    /* 10-step rail is wide — scroll horizontally on small screens instead
       of squeezing/wrapping every step. Step width is tightened close to
       the node's own size so the connector reads as one continuous track
       rather than a dash floating in empty step padding. */
    .pub-rail-node { width: 32px; height: 32px; font-size: 0.9rem; }
    .pub-rail-step { width: 46px; }
    .pub-rail-label { font-size: 0.62rem; }
    .pub-rail-conn { margin-top: 15px; min-width: 14px; }

    .pub-rail {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 6px;
        /* Room after the last node so the fade cue never sits on top of
           it, and so the very last step isn't flush against the card's
           rounded corner. */
        padding-right: 28px;
        scroll-padding-right: 28px;
    }

    /* Fade cue: tells the eye there's more to scroll without needing a
       visible scrollbar. Sits on the wrapper (not .pub-rail) so it stays
       fixed in place while the rail scrolls underneath it. */
    .pub-rail-wrap::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 6px;
        width: 32px;
        background: linear-gradient(to right, rgba(255,255,255,0), #ffffff);
        pointer-events: none;
    }

    /* Dashboard — collapse to single column */
    .dash-tracker-body { flex-direction: column; }

    /* Show mobile-only timeline, hide the desktop right column */
    .dash-timeline-mobile { display: block; }
    .dash-right-col { display: none; }

    .dash-detail-grid { grid-template-columns: 1fr; }
    .dash-metrics-grid { grid-template-columns: repeat(2, 1fr); }

    .track-lookup-form { flex-direction: column; align-items: stretch; }
}

/* On desktop, always hide the mobile timeline duplicate */
@media (min-width: 701px) {
    .dash-timeline-mobile { display: none !important; }
}