/* Track Shipment page (TrackShipment.aspx). Mirrors the Courier Mate portal tracking page.
   Everything is scoped under .cm-track so the site theme (style.css) is not affected. */

.cm-track {
    --cm-orange: #f97316;
    --cm-orange-dark: #ea580c;
    --cm-orange-50: #fff7ed;
    --cm-green: #28a745;
    --cm-grey: #d3d3d3;
    --cm-teal-50: #f0fdfa;
    --cm-text: #1f2937;
    color: var(--cm-text);
    background: #fff;
}

.cm-track [hidden] { display: none !important; }

/* Hero */
.cm-hero { position: relative; }
.cm-hero-img {
    display: block;
    width: 100%;
    aspect-ratio: 2 / 1;
    object-fit: cover;
    border-radius: 12px;
}
.cm-hero-title {
    position: absolute;
    inset: 0;
    margin: 0;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-radius: 12px;
    background: rgba(2, 6, 23, 0.4);
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.05em;
    font-size: 1.875rem;
    line-height: 1.2;
}
@media (min-width: 768px) {
    .cm-hero-img { height: 55vh; aspect-ratio: auto; }
    .cm-hero-title { font-size: 3.75rem; }
}

/* Intro and search */
.cm-intro {
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.6;
    color: var(--cm-text);
    margin-bottom: 1rem;
}
.cm-intro b { font-weight: 700; }
@media (min-width: 768px) { .cm-intro { font-size: 1.25rem; } }

.cm-search { max-width: 720px; padding: 0 12px; }
.cm-search-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--cm-text);
}
.cm-search-hint label { font-size: inherit; font-weight: 500; color: inherit; }
@media (min-width: 768px) { .cm-search-hint { font-size: 1.25rem; } }

.cm-icon {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.cm-search-row { gap: 8px; }
.cm-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    font-size: 1rem;
}
.cm-input:focus { outline: 2px solid var(--cm-orange); outline-offset: 1px; }

.cm-btn {
    background: var(--cm-orange);
    color: #fff;
    border: 0;
    border-radius: 6px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background-color 0.15s;
}
.cm-btn:hover, .cm-btn:focus { background: var(--cm-orange-dark); color: #fff; }
.cm-btn:focus-visible { outline: 2px solid var(--cm-text); outline-offset: 2px; }
.cm-btn-track {
    font-size: 1.125rem;
    letter-spacing: 0.05em;
    padding: 8px 40px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.cm-message {
    margin-top: 12px;
    padding: 8px 12px;
    border-radius: 6px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

/* Progress tracker */
.cm-tracker {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin: 20px auto;
    width: 100%;
    text-align: left;
}
.cm-step { display: flex; flex-direction: column; width: 100%; }
.cm-step strong { display: block; margin-bottom: 4px; white-space: nowrap; }
.cm-step-bar { display: flex; align-items: center; width: 100%; }
.cm-dot {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    border-radius: 50%;
    background: var(--cm-grey);
    position: relative;
    z-index: 1;
}
.cm-line { flex-grow: 1; height: 4px; background: var(--cm-grey); }
.cm-step.reached .cm-dot {
    background: var(--cm-green);
    box-shadow: 0 0 4px 1px rgba(40, 167, 69, 0.4);
    animation: cm-sparkle 2s infinite alternate;
}
.cm-step.passed .cm-line { background: var(--cm-green); }
.cm-step:last-child { width: auto; }
@keyframes cm-sparkle {
    from { box-shadow: 0 0 10px 1px rgba(40, 167, 69, 0.6); }
    to { box-shadow: 0 0 20px 1px rgba(40, 167, 69, 0.9); }
}
@media (prefers-reduced-motion: reduce) { .cm-step.reached .cm-dot { animation: none; } }
.cm-br-sm { display: none; }
@media (max-width: 480px) {
    .cm-br-sm { display: inline; }
    .cm-step strong { white-space: normal; font-size: 0.9rem; }
}

/* Tabs */
.cm-tabs-wrap { width: 100%; }
@media (min-width: 768px) { .cm-tabs-wrap { width: 66.666%; } }
.cm-tablist {
    display: flex;
    justify-content: center;
    border-bottom: 2px solid var(--cm-orange);
    width: fit-content;
    margin: 0 auto;
}
.cm-tab {
    background: transparent;
    border: 0;
    border-radius: 6px 6px 0 0;
    padding: 8px 24px;
    font-size: 1rem;
    color: var(--cm-text);
    cursor: pointer;
}
@media (min-width: 768px) { .cm-tab { font-size: 1.125rem; } }
.cm-tab.active { background: var(--cm-orange); color: #fff; }
.cm-tab:focus-visible { outline: 2px solid var(--cm-orange-dark); outline-offset: 2px; }
.cm-panel { padding: 24px 0; }
.cm-empty { font-size: 1rem; color: var(--cm-text); }

/* Shipment details */
.cm-card {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    padding: 16px;
}
.cm-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 768px) {
    .cm-grid { grid-template-columns: 1fr 1fr; }
    .cm-span-2 { grid-column: span 2; }
}
.cm-tile {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--cm-teal-50);
    border-radius: 8px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
    padding: 12px;
    text-align: left;
    min-width: 0;
}
.cm-tile-icon { color: var(--cm-orange); display: flex; }
.cm-tile-label { color: var(--cm-orange); font-size: 1rem; margin: 0 0 2px; }
.cm-tile-value { font-weight: 600; margin: 0; color: var(--cm-text); word-break: break-word; }
.cm-rotate { transform: rotate(180deg); }

/* Tracking details */
.cm-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #d1d5db;
    background: #fff;
}
.cm-table th, .cm-table td {
    border: 1px solid #d1d5db;
    text-align: center;
    font-size: 0.875rem;
    color: #374151;
    padding: 12px 6px;
}
.cm-table th { background: var(--cm-orange-50); font-weight: 500; }
.cm-table tbody tr:hover { background: #f9fafb; }

.cm-event {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 12px;
    background: #fff;
}
.cm-event-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    background: var(--cm-teal-50);
    border-radius: 6px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
    padding: 8px 10px;
    margin-bottom: 6px;
    text-align: right;
}
.cm-event-row:last-child { margin-bottom: 0; }
.cm-event-row h6 { color: var(--cm-orange); margin: 0; text-align: left; flex: 0 0 auto; }
.cm-event-row span { word-break: break-word; }

/* Image popup */
.cm-overlay {
    position: fixed;
    inset: 0;
    z-index: 1050;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.cm-popup {
    position: relative;
    background: #fff;
    border-radius: 8px;
    padding: 16px;
    max-width: 768px;
    max-height: 90vh;
    overflow: auto;
}
.cm-popup img { max-width: 100%; max-height: 80vh; display: block; margin: 0 auto; }
.cm-popup-x {
    position: absolute;
    top: 4px;
    right: 8px;
    background: none;
    border: 0;
    font-size: 1.5rem;
    color: #4b5563;
    cursor: pointer;
}
.cm-popup-msg { margin: 24px 32px; }

/* Loading */
.cm-loading {
    position: fixed;
    inset: 0;
    z-index: 1060;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}
.cm-spinner {
    width: 48px;
    height: 48px;
    border: 5px solid var(--cm-grey);
    border-top-color: var(--cm-orange);
    border-radius: 50%;
    animation: cm-spin 0.8s linear infinite;
}
@keyframes cm-spin { to { transform: rotate(360deg); } }
