.shi-tracking-widget
{
    --shi-primary: #ff6b00;
    --shi-primary-hover: #e55f00;
    --shi-green: #22c55e;
    --shi-blue: #3b82f6;
    --shi-text: #1f2937;
    --shi-muted: #6b7280;
    --shi-border: #e5e7eb;
    --shi-bg: #f9fafb;

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--shi-bg);
    color: var(--shi-text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.shi-tracking-widget *
{
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ===== Main ===== */
.shi-main 
{
    flex: 1;
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 16px 40px;
}

.shi-tracking-widget h1 
{
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: #0f172a;
}

/* ===== Search Box ===== */
.shi-search-box
{
    background: #fff;
    border: 1px solid var(--shi-border);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.shi-search-input-wrap
{
    flex: 1;
    position: relative;
}

#shi-trackingInput
{
    width: 100%;
    border: none;
    outline: none;
    font-size: 0.95rem;
    resize: none;
    min-height: 44px;
    line-height: 1.5;
    color: var(--shi-text);
    font-family: inherit;
    background: transparent;
}

#shi-trackingInput::placeholder
{
    color: #94a3b8;
}

.shi-clear-btn
{
    position: absolute;
    right: 0;
    top: 8px;
    background: #e2e8f0;
    border: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    color: #64748b;
    display: none;
}

.shi-clear-btn.show
{
    display: flex;
    align-items: center;
    justify-content: center;
}

.shi-track-btn
{
    background: var(--shi-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    transition: background 0.2s;
    min-height: 44px;
}

.shi-track-btn:hover
{
    background: var(--shi-primary-hover);
}

.shi-track-btn:disabled
{
    opacity: 0.6;
    cursor: not-allowed;
}

/* ===== Results ===== */
.shi-results-header
{
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: var(--shi-muted);
}

.shi-expand-all
{
    background: none;
    border: none;
    color: var(--shi-blue);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.shi-expand-all.open
{
    color: var(--shi-primary);
}

.shi-results-list
{
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Single result card (auto-expanded) */
.shi-single-card
{
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--shi-border);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.shi-single-meta
{
    padding: 16px 18px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    border-bottom: 1px solid var(--shi-border);
}

.shi-meta-item label
{
    display: block;
    font-size: 0.75rem;
    color: var(--shi-muted);
    margin-bottom: 2px;
}

.shi-meta-item .value
{
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.shi-copy-btn
{
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    padding: 2px;
    font-size: 1rem;
}

.shi-copy-btn:hover
{
    color: var(--shi-primary);
}

/* Multi result accordion */
.shi-result-item
{
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--shi-border);
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.shi-result-item.open
{
    border-color: #fdba74;
    box-shadow: 0 0 0 1px #fdba74;
}

.shi-result-summary
{
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.shi-result-num
{
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #f1f5f9;
    color: #475569;
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.shi-result-item.open .shi-result-num
{
    background: var(--shi-primary);
    color: #fff;
}

.shi-result-info
{
    flex: 1;
    min-width: 0;
}

.shi-result-tn
{
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.shi-result-dest
{
    font-size: 0.85rem;
    color: var(--shi-muted);
}

.shi-result-status
{
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 2px;
}

.shi-status-delivered
{
    color: var(--shi-green);
}

.shi-status-out
{
    color: var(--shi-blue);
}

.shi-status-arrived
{
    color: var(--shi-blue);
}

.shi-status-default
{
    color: var(--shi-primary);
}

.shi-toggle-btn
{
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px;
    transition: transform 0.2s;
}

.shi-result-item.open .shi-toggle-btn
{
    transform: rotate(180deg);
    color: var(--shi-primary);
}

.shi-toggle-icon
{
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.shi-result-item.open .shi-toggle-icon
{
    transform: rotate(180deg);
}

.shi-view-details-btn
{
    padding: 6px 10px;
    /* keep horizontal + vertical balanced */
}

.shi-view-details-btn,
.shi-toggle-btn
{
    display: inline-flex;
    /* important */
    align-items: center;
    justify-content: center;
    gap: 6px;
    /* space between text and icon */
    line-height: 1;
    /* prevents extra height */
    vertical-align: middle;
}

.shi-view-details-btn .shi-toggle-icon,
.shi-toggle-btn .shi-toggle-icon
{
    display: block;
    /* removes inline SVG baseline gap */
    flex-shrink: 0;
    width: 14px;
    /* or whatever size you want */
    height: 14px;
    /* optional fine-tuning */
    margin-top: 1px;
    /* nudge down a tiny bit if needed */
    /* or */
    /* transform: translateY(1px); */
}

.shi-expand-all-icon
{
    transform: translateY(2px);
}

.shi-result-item.open .shi-view-details-btn .shi-toggle-icon
{
    transform: translateY(-1px) rotate(180deg);
}

/* Tracking History */
.shi-tracking-history
{
    padding: 0 16px 16px;
    display: none;
}

.shi-result-item.open .shi-tracking-history,
.shi-single-card .shi-tracking-history
{
    display: block;
}

.shi-history-title
{
    font-size: 0.9rem;
    font-weight: 600;
    margin: 12px 0 14px;
    color: #334155;
}

.shi-timeline
{
    position: relative;
    padding-left: 24px;
}

.shi-timeline::before
{
    content: "";
    position: absolute;
    left: 7px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: #e2e8f0;
}

.shi-timeline-item
{
    position: relative;
    padding-bottom: 18px;
}

.shi-timeline-item:last-child
{
    padding-bottom: 0;
}

.shi-timeline-dot
{
    position: absolute;
    left: -24px;
    top: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #cbd5e1;
    border: 3px solid #fff;
    box-shadow: 0 0 0 1px #e2e8f0;
}

.shi-timeline-item:first-child .shi-timeline-dot
{
    background: var(--shi-green);
    box-shadow: 0 0 0 1px var(--shi-green);
}

.shi-timeline-status
{
    font-weight: 600;
    font-size: 0.95rem;
}

.shi-timeline-item:first-child .shi-timeline-status
{
    color: var(--shi-green);
}

.shi-timeline-location
{
    font-size: 0.85rem;
    color: var(--shi-muted);
}

.shi-timeline-time
{
    font-size: 0.8rem;
    color: #94a3b8;
    margin-top: 2px;
}

/* Empty / Loading / Error */
.shi-message
{
    text-align: center;
    padding: 40px 20px;
    color: var(--shi-muted);
    font-size: 0.95rem;
}

.shi-spinner
{
    width: 28px;
    height: 28px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--shi-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Desktop multi table style */
@media (min-width: 768px)
{
    .shi-multi-table 
    {
        background: #fff;
        border-radius: 12px;
        border: 1px solid var(--shi-border);
        overflow: hidden;
    }

    .shi-multi-table .shi-table-header
    {
        display: grid;
        grid-template-columns: 40px 1.6fr 1fr 1.3fr 1.2fr 1.1fr 100px;
        gap: 8px;
        padding: 12px 16px;
        background: #f8fafc;
        font-size: 0.8rem;
        color: var(--shi-muted);
        font-weight: 600;
        border-bottom: 1px solid var(--shi-border);
    }

    .shi-multi-table .shi-result-item
    {
        border: none;
        border-radius: 0;
        border-bottom: 1px solid var(--shi-border);
    }

    .shi-multi-table .shi-result-item:last-child
    {
        border-bottom: none;
    }

    .shi-multi-table .shi-result-summary
    {
        display: grid;
        grid-template-columns: 40px 1.6fr 1fr 1.3fr 1.2fr 1.1fr 100px;
        gap: 8px;
        align-items: center;
        padding: 14px 16px;
    }

    .shi-multi-table .shi-result-info
    {
        display: contents;
    }

    .shi-multi-table .shi-result-tn,
    .shi-multi-table .shi-result-dest,
    .shi-multi-table .shi-result-status,
    .shi-multi-table .result-location,
    .shi-multi-table .result-time
    {
        font-size: 0.9rem;
    }

    .shi-multi-table .shi-result-status
    {
        margin-top: 0;
    }

    .shi-view-details-btn
    {
        background: #fff;
        border: 1px solid var(--shi-border);
        border-radius: 6px;
        padding: 6px 10px;
        font-size: 0.8rem;
        cursor: pointer;
        color: var(--shi-blue);
        display: flex;
        align-items: center;
        gap: 4px;
        white-space: nowrap;
    }

    .shi-result-item.open .shi-view-details-btn
    {
        border-color: #fdba74;
        color: var(--shi-primary);
    }
}

/* Mobile-only adjustments */
@media (max-width: 639px)
{
    .shi-desktop-only
    {
        display: none !important;
    }
}

@media (min-width: 640px)
{
    .shi-search-box
    {
        flex-direction: row;
        align-items: flex-start;
        padding: 10px 12px 10px 16px;
    }

    .shi-single-meta
    {
        grid-template-columns: 1.4fr 1fr 1fr;
        gap: 20px;
    }

    .shi-timeline-item
    {
        display: grid;
        grid-template-columns: 1.4fr 1.2fr 1fr;
        gap: 12px;
        align-items: start;
    }

    .shi-timeline-time
    {
        text-align: right;
        margin-top: 0;
    }

    .shi-mobile-only
    {
        display: none !important;
    }
}
