
/* Header/order buttons elsewhere on the site: badges stay inside their button */
.my-orders-btn-wrap,
button.btn-icon,
.btn-icon.my-orders-btn-wrap,
.header-tool-btn.my-orders-btn-wrap,
.cart-toggle-btn.my-orders-btn-wrap { position: relative !important; }
.my-orders-count-badge, .cart-badge-count, .cart-count-bubble { pointer-events: none !important; }

.vitrin-tracker-modal {
  --tk-ink: #18181b; --tk-muted: #71717a; --tk-light: #a1a1aa;
  --tk-cream: #f8f6f0; --tk-cream-2: #f3efe6; --tk-line: #ece6db; --tk-line-2: #e4e4e7;
  --tk-gold: #c5a880; --tk-gold-deep: #8d623e;
  --tk-sage: #5f7a60; --tk-sage-bg: #eef2ea;
  --tk-clay: #9a5a51; --tk-clay-bg: #f6ebe8;
  position: fixed; inset: 0; z-index: 99999;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  font-family: 'Vazir', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  direction: rtl; color: var(--tk-ink);
}
.vitrin-tracker-modal[hidden], .vitrin-tracker-modal [hidden] { display: none !important; }
.vitrin-tracker-modal *, .vitrin-tracker-modal *::before, .vitrin-tracker-modal *::after { box-sizing: border-box; }

.tracker-backdrop { position: absolute; inset: 0; background: rgba(24, 24, 27, 0.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: tkFade 0.2s ease-out; }
.tracker-dialog { position: relative; width: 100%; max-width: 660px; max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; background: #fff; border-radius: 24px; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.35); animation: tkUp 0.3s cubic-bezier(0.16, 1, 0.3, 1); }

/* Header */
.tracker-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.15rem 1.4rem; background: var(--tk-cream); border-bottom: 1px solid var(--tk-line); }
.tracker-title-wrap { display: flex; align-items: center; gap: 0.8rem; min-width: 0; }
.tracker-icon-badge { width: 44px; height: 44px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 14px; color: var(--tk-gold-deep); background: #fff; border: 1px solid #e8dcc8; }
.tracker-title { margin: 0; font-size: 1.1rem; font-weight: 900; }
.tracker-subtitle { margin: 0.15rem 0 0; font-size: 0.76rem; color: var(--tk-muted); }
.btn-tracker-close { width: 36px; height: 36px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border: none; border-radius: 50%; background: #fff; color: var(--tk-muted); cursor: pointer; transition: background 0.2s, color 0.2s; }
.btn-tracker-close:hover { background: var(--tk-cream-2); color: var(--tk-ink); }

/* Search */
.tracker-search-box { margin: 0; padding: 1rem 1.4rem 0.85rem; border-bottom: 1px solid #f4f4f5; }
.tracker-input-group { display: flex; align-items: center; gap: 0.55rem; padding: 0.3rem 0.35rem 0.3rem 0.3rem; padding-inline-start: 0.85rem; border: 1.5px solid var(--tk-line-2); border-radius: 14px; background: #fafaf9; color: var(--tk-light); transition: border-color 0.2s, background 0.2s, box-shadow 0.2s; cursor: text; }
.tracker-input-group:focus-within { border-color: var(--tk-gold); background: #fff; box-shadow: 0 0 0 3px rgba(197, 168, 128, 0.18); }
.tracker-input-group input { flex: 1; min-width: 0; padding: 0.45rem 0; border: none; outline: none; background: transparent; font-family: inherit; font-size: 0.88rem; color: var(--tk-ink); }
.btn-tracker-search { padding: 0.55rem 1.15rem; border: none; border-radius: 10px; background: var(--tk-ink); color: #fff; font-family: inherit; font-size: 0.82rem; font-weight: 800; cursor: pointer; transition: background 0.2s; }
.btn-tracker-search:hover { background: #27272a; }
.btn-tracker-search:disabled { opacity: 0.6; cursor: wait; }
.tracker-quick-hint { margin: 0.5rem 0 0; font-size: 0.72rem; line-height: 1.6; color: var(--tk-light); }

/* Body + states */
.tracker-body { flex: 1; overflow-y: auto; padding: 1.15rem 1.4rem 1.4rem; background: #fcfbf9; overscroll-behavior: contain; }
.tracker-state { padding: 2.75rem 1rem; text-align: center; color: var(--tk-muted); font-size: 0.85rem; }
.tracker-spinner { width: 34px; height: 34px; margin: 0 auto 0.9rem; border: 3px solid var(--tk-line); border-top-color: var(--tk-gold); border-radius: 50%; animation: tkSpin 0.8s linear infinite; }
.tracker-empty-icon { width: 64px; height: 64px; margin: 0 auto 0.85rem; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--tk-cream); color: var(--tk-gold-deep); }
.tracker-state h4 { margin: 0 0 0.35rem; font-size: 1rem; font-weight: 900; color: var(--tk-ink); }
.tracker-state p { max-width: 400px; margin: 0 auto; line-height: 1.8; }

/* Order card */
.tk-card { background: #fff; border: 1px solid var(--tk-line); border-radius: 20px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04); overflow: hidden; }
.tk-card + .tk-card { margin-top: 1rem; }
.tk-card-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.6rem; padding: 0.95rem 1.1rem; border-bottom: 1px solid #f4f1ea; }
.tk-code { display: flex; flex-direction: column; gap: 0.1rem; }
.tk-code strong { font-size: 1rem; font-weight: 900; letter-spacing: 0.02em; direction: ltr; text-align: right; }
.tk-code span { font-size: 0.72rem; color: var(--tk-light); }
.tk-status { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.32rem 0.8rem; border-radius: 9999px; font-size: 0.76rem; font-weight: 800; border: 1px solid; }
.tk-status svg { width: 14px; height: 14px; }
.tk-st-pending   { color: #8a6a1f; background: #faf3e2; border-color: #efdfb6; }
.tk-st-paid      { color: var(--tk-sage); background: var(--tk-sage-bg); border-color: #d9e1d3; }
.tk-st-preparing { color: var(--tk-gold-deep); background: #f6efe4; border-color: #e8dcc8; }
.tk-st-shipped   { color: #4a5f7a; background: #ecf0f5; border-color: #d4dce7; }
.tk-st-completed { color: #3f5a41; background: #e6eee2; border-color: #cfdcc9; }
.tk-st-cancelled { color: var(--tk-clay); background: var(--tk-clay-bg); border-color: #ead8d2; }

/* Stepper */
.tk-steps { position: relative; display: grid; grid-template-columns: repeat(4, 1fr); margin: 1.1rem 1.1rem 0.4rem; padding: 0; list-style: none; }
.tk-steps::before, .tk-steps::after { content: ''; position: absolute; top: 15px; height: 3px; border-radius: 3px; inset-inline-start: 12.5%; }
.tk-steps::before { inset-inline-end: 12.5%; background: var(--tk-line); }
/* RTL: progress grows from the first step on the right towards the left */
.tk-steps::after { width: calc(var(--tk-progress, 0) * 75%); background: linear-gradient(270deg, var(--tk-gold), var(--tk-gold-deep)); transition: width 0.6s ease; }
.tk-step { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 0.4rem; text-align: center; }
.tk-step-dot { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: #fff; border: 2px solid var(--tk-line); color: var(--tk-light); font-size: 0.8rem; font-weight: 900; transition: all 0.3s; }
.tk-step-dot svg { width: 14px; height: 14px; }
.tk-step-label { font-size: 0.7rem; font-weight: 700; color: var(--tk-light); line-height: 1.4; }
.tk-step.is-done .tk-step-dot { background: var(--tk-gold-deep); border-color: var(--tk-gold-deep); color: #fff; }
.tk-step.is-done .tk-step-label { color: var(--tk-muted); }
.tk-step.is-current .tk-step-dot { background: var(--tk-ink); border-color: var(--tk-ink); color: #fff; box-shadow: 0 0 0 5px rgba(197, 168, 128, 0.28); }
.tk-step.is-current .tk-step-label { color: var(--tk-ink); font-weight: 900; }

.tk-alert { display: flex; align-items: center; gap: 0.7rem; margin: 1rem 1.1rem 0; padding: 0.8rem 0.95rem; border-radius: 14px; font-size: 0.82rem; line-height: 1.7; }
.tk-alert svg { flex-shrink: 0; width: 20px; height: 20px; }
.tk-alert.is-pending { background: #faf3e2; color: #6f5418; }
.tk-alert.is-cancelled { background: var(--tk-clay-bg); color: #7f4a44; }

/* Items */
.tk-items { list-style: none; margin: 1rem 1.1rem 0; padding: 0; border: 1px solid #f1ede5; border-radius: 16px; overflow: hidden; }
.tk-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 0.8rem; }
.tk-item + .tk-item { border-top: 1px solid #f4f1ea; }
.tk-thumb { width: 48px; height: 48px; flex-shrink: 0; border-radius: 12px; object-fit: cover; background: var(--tk-cream); border: 1px solid #efe9de; }
.tk-thumb.is-empty { display: inline-flex; align-items: center; justify-content: center; color: var(--tk-gold); }
.tk-item-main { flex: 1; min-width: 0; }
.tk-item-name { font-size: 0.84rem; font-weight: 800; line-height: 1.6; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tk-item-meta { font-size: 0.72rem; color: var(--tk-muted); margin-top: 0.1rem; }
.tk-item-price { flex-shrink: 0; font-size: 0.82rem; font-weight: 800; white-space: nowrap; }

/* Summary + details */
.tk-post { margin: 1rem 1.1rem 0; padding: 0.9rem 1rem; border-radius: 14px; background: #fff; border: 1.5px solid #e8dcc8; box-shadow: 0 6px 18px -12px rgba(141, 98, 62, 0.45); }
.tk-post-head { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; font-weight: 800; color: var(--tk-gold-deep); }
.tk-post-head svg { width: 18px; height: 18px; flex-shrink: 0; }
.tk-post-code { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.55rem; }
.tk-post-code code { flex: 1; min-width: 0; padding: 0.55rem 0.7rem; border-radius: 10px; background: var(--tk-cream); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9rem; font-weight: 700; letter-spacing: 0.06em; color: var(--tk-ink); direction: ltr; text-align: left; overflow-wrap: anywhere; }
.tk-post-copy { flex-shrink: 0; padding: 0.55rem 0.8rem; border: 1px solid var(--tk-line); border-radius: 10px; background: #fff; font-family: inherit; font-size: 0.76rem; font-weight: 800; color: var(--tk-ink); cursor: pointer; transition: background 0.2s; }
.tk-post-copy:hover { background: var(--tk-cream-2); }
.tk-pkg { padding: .55rem 0; border-top: 1px dashed rgba(0,0,0,.1); }
.tk-pkg-head { display: flex; justify-content: space-between; gap: .5rem; font-size: .8rem; }
.tk-pkg-head span { font-size: .74rem; opacity: .75; }
.tk-pkg-items { margin: .2rem 0 .35rem; font-size: .74rem; opacity: .7; line-height: 1.7; }
.tk-post-link { display: inline-flex; align-items: center; gap: 0.3rem; margin-top: 0.6rem; font-size: 0.78rem; font-weight: 800; color: var(--tk-gold-deep); text-decoration: none; }
.tk-post-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.tk-total { display: flex; align-items: baseline; justify-content: space-between; margin: 0.9rem 1.1rem 0; padding: 0.85rem 1rem; border-radius: 14px; background: var(--tk-cream); }
.tk-total span { font-size: 0.82rem; font-weight: 700; color: var(--tk-muted); }
.tk-total strong { font-size: 1.15rem; font-weight: 900; }
.tk-total small { font-size: 0.72rem; font-weight: 700; color: var(--tk-muted); }
.tk-details { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem 1rem; margin: 0.9rem 1.1rem 0; padding: 0; }
.tk-details div { min-width: 0; }
.tk-details .is-wide { grid-column: 1 / -1; }
.tk-details dt { font-size: 0.7rem; font-weight: 700; color: var(--tk-light); margin-bottom: 0.1rem; }
.tk-details dd { margin: 0; font-size: 0.84rem; font-weight: 700; line-height: 1.7; overflow-wrap: anywhere; }
.tk-mask-note { display: flex; align-items: center; gap: 0.4rem; margin: 0.6rem 1.1rem 0; font-size: 0.7rem; color: var(--tk-light); }
.tk-mask-note svg { width: 13px; height: 13px; flex-shrink: 0; }

/* Actions */
.tk-actions { display: flex; gap: 0.6rem; padding: 1rem 1.1rem 1.1rem; }
.tk-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; padding: 0.7rem 0.9rem; border-radius: 12px; font-size: 0.8rem; font-weight: 800; text-decoration: none; transition: background 0.2s, border-color 0.2s; }
.tk-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.tk-btn-pay { background: var(--tk-ink); color: #fff; }
.tk-btn-pay:hover { background: #27272a; }
.tk-btn-support { background: #fff; color: var(--tk-ink); border: 1px solid var(--tk-line-2); }
.tk-btn-support:hover { border-color: var(--tk-gold); background: #fffdf9; }

@keyframes tkFade { from { opacity: 0; } }
@keyframes tkUp { from { opacity: 0; transform: translateY(18px) scale(0.98); } }
@keyframes tkSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .tracker-backdrop, .tracker-dialog { animation: none; } .tk-steps::after { transition: none; } }

@media (max-width: 640px) {
  .vitrin-tracker-modal { align-items: flex-end; padding: 0; }
  .tracker-dialog { max-width: none; max-height: 92vh; border-radius: 22px 22px 0 0; }
  .tracker-header { padding: 0.95rem 1rem; }
  .tracker-search-box { padding: 0.85rem 1rem 0.7rem; }
  .tracker-body { padding: 0.9rem 0.85rem calc(1rem + env(safe-area-inset-bottom)); }
  .tk-card-top, .tk-actions { padding-inline: 0.9rem; }
  .tk-steps, .tk-alert, .tk-items, .tk-total, .tk-details, .tk-mask-note { margin-inline: 0.9rem; }
  .tk-step-dot { width: 28px; height: 28px; }
  .tk-steps::before, .tk-steps::after { top: 13px; }
  .tk-step-label { font-size: 0.64rem; }
  .tk-details { grid-template-columns: 1fr; }
  .tk-actions { flex-direction: column; }
}
