/* AWB Tracking Plugin — Matches AWB System UI */

:root {
    --awb-primary: #E22F2F;
    --awb-primary-light: #fef2f2;
    --awb-text: #1e293b;
    --awb-muted: #64748b;
    --awb-border: #e2e8f0;
    --awb-bg: #f8fafc;
    --awb-white: #ffffff;
    --awb-radius: 20px;
    --awb-radius-sm: 16px;
}

/* =================== SEARCH CARD =================== */

.awb-tracking-widget {
    max-width: 1100px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--awb-text);
    line-height: 1.5;
}

.awb-search-card {
    background: var(--awb-white);
    border: 1px solid var(--awb-border);
    border-radius: 30px;
    padding: 44px 36px 36px;
    text-align: center;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
}

.awb-search-header {
    margin-bottom: 8px;
}

.awb-search-logo {
    margin-bottom: 14px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    max-height: 40px;
    width: auto;
}

.awb-search-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--awb-text);
    margin: 0 0 6px;
    letter-spacing: -0.01em;
}

.awb-search-subtitle {
    color: var(--awb-muted);
    font-size: 0.95rem;
    margin: 0 0 28px;
}

.awb-search-form {
    display: flex;
    gap: 12px;
    max-width: 520px;
    margin: 0 auto;
}

.awb-input {
    flex: 1;
    padding: 14px 18px;
    font-size: 1rem;
    border: 1.5px solid var(--awb-border);
    border-radius: var(--awb-radius-sm);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    color: var(--awb-text);
    background: var(--awb-bg);
    font-family: inherit;
}

.awb-input::placeholder {
    color: #94a3b8;
}

.awb-input:focus {
    border-color: var(--awb-primary);
    box-shadow: 0 0 0 4px rgba(226, 47, 47, 0.1);
    background: var(--awb-white);
}

.awb-track-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 26px;
    background: var(--awb-primary);
    color: #fff;
    border: none;
    border-radius: var(--awb-radius-sm);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s;
    white-space: nowrap;
}

.awb-track-btn:hover {
    background: #C62828;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(226, 47, 47, 0.3);
}

.awb-track-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.awb-track-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* =================== LOADING =================== */

.awb-loading {
    text-align: center;
    padding: 48px 0;
    color: var(--awb-muted);
}

.awb-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--awb-border);
    border-top-color: var(--awb-primary);
    border-radius: 50%;
    margin: 0 auto 14px;
    animation: awb-spin 0.7s linear infinite;
}

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

/* =================== ERROR =================== */

.awb-error {
    margin-top: 24px;
    padding: 18px 24px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--awb-radius-sm);
    color: #991b1b;
    font-weight: 500;
    text-align: center;
    animation: awb-popIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* =================== ENTRANCE ANIMATIONS =================== */

@keyframes awb-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes awb-popIn {
    0% { opacity: 0; transform: scale(0.9) translateY(20px); }
    60% { transform: scale(1.02) translateY(-2px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes awb-slideRight {
    from { opacity: 0; transform: translateX(-16px); }
    to { opacity: 1; transform: translateX(0); }
}

/* =================== RESULTS SECTION HEADER =================== */

.awb-results-header {
    margin-top: 40px;
    margin-bottom: 28px;
    text-align: center;
    animation: awb-fadeIn 0.3s ease-out;
    scroll-margin-top: 15px;
}

.awb-results-header h2 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--awb-text);
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.awb-results-header h2 svg {
    color: var(--awb-primary);
}

.awb-results-header .awb-header-line {
    display: block;
    width: 60px;
    height: 3px;
    background: var(--awb-primary);
    border-radius: 3px;
    margin: 10px auto 0;
}

.awb-results-header p {
    margin: 8px 0 0;
    font-size: 0.875rem;
    color: var(--awb-muted);
}

/* =================== RESULT CARDS =================== */

.awb-results-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 24px;
    align-items: start;
}

.awb-card {
    background: var(--awb-white);
    border: 1px solid var(--awb-border);
    border-radius: var(--awb-radius);
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    animation: awb-popIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
}

/* Stagger card entrance */
.awb-results-grid > div > .awb-card:nth-child(1) { animation-delay: 0.1s; }
.awb-results-grid > div > .awb-card:nth-child(2) { animation-delay: 0.25s; }
.awb-results-grid > div > .awb-card:nth-child(3) { animation-delay: 0.4s; }

.awb-card + .awb-card {
    margin-top: 20px;
}

/* Hero card — subtle animated SVG background, one mark per transport mode.
   The watermark used to be a truck for every shipment, which contradicted the
   mode named two lines below it. Road is the default, matching modeIcon(). */
.awb-card-hero {
    position: relative;
    overflow: hidden;
    --awb-hero-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23E22F2F' stroke-width='1' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='1' y='3' width='15' height='13'/%3E%3Cpolygon points='16 8 20 8 23 11 23 16 16 16 16 8'/%3E%3Ccircle cx='5.5' cy='18.5' r='2.5'/%3E%3Ccircle cx='18.5' cy='18.5' r='2.5'/%3E%3C/svg%3E");
}

.awb-card-hero.awb-hero-air {
    --awb-hero-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23E22F2F' stroke-width='1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.2 3.3a1.8 1.8 0 0 1 3.6 0V9l7.2 4.2v2.2l-7.2-2v3.9l2.4 1.7V21L12 20.2 7.8 21v-2l2.4-1.7v-3.9l-7.2 2v-2.2L10.2 9V3.3z'/%3E%3C/svg%3E");
}

.awb-card-hero.awb-hero-rail {
    --awb-hero-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23E22F2F' stroke-width='1' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='3' width='16' height='13' rx='2'/%3E%3Cline x1='4' y1='11' x2='20' y2='11'/%3E%3Ccircle cx='8.5' cy='13.5' r='1'/%3E%3Ccircle cx='15.5' cy='13.5' r='1'/%3E%3Cline x1='7' y1='21' x2='9' y2='18'/%3E%3Cline x1='17' y1='21' x2='15' y2='18'/%3E%3C/svg%3E");
}

.awb-card-hero.awb-hero-sea {
    --awb-hero-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23E22F2F' stroke-width='1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 19c1.4 0 2.1-1 3.5-1s2.1 1 3.5 1 2.1-1 3.5-1 2.1 1 3.5 1 2.1-1 3.5-1'/%3E%3Cpath d='M4 15V9l8-4 8 4v6'/%3E%3Cline x1='12' y1='5' x2='12' y2='15'/%3E%3C/svg%3E");
}

.awb-card-hero::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 260px;
    height: 260px;
    transform: translate(-50%, -50%);
    opacity: 0.04;
    background: var(--awb-hero-mark) center/contain no-repeat;
    animation: awb-heroPulse 6s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

.awb-card-hero > * {
    position: relative;
    z-index: 1;
}

@keyframes awb-heroPulse {
    0%, 100% { opacity: 0.035; transform: translate(-50%, -50%) scale(1) rotate(0deg); }
    50% { opacity: 0.06; transform: translate(-50%, -50%) scale(1.08) rotate(6deg); }
}

/* =================== SHIPMENT HEADER =================== */

.awb-shipment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.awb-shipment-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.awb-package-icon {
    background: var(--awb-primary-light);
    color: var(--awb-primary);
    padding: 10px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Header lines, in reading order: customer, AWB, activity. */
h3.awb-customer-name,
.awb-customer-name {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
    color: #E22F2F !important;
}

.awb-shipment-name {
    font-size: 0.9rem;
    color: var(--awb-text);
    margin: 2px 0 0;
    font-weight: 600;
}

.awb-shipment-awb {
    font-size: 0.8rem;
    color: var(--awb-muted);
    margin: 2px 0 0;
}

/* =================== STATUS BADGE =================== */

.awb-status-badge {
    padding: 6px 16px;
    border-radius: 99px;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
}

.awb-status-pending       { background: #fef3c7; color: #b45309; }
.awb-status-processing    { background: #e0f2fe; color: #0369a1; }
.awb-status-dispatched    { background: #e0f2fe; color: #0369a1; }
.awb-status-in_transit    { background: #dcfce7; color: #15803d; }
.awb-status-out_for_delivery { background: #dcfce7; color: #15803d; }
.awb-status-delivered     { background: #f1f5f9; color: #475569; }
.awb-status-returned      { background: #fef2f2; color: #991b1b; }
.awb-status-default       { background: #f1f5f9; color: #475569; }

/* =================== ROUTE GRID =================== */

.awb-route-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    position: relative;
}

.awb-route-grid::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 16px;
    bottom: 16px;
    width: 2px;
    transform: translateX(-50%);
    border-left: 2px dashed #c0c8d4;
    background: none;
}

.awb-route-label {
    color: var(--awb-muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.awb-route-city {
    font-size: 1.05rem;
    font-weight: 600;
}

.awb-route-date {
    color: var(--awb-muted);
    font-size: 0.8rem;
    margin-top: 4px;
}

.awb-route-dest {
    text-align: right;
}

.awb-route-dest .awb-route-label {
    justify-content: flex-end;
}

/* =================== DETAILS GRID =================== */

.awb-details-grid {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--awb-border);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.awb-detail-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--awb-muted);
    text-transform: uppercase;
    margin-bottom: 6px;
}

.awb-detail-value {
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.awb-mode-icon {
    display: inline-flex;
    align-items: center;
    color: var(--awb-primary);
    flex-shrink: 0;
}

/* =================== TIMELINE =================== */

.awb-timeline-title {
    margin: 0 0 20px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--awb-text);
}

.awb-timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.awb-timeline-item {
    display: flex;
    gap: 16px;
    animation: awb-slideRight 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
}

.awb-timeline-item:nth-child(1) { animation-delay: 0.3s; }
.awb-timeline-item:nth-child(2) { animation-delay: 0.4s; }
.awb-timeline-item:nth-child(3) { animation-delay: 0.5s; }
.awb-timeline-item:nth-child(4) { animation-delay: 0.6s; }
.awb-timeline-item:nth-child(5) { animation-delay: 0.7s; }
.awb-timeline-item:nth-child(6) { animation-delay: 0.8s; }
.awb-timeline-item:nth-child(7) { animation-delay: 0.9s; }
.awb-timeline-item:nth-child(8) { animation-delay: 1.0s; }

.awb-timeline-track {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.awb-timeline-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--awb-border);
    flex-shrink: 0;
    z-index: 1;
}

.awb-timeline-dot.active {
    background: var(--awb-primary);
    box-shadow: 0 0 0 4px rgba(226, 47, 47, 0.15);
}

.awb-timeline-line {
    flex: 1;
    min-height: 16px;
    width: 2px;
    background: var(--awb-border);
    margin: 4px 0;
}

.awb-timeline-content {
    padding-bottom: 20px;
    width: 100%;
}

.awb-timeline-item:last-child .awb-timeline-content {
    padding-bottom: 0;
}

.awb-timeline-status {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--awb-text);
    text-transform: capitalize;
}

.awb-timeline-status.muted {
    color: var(--awb-muted);
}

.awb-timeline-meta {
    font-size: 0.8rem;
    color: var(--awb-muted);
    margin-top: 3px;
}

.awb-timeline-notes {
    margin-top: 6px;
    font-size: 0.8rem;
    background: var(--awb-bg);
    padding: 8px 12px;
    border-radius: 10px;
    color: var(--awb-text);
    border: 1px solid var(--awb-border);
}

.awb-timeline-empty {
    text-align: center;
    color: var(--awb-muted);
    padding: 16px;
}

/* =================== STAMP CARD =================== */

.awb-stamp-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0 0 14px;
    color: var(--awb-primary);
}

.awb-stamp-link {
    display: block;
    text-decoration: none;
    cursor: pointer;
}

.awb-stamp-img {
    max-width: 100%;
    border-radius: 16px;
    border: 1px solid var(--awb-border);
    display: block;
}

/* Stamp zoom affordance — the stamp is the one thing in the results a
   consignee wants to look at closely, and it renders at column width. */
.awb-stamp-frame {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    cursor: zoom-in;
    border-radius: 16px;
    overflow: hidden;
    font: inherit;
    color: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.awb-stamp-frame:focus-visible {
    outline: 2px solid var(--awb-primary);
    outline-offset: 3px;
}

.awb-stamp-frame .awb-stamp-img {
    transition: transform .25s ease;
}

.awb-stamp-frame:hover .awb-stamp-img {
    transform: scale(1.03);
}

.awb-stamp-zoom {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.72);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    transition: background .2s ease, transform .2s ease;
}

.awb-stamp-frame:hover .awb-stamp-zoom {
    background: var(--awb-primary);
    transform: scale(1.08);
}

.awb-stamp-hint {
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--awb-muted);
}

/* =================== STAMP LIGHTBOX =================== */

.awb-lb {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    background: rgba(15, 23, 42, 0.96);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    transition: opacity .2s ease;
}

.awb-lb[hidden] { display: none; }

.awb-lb.open { opacity: 1; }

.awb-lb-stage {
    max-width: 100%;
    max-height: 100%;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-overflow-scrolling: touch;
}

.awb-lb-img {
    max-width: min(1100px, 92vw);
    max-height: 82vh;
    border-radius: 12px;
    background: #fff;
    cursor: zoom-in;
    transition: transform .2s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.awb-lb-img.zoomed {
    max-width: none;
    max-height: none;
    cursor: zoom-out;
}

.awb-lb-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    color: #fff;
}

.awb-lb-caption {
    font-size: 0.9rem;
    font-weight: 600;
}

.awb-lb-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.awb-lb-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 99px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    line-height: 1.2;
}

.awb-lb-btn:hover,
.awb-lb-btn:focus {
    background: rgba(255, 255, 255, 0.24);
    color: #fff;
}

.awb-lb-close {
    width: 38px;
    height: 38px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.1rem;
}

body.awb-lb-open { overflow: hidden; }

.awb-verified-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #15803d;
}

.awb-unverified-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--awb-muted);
}

/* =================== RESPONSIVE =================== */

@media (max-width: 768px) {
    .awb-search-card {
        padding: 32px 20px 28px;
        border-radius: 24px;
    }

    .awb-search-title {
        font-size: 1.3rem;
    }

    .awb-results-grid {
        grid-template-columns: 1fr;
    }

    .awb-route-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .awb-route-grid::before {
        display: none;
    }

    .awb-route-dest {
        text-align: left;
    }

    .awb-route-dest .awb-route-label {
        justify-content: flex-start;
    }

    .awb-details-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .awb-search-form {
        flex-direction: column;
    }

    .awb-shipment-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .awb-card {
        padding: 20px 16px;
    }

    .awb-results-header {
        margin-top: 32px;
    }
}
