/* استایل بخش کاربری افزونه تیکت — رنگ‌ها از متغیرهای قالب می‌آیند و اگر
   افزونه با قالب دیگری استفاده شود، مقادیر پیش‌فرض جایگزین می‌شوند. */
.tb-ticket-wrap,
.tb-track {
  --tb-bg: var(--bg, #0e131a);
  --tb-surface: var(--surface, #171f29);
  --tb-surface-2: var(--surface-2, #1f2937);
  --tb-border: var(--border, #2a3441);
  --tb-mint: var(--mint, #35e0a1);
  --tb-mint-dim: var(--mint-dim, #1f8f66);
  --tb-amber: var(--amber, #ffab5e);
  --tb-text: var(--text, #eef2f5);
  --tb-muted: var(--muted, #8fa0b2);
  font-family: inherit;
  color: var(--tb-text);
}

.tb-ticket-wrap * ,
.tb-track * { box-sizing: border-box; }

/* ===== فرم پرونده ===== */
.tb-ticket-wrap { position: relative; }

.tb-ticket {
  background: var(--tb-surface);
  border: 1px solid var(--tb-border);
  border-radius: 16px;
  padding: 26px 26px 24px;
  position: relative;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .5);
}

.tb-ticket::before,
.tb-ticket::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  background: var(--tb-bg);
  border: 1px solid var(--tb-border);
  border-radius: 50%;
  top: 50%;
  transform: translateY(-50%);
}
.tb-ticket::before { left: -11px; }
.tb-ticket::after { right: -11px; }

.tb-ticket-perf { border-top: 1.5px dashed var(--tb-border); margin: 20px 0; }

.tb-ticket-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tb-ticket-title { font-size: 13px; color: var(--tb-muted); font-weight: 600; }
.tb-ticket-sub { font-size: 22px; font-weight: 800; margin-top: 6px; }
.tb-ticket-id { font-size: 13px; color: var(--tb-mint); font-weight: 700; font-variant-numeric: tabular-nums; }

.tb-stamp {
  position: absolute; top: -14px; inset-inline-start: -14px;
  width: 74px; height: 74px; border-radius: 50%;
  border: 2px dashed var(--tb-amber);
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: 10.5px; font-weight: 800; color: var(--tb-amber);
  transform: rotate(-14deg); background: rgba(255, 171, 94, .06);
  line-height: 1.3; transition: transform .3s ease; z-index: 2;
}
.tb-ticket-wrap:hover .tb-stamp { transform: rotate(-6deg) scale(1.04); }

.tb-field { margin-bottom: 16px; }
.tb-field label,
.tb-track label {
  display: block; font-size: 13px; color: var(--tb-muted);
  margin-bottom: 8px; font-weight: 600;
}

.tb-field select,
.tb-field input[type="text"],
.tb-field input[type="tel"],
.tb-track input[type="text"],
.tb-track textarea {
  width: 100%;
  background: var(--tb-surface-2);
  border: 1px solid var(--tb-border);
  color: var(--tb-text);
  padding: 12px 14px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color .15s ease;
}
.tb-field select:focus,
.tb-field input:focus,
.tb-track input:focus,
.tb-track textarea:focus { border-color: var(--tb-mint); }

.tb-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tb-chip {
  font-size: 13.5px; padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--tb-border); background: var(--tb-surface-2);
  color: var(--tb-muted); cursor: pointer; font-family: inherit;
  transition: all .15s ease; user-select: none;
}
.tb-chip.is-active {
  background: rgba(53, 224, 161, .12);
  border-color: var(--tb-mint);
  color: var(--tb-mint);
}
.tb-chip:focus-visible,
.tb-btn:focus-visible { outline: 2px solid var(--tb-mint); outline-offset: 2px; }

.tb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 12px; border: none;
  font-weight: 700; font-size: 15px; cursor: pointer; font-family: inherit;
  transition: transform .15s ease, box-shadow .15s ease;
}
.tb-btn[disabled] { opacity: .7; cursor: default; }
.tb-btn-primary { background: var(--tb-mint); color: #08201a; }
.tb-btn-primary:hover:not([disabled]) { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(53, 224, 161, .25); }
.tb-btn-block { width: 100%; margin-top: 12px; }
.tb-btn-agree { background: rgba(53, 224, 161, .14); color: var(--tb-mint); border: 1px solid var(--tb-mint); width: 100%; }
.tb-btn-disagree { background: rgba(255, 171, 94, .1); color: var(--tb-amber); border: 1px solid var(--tb-amber); width: 100%; }

.tb-ticket-actions { display: flex; gap: 10px; margin-top: 22px; }
.tb-ticket-actions .tb-btn { flex: 1; }
.tb-ticket-hint { font-size: 12.5px; color: var(--tb-muted); margin-top: 10px; text-align: center; }
.tb-ticket-hint a { color: var(--tb-mint); }

.tb-result {
  display: none; margin-top: 18px; padding: 16px; border-radius: 12px;
  background: rgba(53, 224, 161, .08); border: 1px solid var(--tb-mint-dim);
  font-size: 14px; line-height: 1.9;
}
.tb-result.is-visible { display: block; }
.tb-result.is-error { background: rgba(255, 171, 94, .08); border-color: var(--tb-amber); }
.tb-result b { color: var(--tb-mint); }

/* ===== صفحه پیگیری ===== */
.tb-track { max-width: 480px; margin: 0 auto; }
.tb-box {
  background: var(--tb-surface); border: 1px solid var(--tb-border);
  border-radius: 16px; padding: 24px; margin-bottom: 16px;
}
.tb-track-title { font-size: 19px; margin: 0 0 6px; }
.tb-lead { color: var(--tb-muted); font-size: 13.5px; margin: 0 0 20px; }
.tb-lead-flat { margin: 0; }
.tb-code-input { letter-spacing: 2px; text-transform: uppercase; text-align: center; font-size: 16px; }

.tb-msg { margin-top: 16px; padding: 14px; border-radius: 10px; font-size: 13.5px; line-height: 1.8; }
.tb-msg-error { background: rgba(255, 120, 120, .08); border: 1px solid #b04545; color: #ffb3b3; }
.tb-msg-ok { background: rgba(53, 224, 161, .1); border: 1px solid var(--tb-mint-dim); color: var(--tb-mint); }

.tb-row { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; margin-bottom: 10px; }
.tb-row b { color: var(--tb-muted); font-weight: 600; flex-shrink: 0; }

.tb-status { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700; }
.tb-status.is-new { background: rgba(255, 171, 94, .12); color: var(--tb-amber); }
.tb-status.is-answered { background: rgba(53, 224, 161, .12); color: var(--tb-mint); }

.tb-thread { margin-top: 6px; }
.tb-bubble {
  max-width: 85%; padding: 10px 14px; border-radius: 12px;
  font-size: 13.5px; line-height: 1.8; margin-bottom: 10px; white-space: pre-wrap;
}
.tb-bubble.is-admin {
  background: var(--tb-surface-2); border: 1px solid var(--tb-border);
  margin-inline-start: auto; border-end-start-radius: 2px;
}
.tb-bubble.is-customer {
  background: rgba(53, 224, 161, .1); border: 1px solid var(--tb-mint-dim);
  margin-inline-end: auto; border-end-end-radius: 2px;
}
.tb-bubble .tb-who { font-size: 11px; color: var(--tb-muted); margin-bottom: 4px; font-weight: 600; }

.tb-quick-actions { display: flex; gap: 8px; margin-top: 16px; }
.tb-quick-actions form { flex: 1; margin: 0; }
.tb-send-form { margin-top: 14px; }
.tb-send-form textarea { resize: vertical; min-height: 64px; font-size: 14px; }

/* ===================================================================
   انیمیشن‌های فرم
   قاعده‌ها مثل قالب: فقط transform/opacity، افکت hover فقط روی دستگاه
   دارای موس، و خاموش شدن کامل با «کاهش حرکت» سیستم‌عامل.
   =================================================================== */

.tb-ticket-form,
.tb-chip,
.tb-btn,
.tb-result { --tb-ease: cubic-bezier(0.22, 1, 0.36, 1); }

/* --- چیپ‌های علائم --- */
.tb-chip {
  transition:
    transform 160ms cubic-bezier(0.34, 1.56, 0.64, 1),
    background-color 200ms ease,
    border-color 200ms ease,
    color 200ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .tb-chip:hover:not(.is-active) { transform: translateY(-2px); border-color: var(--tb-mint); }
}
.tb-chip:active { transform: scale(0.94); }

/* انتخاب شدن چیپ، یک «پاپ» کوتاه دارد تا انتخاب حس شود */
.tb-chip.is-active { animation: tb-chip-pop 260ms cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes tb-chip-pop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* --- دکمه ثبت: حالت در حال ارسال --- */
.tb-btn { position: relative; transition: transform 160ms var(--tb-ease), box-shadow 240ms ease, background-color 240ms ease; }
.tb-btn:active:not([disabled]) { transform: scale(0.97); }

.tb-btn.is-loading { color: transparent; pointer-events: none; }
.tb-btn.is-loading::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 18px; height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(8, 32, 26, 0.35);
  border-top-color: #08201a;
  border-radius: 50%;
  animation: tb-spin 700ms linear infinite;
}
@keyframes tb-spin { to { transform: rotate(360deg); } }

/* تیک موفقیت بعد از ثبت */
.tb-btn.is-done { color: transparent; }
.tb-btn.is-done::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 16px; height: 9px;
  margin: -7px 0 0 -8px;
  border-inline-start: 2.5px solid #08201a;
  border-bottom: 2.5px solid #08201a;
  transform: rotate(-45deg) scale(0);
  animation: tb-check 420ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes tb-check {
  to { transform: rotate(-45deg) scale(1); }
}

/* --- کادر نتیجه --- */
.tb-result {
  transition: opacity 320ms var(--tb-ease), transform 320ms var(--tb-ease);
}
.tb-result.tb-pop { animation: tb-result-in 420ms var(--tb-ease); }
@keyframes tb-result-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

/* خطا: فرم تکان کوتاهی می‌خورد. عمداً کوتاه و کم‌دامنه است تا آزاردهنده نباشد. */
.tb-shake { animation: tb-shake 380ms ease; }
@keyframes tb-shake {
  0%, 100%   { transform: translateX(0); }
  20%, 60%   { transform: translateX(-6px); }
  40%, 80%   { transform: translateX(6px); }
}

/* --- کد پرونده: مهم‌ترین چیزی که مشتری باید ببرد --- */
.tb-code-in { animation: tb-code-in 700ms cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes tb-code-in {
  0%   { opacity: 0; transform: scale(0.7); }
  55%  { opacity: 1; transform: scale(1.18); }
  100% { opacity: 1; transform: scale(1); }
}

/* --- صفحه پیگیری: وضعیت «در حال بررسی» نبض می‌زند --- */
.tb-status.is-new::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  margin-inline-end: 7px;
  border-radius: 50%;
  background: var(--tb-mint);
  animation: tb-pulse 1.8s ease-in-out infinite;
}
@keyframes tb-pulse {
  0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 rgba(53, 224, 161, 0.45); }
  50%      { opacity: .75; transform: scale(1.15); box-shadow: 0 0 0 6px rgba(53, 224, 161, 0); }
}

/* حباب‌های گفتگو، یکی‌یکی و از سمت خودشان وارد می‌شوند */
.tb-bubble { animation: tb-bubble-in 460ms var(--tb-ease) backwards; }
.tb-bubble:nth-child(1) { animation-delay: 40ms; }
.tb-bubble:nth-child(2) { animation-delay: 120ms; }
.tb-bubble:nth-child(3) { animation-delay: 200ms; }
.tb-bubble:nth-child(n+4) { animation-delay: 260ms; }

.tb-bubble.is-admin    { animation-name: tb-bubble-in-admin; }
.tb-bubble.is-customer { animation-name: tb-bubble-in-customer; }

@keyframes tb-bubble-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
@keyframes tb-bubble-in-admin {
  from { opacity: 0; transform: translateY(10px) translateX(14px); }
  to   { opacity: 1; transform: none; }
}
@keyframes tb-bubble-in-customer {
  from { opacity: 0; transform: translateY(10px) translateX(-14px); }
  to   { opacity: 1; transform: none; }
}

/* پیام موفقیت/خطای صفحه پیگیری */
.tb-msg { animation: tb-result-in 420ms var(--tb-ease); }

@media (prefers-reduced-motion: reduce) {
  .tb-chip,
  .tb-btn,
  .tb-result,
  .tb-msg,
  .tb-bubble,
  .tb-shake,
  .tb-code-in {
    animation: none !important;
    transition-duration: 0.001ms !important;
    transform: none !important;
    opacity: 1 !important;
  }
  .tb-status.is-new::before { animation: none !important; }
  /* اسپینر باید بچرخد وگرنه معلوم نیست چیزی در حال انجام است */
  .tb-btn.is-loading::after { animation: tb-spin 700ms linear infinite !important; }
}

/* راهنمای زیر فیلد فرم */
.tb-field-hint {
  display: block;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--tb-muted);
}
