/**
 * =====================================================================
 * CARDEIX — تذاكر الدعم الفني
 * =====================================================================
 */

.support-kpis { margin-bottom: var(--sp-5); }

/* ── قائمة التذاكر ────────────────────────────────────────────── */
.ticket-list { display: flex; flex-direction: column; }

/* الحشوةُ حشوةُ خليّة الجدول نفسِها: هذه قائمةٌ تُمسَح بحثاً عن تذكرة،
   وصفُّها كان ستةً وستّين بكسلاً مقابل أربعين في جدول الطلبات — أي
   أربعةَ عشرَ سطراً في الشاشة مقابل أربعةٍ وعشرين. */
.ticket-row {
  display: grid;
  grid-template-columns: 4px 1fr minmax(120px, auto) minmax(96px, auto) auto;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-2);
  border-bottom: 1px solid var(--border-hairline);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.ticket-row:last-child { border-bottom: none; }
.ticket-row:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
/* التذكرة التي تجاوزت مهلتها هي وحدها ما يحتاج تدخّلاً الآن */
.ticket-row.is-overdue { background: color-mix(in srgb, var(--danger) 5%, transparent); }

/* شريط الأولوية: لون فقط، والعنوان يحمل الاسم لمن لا يميّز الألوان */
.ticket-prio {
  width: 4px;
  align-self: stretch;
  min-height: 34px;
  border-radius: var(--radius-full);
}

.ticket-main { min-width: 0; }

.ticket-head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  min-width: 0;
}
.ticket-number {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.ticket-subject {
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  color: var(--text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-sub {
  display: flex;
  gap: var(--sp-1);
  flex-wrap: wrap;
  margin-top: 3px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.ticket-who {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  min-width: 0;
}
.ticket-avatar {
  width: 26px; height: 26px; flex-shrink: 0;
  border-radius: var(--radius-full);
  display: grid; place-items: center;
  font-size: var(--fs-xs); font-weight: var(--fw-bold);
  background: var(--accent-soft); color: var(--accent);
}
.ticket-unassigned { color: var(--text-muted); font-style: italic; }

.ticket-state { display: flex; flex-direction: column; gap: var(--sp-1); align-items: flex-start; }
/* «تأخّرت» تُقرأ لا تُرى فقط: النصُّ يأخذ درجةَ نصّ الخطر لا درجةَ
   سطحه — السادسةُ على أبيض تقيس 3.19:1 عند أحدَ عشرَ بكسلاً. */
.ticket-late {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: var(--fs-xs); color: var(--danger-text); font-weight: var(--fw-semibold);
}
.ticket-late i , .ticket-late svg{ width: 12px; height: 12px; }

.ticket-age {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ── لوح التذكرة ──────────────────────────────────────────────── */
.tk-head { margin-bottom: var(--sp-4); }
.tk-head h4 {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: var(--text-strong);
  line-height: var(--lh-tight);
  margin-bottom: var(--sp-3);
}
.tk-badges { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ما قاله العميل حرفياً — يُقتبس لا يُعاد صياغته */
.tk-quote {
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
  border-radius: var(--radius-sm);
  background: var(--surface-inset);
  border-inline-start: 3px solid var(--accent);
  font-size: var(--fs-base);
  line-height: var(--lh-relaxed);
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.tk-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  padding: var(--sp-4);
  margin-bottom: var(--sp-5);
  border-radius: var(--radius-sm);
  background: var(--surface-inset);
}
.tk-meta dt { font-size: var(--fs-xs); color: var(--text-muted); margin-bottom: 3px; }
.tk-meta dd { font-size: var(--fs-sm); color: var(--text-primary); font-weight: var(--fw-medium); }

.tk-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.tk-controls .form-group { margin-bottom: 0; }

/* ── الخط الزمني ──────────────────────────────────────────────── */
.tk-timeline {
  margin: var(--sp-6) 0 var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border-hairline);
}
.tk-timeline h5 {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--text-secondary);
  margin-bottom: var(--sp-4);
}

.tk-event {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-3);
  padding-bottom: var(--sp-4);
  position: relative;
}
/* خيط رأسي يربط الأحداث — يجعل التسلسل مقروءاً بلا ترقيم */
.tk-event:not(:last-child)::before {
  content: '';
  position: absolute;
  inset-inline-start: 4px;
  top: 14px;
  bottom: 0;
  width: 1px;
  background: var(--border-default);
}
.tk-dot {
  width: 9px; height: 9px;
  margin-top: var(--sp-1);
  border-radius: var(--radius-full);
  background: var(--accent);
  position: relative;
  z-index: 1;
}
.tk-event-line { font-size: var(--fs-sm); color: var(--text-secondary); line-height: var(--lh-base); }
.tk-event-line strong { color: var(--text-strong); font-weight: var(--fw-semibold); }
.tk-event-line em { color: var(--text-primary); font-style: normal; }
.tk-event time { font-size: var(--fs-xs); color: var(--text-muted); }

.tk-empty { font-size: var(--fs-sm); color: var(--text-muted); }

.tk-note { display: flex; gap: var(--sp-2); }
.tk-note .form-input { flex: 1; }
.tk-note .btn { flex-shrink: 0; }

/* ── الشاشات الضيّقة ────────────────────────────────────────────
   العتبةُ من حساب هذا الصفّ وحدَه لا من عتبةِ ملفٍّ آخر: أعمدتُه
   الثابتة — شريطُ الأولوية أربعةٌ، وصاحبُها مئةٌ وعشرون، وحالتُها
   ستّةٌ وتسعون، وعمرُها نحوُ تسعين — مع فجواتِها الأربع بستّةَ عشرَ
   تأخذ نحوَ 374 بكسلاً من `.main`. فإذا نزل `.main` تحت 525 هبط
   عمودُ الموضوع دون 150، وعندها لا يُقرأ من العنوان شيء. و`.main`
   أضيقُ من النافذة بـ 334: الشريطُ الجانبيُّ وحشوتُها. فالعتبةُ 860.
   وطيُّ الصفّ قبلها يزيد ارتفاعَه سطراً — أي يعكس ما قُصِد أصلاً. */
@media (max-width: 860px) {
  .ticket-row {
    grid-template-columns: 4px 1fr auto;
    gap: var(--sp-3);
  }
  .ticket-who { grid-column: 2 / -1; }
  .tk-controls { grid-template-columns: 1fr; }
  .tk-meta { grid-template-columns: 1fr; }
}
