/*
 * Order tracking — style mặc định dùng chung cho mọi theme.
 *
 * Theme chỉnh màu/font bằng cách khai báo lại biến --ot-* trong style.css của theme
 * (không cần copy file này). Chỉ khi layout khác hẳn mới tạo
 * themes/{theme}/public/css/order-tracking.css — file đó THAY THẾ hoàn toàn file này.
 */
/* :where() = độ ưu tiên 0: style.css của theme nạp TRƯỚC file này, khai báo :root { --ot-* } ở đó
 * vẫn thắng giá trị mặc định dưới đây (nếu dùng :root thường, file nạp sau sẽ thắng). */
:where(:root) {
    --ot-primary: #dc3545;
    --ot-success: #2e7d32;
    --ot-success-ink: #1b5e20; /* chữ trên nền nhạt — đủ tương phản 4.5:1 */
    --ot-success-soft: #e7f2e8;
    --ot-pending: #8a8f98; /* viền trạm chưa tới — đạt 3:1 trên --ot-surface */
    --ot-page: #fff; /* màu nền trang, cho hai vết khuyết của đường xé */
    --ot-muted: #6b7280;
    --ot-text: #1f2328;
    --ot-border: #e5e7eb;
    --ot-surface: #f7f7f8;
    --ot-radius: 12px;
    --ot-font: inherit;
}

/* Ô bẫy bot .ot-hp được ẩn bằng style inline trong form.php — không phụ thuộc file này. */

[data-ot-submit].is-loading {
    opacity: .7;
    cursor: progress;
}

[data-ot-submit]:disabled {
    cursor: not-allowed;
}

.ot-error {
    font-family: var(--ot-font);
}


/* ============================================================================================
 * Kết quả tra cứu — "nhãn kiện hàng": mã đơn + tuyến tiến độ ở trên, đường xé, mã vận đơn ở dưới.
 * Mọi selector nằm dưới .ot-result để CSS toàn cục của theme (ul, img, table, h3…) không lấn vào.
 * ========================================================================================== */
.ot-result {
    margin-top: 2.5rem;
    color: var(--ot-text);
    font-family: var(--ot-font);
    font-size: 1rem;
    line-height: 1.5;
    text-align: left;
}

.ot-result *,
.ot-result *::before,
.ot-result *::after {
    box-sizing: border-box;
}

.ot-result p,
.ot-result h3,
.ot-result h4,
.ot-result dl,
.ot-result dd,
.ot-result ul,
.ot-result ol {
    margin: 0;
    padding: 0;
}

.ot-result ul,
.ot-result ol {
    list-style: none;
}

.ot-result .ot-icon {
    width: 1.15em;
    height: 1.15em;
    flex: none;
}

.ot-result [tabindex="-1"]:focus {
    outline: none;
}

.ot-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.ot-result .ot-eyebrow {
    color: var(--ot-muted);
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.ot-num,
.ot-result .ot-item__price,
.ot-result .ot-summary dd {
    font-variant-numeric: tabular-nums;
}

/* Xuất hiện lần lượt khi kết quả được chèn — một chuyển động duy nhất cho cả khối. */
.ot-result > * {
    animation: ot-rise .36s cubic-bezier(.2, .7, .2, 1) both;
}

.ot-result > *:nth-child(2) { animation-delay: .05s; }
.ot-result > *:nth-child(3) { animation-delay: .1s; }
.ot-result > *:nth-child(4) { animation-delay: .15s; }

@keyframes ot-rise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* ---- Nhãn kiện hàng ---------------------------------------------------------------------- */
.ot-label {
    position: relative;
    background: var(--ot-surface);
    border: 1px solid var(--ot-border);
    border-radius: var(--ot-radius);
}

.ot-label__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.25rem 0;
}

.ot-label__id {
    min-width: 0;
}

.ot-result .ot-label__number {
    margin-top: .2rem;
    font-size: clamp(1.15rem, 4.6vw, 1.5rem);
    font-weight: 700;
    line-height: 1.2;
    overflow-wrap: anywhere;
    font-variant-numeric: tabular-nums;
}

.ot-badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    flex: none;
    padding: .3rem .7rem;
    border-radius: 999px;
    background: var(--ot-success-soft);
    color: var(--ot-success-ink);
    font-size: .8125rem;
    font-weight: 700;
}

.ot-badge::before {
    content: "";
    width: .45rem;
    height: .45rem;
    border-radius: 50%;
    background: currentColor;
}

/* Đường xé: nét đứt + hai vết khuyết bán nguyệt ở mép, như cuống vé / tem gửi hàng. */
.ot-label__tear {
    position: relative;
    height: 0;
    margin: 0 1.25rem;
    border-top: 2px dashed var(--ot-border);
}

.ot-label__tear::before,
.ot-label__tear::after {
    content: "";
    position: absolute;
    top: -12px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--ot-page);
    border: 1px solid var(--ot-border);
}

.ot-label__tear::before {
    left: calc(-1.25rem - 12px);
    clip-path: inset(0 0 0 50%);
}

.ot-label__tear::after {
    right: calc(-1.25rem - 12px);
    clip-path: inset(0 50% 0 0);
}

/* Đơn có sản phẩm lệch tiến độ thì không có tuyến chung: chừa khoảng trước đường xé. */
.ot-label__head + .ot-label__tear {
    margin-top: 1.25rem;
}

.ot-label__tracking {
    display: grid;
    gap: 1rem;
    padding: 1.1rem 1.25rem 1.25rem;
}

/* ---- Tuyến tiến độ ----------------------------------------------------------------------- */
.ot-result .ot-route {
    display: grid;
    grid-auto-columns: 1fr;
    grid-auto-flow: column;
    padding: 1.5rem .25rem 1.4rem;
}

.ot-route__stop {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
    text-align: center;
    min-width: 0;
}

/* Đoạn nối từ trạm trước tới trạm này: tô màu khi trạm này đã tới. */
.ot-route__stop + .ot-route__stop::before {
    content: "";
    position: absolute;
    top: 13px;
    right: 50%;
    width: 100%;
    height: 3px;
    border-radius: 3px;
    background: var(--ot-border);
    z-index: 0;
}

.ot-route__stop.is-done::before,
.ot-route__stop.is-current::before {
    background: var(--ot-success);
}

.ot-route__dot {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--ot-surface);
    border: 2px solid var(--ot-pending);
    color: #fff;
}

.ot-route__dot .ot-icon {
    width: 16px;
    height: 16px;
    stroke-width: 2.4;
}

.is-done .ot-route__dot,
.is-current .ot-route__dot {
    background: var(--ot-success);
    border-color: var(--ot-success);
}

/* Trạm hiện tại: vòng sáng lan nhẹ — chỉ một phần tử chuyển động trên cả trang. */
.is-current .ot-route__dot::after {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid var(--ot-success);
    opacity: 0;
    animation: ot-ping 2.4s ease-out infinite;
}

@keyframes ot-ping {
    0% { opacity: .55; transform: scale(.8); }
    70%, 100% { opacity: 0; transform: scale(1.25); }
}

.ot-route__title {
    font-size: .8125rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--ot-muted);
    overflow-wrap: break-word;
    -webkit-hyphens: auto;
    hyphens: auto;
}

.is-done .ot-route__title,
.is-current .ot-route__title {
    color: var(--ot-text);
}

.is-current .ot-route__title {
    color: var(--ot-success);
}

.ot-route__date {
    font-size: .75rem;
    color: var(--ot-muted);
    font-variant-numeric: tabular-nums;
}

.ot-result .ot-route--compact {
    max-width: 220px;
    padding: .75rem 0 .35rem;
}

.ot-route--compact .ot-route__dot {
    width: 18px;
    height: 18px;
}

.ot-route--compact .ot-route__dot .ot-icon {
    width: 11px;
    height: 11px;
}

.ot-route--compact .ot-route__stop + .ot-route__stop::before {
    top: 8px;
    height: 2px;
}

.ot-route__caption {
    color: var(--ot-success);
    font-size: .8125rem;
    font-weight: 600;
}

.ot-route--compact .is-current .ot-route__dot::after {
    display: none;
}

/* ---- Mã vận đơn -------------------------------------------------------------------------- */
.ot-track {
    display: grid;
    gap: .35rem;
}

.ot-track__label {
    color: var(--ot-muted);
    font-size: .8125rem;
}

.ot-result .ot-track__number {
    color: var(--ot-text);
    background: none;
    padding: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: .04em;
    overflow-wrap: anywhere;
}

.ot-track__actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .4rem;
}

.ot-result .ot-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    min-height: 44px;
    padding: .55rem 1rem;
    border-radius: calc(var(--ot-radius) - 4px);
    font: inherit;
    font-size: .9375rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
    transition: background-color .18s ease, border-color .18s ease, transform .12s ease;
}

.ot-result .ot-btn:active {
    transform: scale(.97);
}

.ot-result .ot-btn:focus-visible {
    outline: 3px solid var(--ot-primary);
    outline-offset: 2px;
}

.ot-result .ot-btn--solid {
    flex: 1 1 auto;
    background: var(--ot-primary);
    border: 1px solid var(--ot-primary);
    color: #fff;
}

.ot-result .ot-btn--solid:hover {
    filter: brightness(.92);
    color: #fff;
}

.ot-result .ot-btn--quiet {
    background: #fff;
    border: 1px solid var(--ot-border);
    color: var(--ot-text);
}

.ot-result .ot-btn--quiet:hover {
    border-color: var(--ot-muted);
}

.ot-copy-done,
.is-copied .ot-copy-idle {
    display: none;
}

.is-copied .ot-copy-done {
    display: inline;
    color: var(--ot-success);
}

.ot-track__empty {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    color: var(--ot-muted);
    font-size: .9375rem;
}

.ot-track__empty .ot-icon {
    margin-top: .1rem;
    width: 1.35em;
    height: 1.35em;
}

/* ---- Khối nội dung ----------------------------------------------------------------------- */
.ot-block {
    margin-top: 2rem;
}

.ot-result .ot-block__title {
    display: flex;
    align-items: baseline;
    gap: .5rem;
    padding-bottom: .85rem;
    border-bottom: 1px solid var(--ot-border);
    font-size: 1.0625rem;
    font-weight: 700;
}

.ot-block__count {
    color: var(--ot-muted);
    font-weight: 600;
    font-size: .875rem;
}

/* ---- Sản phẩm ---------------------------------------------------------------------------- */
.ot-item {
    display: grid;
    grid-template-columns: 72px 1fr auto;
    gap: .9rem;
    align-items: start;
    padding: 1rem 0;
    border-bottom: 1px solid var(--ot-border);
}

.ot-item__thumb {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    border-radius: calc(var(--ot-radius) - 4px);
    border: 1px solid var(--ot-border);
    background: var(--ot-surface);
    color: var(--ot-muted);
    overflow: hidden;
}

.ot-result .ot-item__thumb img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
}

.ot-item__thumb .ot-icon {
    width: 28px;
    height: 28px;
}

.ot-item__body {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    min-width: 0;
}

.ot-result .ot-item__name {
    color: var(--ot-text);
    font-weight: 600;
    line-height: 1.35;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.ot-result a.ot-item__name:hover {
    color: var(--ot-primary);
    text-decoration: underline;
}

.ot-item__meta,
.ot-item__qty {
    color: var(--ot-muted);
    font-size: .875rem;
}

.ot-item__meta > span {
    font-weight: 600;
    text-transform: uppercase;
    font-size: .75rem;
    letter-spacing: .04em;
}

.ot-item__parcel {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    color: var(--ot-muted);
    font-size: .8125rem;
}

.ot-result .ot-item__parcel code {
    color: var(--ot-text);
    background: none;
    padding: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: .8125rem;
}

.ot-item__price {
    font-weight: 600;
    white-space: nowrap;
}

/* ---- Tổng tiền --------------------------------------------------------------------------- */
.ot-result .ot-summary {
    /* .ot-result để thắng reset ".ot-result dl { padding: 0 }" ở trên (cùng class, thêm thẻ). */
    display: grid;
    gap: .6rem;
    padding-top: 1rem;
}

.ot-summary__row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.ot-summary__row dt {
    font-weight: 400;
    color: var(--ot-muted);
}

.ot-summary__row--saving dd {
    color: var(--ot-success);
}

.ot-summary__row--total {
    margin-top: .5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--ot-border);
    font-size: 1.125rem;
    font-weight: 700;
}

.ot-summary__row--total dt {
    color: var(--ot-text);
    font-weight: 700;
}

.ot-result .ot-summary__method {
    margin-top: .75rem;
    color: var(--ot-muted);
    font-size: .875rem;
    text-align: right;
}

/* ---- Khách hàng -------------------------------------------------------------------------- */
.ot-result .ot-customer__grid {
    display: grid;
    gap: 1.25rem;
    padding-top: 1rem;
    overflow-wrap: anywhere;
}

.ot-customer__grid .ot-eyebrow {
    margin-bottom: .3rem;
}

.ot-result .ot-privacy {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin-top: 1.25rem;
    color: var(--ot-muted);
    font-size: .8125rem;
}

@media (min-width: 576px) {
    .ot-customer__grid {
        grid-template-columns: 1fr 1fr;
    }

    .ot-result .ot-btn--solid {
        flex: 0 1 auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ot-result > *,
    .is-current .ot-route__dot::after {
        animation: none;
    }

    .ot-result .ot-btn {
        transition: none;
    }
}
