/* ===========================================================================
   TrackingConsole.css
   ---------------------------------------------------------------------------
   Single stylesheet for the shipment tracking page.

   Replaces MobileView.css + TabView.css + LaptopView.css, which held ~1,815
   lines between them, redefined .inputGroup 65 times and .search 41 times, and
   carried two real defects:

     * a breakpoint COLLISION at exactly 1223px -- TabView ended at
       max-width:1223px while LaptopView began at min-width:1223px, so both
       applied at that width and fought each other;
     * NOTHING above 1800px -- LaptopView capped at max-width:1800px, so wide
       monitors fell back to unstyled markup.

   This file is fluid instead of device-bucketed: one set of rules, a couple of
   min-width breakpoints, so there is no width that is uncovered or doubly
   covered. Colours and spacing come from tokens declared once in :root.
   =========================================================================== */

/* ---------------------------------------------------------------------------
   Theme.

   Dark is the default for this page -- it is a working tool staff keep open all
   day. The header toggle writes data-theme onto <html> and the choice is
   remembered in localStorage.

   Every colour is a token declared here, so a theme swap only redefines tokens
   and no component rule needs to know which theme is active.
   --------------------------------------------------------------------------- */
:root,
:root[data-theme="dark"] {
    --ink: #E8EEF4;
    --ink-2: #C2D0DD;
    --muted: #8FA6BB;
    --muted-2: #6B8299;
    --ground: #0D1620;
    --surface: #151F2B;
    --surface-2: #1B2733;
    --line: #2A3846;
    --line-2: #222E3B;
    --brand: #E8555B; /* Duroflex red, lifted for contrast on the dark ground */
    --brand-ink: #F2787D;
    --brand-text: #2A0A0C; /* ink used ON the brand fill */
    --ok: #6FD79B;
    --ok-bg: #12301F;
    --warn: #E9A95C;
    --warn-bg: #32240F;
    --bad: #F1809B;
    --bad-bg: #331520;
    --info: #7FB6DE;
    --info-bg: #12293A;
    --focus: #7FB6DE;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.28);
}

:root[data-theme="light"] {
    --ink: #0F2133;
    --ink-2: #2B4257;
    --muted: #5B7A99;
    --muted-2: #8AA2B8;
    --ground: #EEF1F5;
    --surface: #FFFFFF;
    --surface-2: #F7F9FB;
    --line: #D7DEE7;
    --line-2: #E8EDF2;
    --brand: #C1272D; /* full-strength Duroflex red reads correctly on white */
    --brand-ink: #9E1F24;
    --brand-text: #FFFFFF;
    --ok: #1B7F4C;
    --ok-bg: #E4F3EA;
    --warn: #B45309;
    --warn-bg: #FBF0E2;
    --bad: #9F1239;
    --bad-bg: #FBE7EC;
    --info: #1F5F8B;
    --info-bg: #E4EEF6;
    --focus: #1F5F8B;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(15,33,51,.06), 0 4px 16px rgba(15,33,51,.06);
}

* { box-sizing: border-box; }

html, body { height: auto; }

body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font-family: Barlow, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.tc-wrap {
    max-width: 1400px;
    margin: 0 auto;
    padding-inline: 16px;
    padding-block: 20px 48px;
}

/* ---------- header ---------- */
.tc-top {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

/* Same Duroflex "D" mark the integration site uses as its tab icon, so the two
   apps read as one product. */
.tc-logo { height: 34px; width: 34px; flex: none; border-radius: 8px; }

.tc-titles h1 {
    font-family: "Barlow Condensed", Barlow, sans-serif;
    font-weight: 600;
    font-size: 22px;
    margin: 0;
    letter-spacing: .3px;
    text-wrap: balance;
}

.tc-titles p { color: var(--muted); font-size: 13px; margin: 0; }

/* Pushes the theme toggle to the far end of the header. */
.tc-spacer { flex: 1 1 auto; }

.tc-theme {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-2);
    border-radius: 8px;
    padding: 7px 12px;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    flex: none;
}

.tc-theme:hover { border-color: var(--muted-2); color: var(--ink); }
.tc-theme:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.tc-theme svg { width: 15px; height: 15px; }

/* Only one of the two icons shows, depending on the active theme: the moon
   while light is active (click for dark), the sun while dark is active. */
.tc-theme .tc-ico-dark { display: inline; }
.tc-theme .tc-ico-light { display: none; }
:root[data-theme="light"] .tc-theme .tc-ico-dark { display: none; }
:root[data-theme="light"] .tc-theme .tc-ico-light { display: inline; }

/* ---------- search panel ---------- */
.tc-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
}

.tc-panel h2 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--muted);
    margin: 0 0 12px;
    font-weight: 600;
}

.tc-segrow { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 12px; }

.tc-seg {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    font-size: 14px;
    user-select: none;
}

.tc-seg input {
    accent-color: var(--brand);
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
}

.tc-searchrow { display: flex; gap: 10px; flex-wrap: wrap; }

.tc-field {
    flex: 1 1 320px;
    min-width: 0;
    position: relative;
    display: flex;
    align-items: center;
}

.tc-field svg {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    color: var(--muted-2);
    pointer-events: none;
}

.tc-field input {
    width: 100%;
    padding: 11px 12px 11px 36px;
    font: inherit;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.tc-field input::placeholder { color: var(--muted-2); }

.tc-field input:focus {
    outline: 2px solid var(--focus);
    outline-offset: 1px;
    border-color: transparent;
}

.tc-btn {
    flex: 0 0 auto;
    padding: 11px 22px;
    font: inherit;
    font-weight: 600;
    background: var(--brand);
    /* Token, not a literal: on dark the lifted red needs dark ink (white on
       #E8555B falls below the 4.5:1 floor), on light the deep red needs white. */
    color: var(--brand-text);
    border: 1px solid var(--brand);
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
}

.tc-btn:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.tc-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.tc-btn[disabled] { opacity: .65; cursor: progress; }

.tc-hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }

/* ---------- states ---------- */
.tc-state {
    margin-top: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 36px 20px;
    text-align: center;
    box-shadow: var(--shadow);
}

.tc-state .ico { font-size: 26px; line-height: 1; }
.tc-state h3 { margin: 10px 0 4px; font-size: 16px; font-weight: 600; }
.tc-state p { margin: 0; color: var(--muted); font-size: 14px; }
.tc-state.is-error { border-color: var(--bad); background: var(--bad-bg); }
.tc-state.is-error h3, .tc-state.is-error p { color: var(--bad); }

/* skeleton shown while the request is in flight */
.tc-sk {
    margin-top: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.tc-sk-row {
    display: flex;
    gap: 14px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line-2);
}

.tc-sk-row:last-child { border-bottom: 0; }

.tc-sk-bar {
    height: 11px;
    border-radius: 5px;
    background: linear-gradient(90deg, var(--line-2), var(--line), var(--line-2));
    background-size: 200% 100%;
    animation: tc-sh 1.2s linear infinite;
    flex: 1;
}

@keyframes tc-sh {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .tc-sk-bar { animation: none; }
}

/* ---------- results ---------- */
.tc-rhead {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 22px 0 10px;
    flex-wrap: wrap;
}

.tc-rhead h2 { font-size: 15px; margin: 0; font-weight: 600; }
.tc-count { color: var(--muted); font-size: 13px; }

.tc-tablewrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

#TrackingDetails { width: 100%; border-collapse: collapse; font-size: 14px; margin: 0; }

#TrackingDetails thead th {
    text-align: left;
    padding: 10px 14px;
    white-space: nowrap;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
    font-weight: 600;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
}

#TrackingDetails tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line-2);
    vertical-align: middle;
}

#TrackingDetails tbody tr:last-child td { border-bottom: 0; }
#TrackingDetails tbody tr:hover { background: var(--surface-2); }

.tc-mono { font-variant-numeric: tabular-nums; font-weight: 500; }
.tc-sub { color: var(--muted); font-size: 12.5px; }
.tc-dash { color: var(--muted-2); }

a.tc-track {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--info);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

a.tc-track:hover { text-decoration: underline; }
a.tc-track:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.tc-pill {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.tc-pill.is-ok { background: var(--ok-bg); color: var(--ok); }
.tc-pill.is-warn { background: var(--warn-bg); color: var(--warn); }
.tc-pill.is-bad { background: var(--bad-bg); color: var(--bad); }
.tc-pill.is-info { background: var(--info-bg); color: var(--info); }

/* ---------------------------------------------------------------------------
   Loading overlay.

   Was a 70 KB Loader.gif with a baked-in background, which sat on the page as a
   pale rectangle that did not match either theme. This is drawn in CSS from the
   theme tokens instead: it costs no download, stays sharp at any zoom, and
   recolours automatically when the theme is switched.
   --------------------------------------------------------------------------- */
#overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    /* Literal fallback first for browsers without color-mix(); the token-based
       version below wins where it is supported and follows the theme. */
    background: rgba(13,22,32,.72);
    background: color-mix(in srgb, var(--ground) 72%, transparent);
    backdrop-filter: blur(2px);
}

.cv-spinner {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 14px;
}

/* Two counter-rotating arcs: the brand-red ring reads as "Duroflex", the
   slower inner ring keeps the motion from looking mechanical. */
.tc-loader {
    position: relative;
    width: 46px;
    height: 46px;
    flex: none;
}

.tc-loader::before,
.tc-loader::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid transparent;
}

.tc-loader::before {
    border-top-color: var(--brand);
    border-right-color: var(--brand);
    animation: tc-spin .9s linear infinite;
}

.tc-loader::after {
    inset: 9px;
    border-bottom-color: var(--info);
    animation: tc-spin 1.4s linear infinite reverse;
}

@keyframes tc-spin {
    to { transform: rotate(360deg); }
}

.tc-loading-text {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
}

/* Respect a reduced-motion preference: keep a visible indicator, drop the spin
   so it does not trigger motion sensitivity. */
@media (prefers-reduced-motion: reduce) {
    .tc-loader::before,
    .tc-loader::after {
        animation: none;
        border-color: var(--brand);
        opacity: .5;
    }
}

/* ---------------------------------------------------------------------------
   Narrow screens: the table reflows into stacked cards.

   The previous build only let the table scroll sideways on a phone, so reading
   one shipment meant dragging the table left and right. Each row becomes a card
   and each cell shows its column name, injected by the JS as .tc-lbl.
   --------------------------------------------------------------------------- */
.tc-lbl { display: none; }

@media (max-width: 720px) {
    .tc-tablewrap {
        overflow: visible;
        background: transparent;
        border: 0;
        box-shadow: none;
        border-radius: 0;
    }

    #TrackingDetails, #TrackingDetails tbody, #TrackingDetails tr, #TrackingDetails td {
        display: block;
        width: 100%;
    }

    #TrackingDetails thead { display: none; }

    #TrackingDetails tbody tr {
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        margin-bottom: 12px;
        padding: 4px 0;
    }

    #TrackingDetails tbody tr:hover { background: var(--surface); }

    #TrackingDetails tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 16px;
        padding: 9px 14px;
        border-bottom: 1px solid var(--line-2);
        text-align: right;
    }

    #TrackingDetails tbody td:last-child { border-bottom: 0; }

    .tc-lbl {
        display: block;
        text-align: left;
        flex: 0 0 auto;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: .07em;
        color: var(--muted);
        font-weight: 600;
    }

    .tc-btn { width: 100%; }
}

/* Accessible helper for labels that should be read but not shown. */
.tc-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
