/**
 * =====================================================================
 * CARDEIX — الفريق والحضور وسجلّ النشاط
 * =====================================================================
 * مكوّنات الصفحات الثلاث الجديدة. كل الألوان والمقاييس من tokens.css،
 * فالثيم الفاتح والداكن يتبعان تلقائياً بلا قاعدة واحدة مكرّرة.
 */

/* ── شريط الأدوات ─────────────────────────────────────────────── */
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.toolbar-actions .form-input { width: auto; min-width: 148px; }

.section-header h3 {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  color: var(--text-strong);
}

/* ملاحظة تفسيرية داخل النماذج — تشرح أثر الحقل لا تكرّر اسمه */
.form-hint {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  margin: var(--sp-4) 0;
  padding: var(--sp-3) var(--sp-4);
  background: var(--accent-soft);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  line-height: var(--lh-relaxed);
  color: var(--text-secondary);
}
.form-hint i , .form-hint svg{ width: var(--icon-md); height: var(--icon-md); color: var(--accent); flex-shrink: 0; margin-top: 2px; }
.form-hint a { color: var(--accent); font-weight: var(--fw-semibold); }

/* =====================================================================
   الفريق
   ===================================================================== */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--sp-4);
}

.person-card {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  transition: transform var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base);
}
.person-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
/* الموقوف يبقى ظاهراً — إخفاؤه يجعل إعادة تفعيله مستحيلة — لكن باهتاً */
.person-card.is-off { opacity: .62; }

.person-head { display: flex; align-items: center; gap: var(--sp-3); }

.person-avatar {
  width: 46px; height: 46px; flex-shrink: 0;
  border-radius: var(--radius-full);
  display: grid; place-items: center;
  font-weight: var(--fw-bold);
  font-size: var(--fs-base);
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--border-strong);
}

.person-id { flex: 1; min-width: 0; }
.person-id h4 {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  color: var(--text-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.person-id p { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 2px; }

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

.person-actions {
  display: flex;
  gap: var(--sp-2);
  margin-top: auto;
}
.person-actions .btn:first-child { flex: 1; }

/* ── محرّر الدوام الأسبوعي ────────────────────────────────────── */
.shift-table {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.shift-row {
  display: grid;
  grid-template-columns: 1fr 110px auto 110px;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hairline);
  background: var(--surface-inset);
  transition: opacity var(--transition-fast);
}
.shift-row.is-off { opacity: .5; }
.shift-row .form-input { padding: var(--sp-2) var(--sp-3); }
.shift-day { margin: 0; font-weight: var(--fw-semibold); }
.shift-sep { font-size: var(--fs-sm); color: var(--text-muted); }

/* =====================================================================
   الحضور والانصراف
   ===================================================================== */
.att-kpis { margin-bottom: var(--sp-5); }
.att-date { font-size: var(--fs-sm); color: var(--text-muted); }

.att-list { display: flex; flex-direction: column; }

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

.att-who { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }

.att-avatar {
  position: relative;
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: var(--radius-full);
  display: grid; place-items: center;
  font-size: var(--fs-sm); font-weight: var(--fw-bold);
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--border-strong);
}

/* نبضة خضراء على صورة من هو على رأس العمل الآن */
.att-live {
  position: absolute; inset-inline-end: -2px; bottom: -2px;
  width: 9px; height: 9px;
  border-radius: var(--radius-full);
  background: var(--success);
  border: 2px solid var(--surface-2);
  animation: attPulse 2s ease-in-out infinite;
}
@keyframes attPulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 55%, transparent) }
  70%      { box-shadow: 0 0 0 7px transparent }
}

.att-name { font-size: var(--fs-base); font-weight: var(--fw-semibold); color: var(--text-strong); }
.att-title { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }

.att-cell { display: flex; flex-direction: column; gap: 3px; }
.att-cell span { font-size: var(--fs-xs); color: var(--text-muted); }
.att-cell strong {
  font-size: var(--fs-base);
  color: var(--text-primary);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}

.att-state { justify-self: start; }
.att-tools { justify-self: end; }

/* شريط نسبة الالتزام في تقرير الفترة */
.rate-cell { display: flex; align-items: center; gap: var(--sp-2); }
.rate-bar {
  flex: 1; min-width: 56px; height: 6px;
  background: var(--surface-3);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.rate-bar i , .rate-bar svg{
  display: block; height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

/* ── ما سجّلته البصمة فعلاً: يُعرض ولا يُعدَّل ─────────────────── */
.proof-box {
  margin: var(--sp-4) 0;
  padding: var(--sp-4);
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--surface-inset);
}
.proof-title {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-sm); font-weight: var(--fw-bold);
  color: var(--text-secondary);
  margin-bottom: var(--sp-3);
}
.proof-title i , .proof-title svg{ width: var(--icon-md); height: var(--icon-md); color: var(--accent); }
.proof-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-1) 0;
  font-size: var(--fs-sm);
}
.proof-row span { color: var(--text-muted); }
.proof-row code {
  color: var(--text-primary);
  font-size: var(--fs-sm);
  background: var(--surface-3);
  padding: 2px var(--sp-2);
  border-radius: var(--radius-xs);
}

/* =====================================================================
   سجلّ النشاط
   ===================================================================== */
.audit-feed { display: flex; flex-direction: column; gap: var(--sp-6); }

.audit-day-title {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--text-secondary);
  padding-bottom: var(--sp-2);
  margin-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border-hairline);
}
.audit-day-title span {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  background: var(--surface-3);
  padding: 1px var(--sp-2);
  border-radius: var(--radius-full);
}

.audit-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-2);
  border-radius: var(--radius-sm);
}
.audit-item:hover { background: var(--surface-inset); }

.audit-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  display: grid; place-items: center;
}
.audit-icon i , .audit-icon svg{ width: var(--icon-sm); height: var(--icon-sm); }

.audit-text { min-width: 0; }
.audit-line {
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
  font-size: var(--fs-base);
}
.audit-line strong { color: var(--text-strong); font-weight: var(--fw-semibold); }
.audit-line span { color: var(--text-secondary); }
/* ما وقع عليه الفعل بيانٌ لا رابط: البنفسجيُّ للتفاعل وحدَه، والسطرُ
   يبقى ثلاثَ درجاتٍ — الفاعلُ أقوى، والفعلُ أخفت، والمفعولُ بينهما.
   وهي درجةُ نظيره في الخطّ الزمنيّ للتذكرة. */
.audit-line em { color: var(--text-primary); font-style: normal; font-weight: var(--fw-medium); }

.audit-summary {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: 3px;
  word-break: break-word;
}
.audit-meta { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 3px; }

.audit-time {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* =====================================================================
   الشاشات الضيّقة
   ===================================================================== */
/* العتبةُ من حساب أعمدةِ هذا الصفّ: مئةٌ وثمانون للاسم، وأربعةٌ
   وثمانون لكلٍّ من الأعمدة الثلاثة، وعمودا الحالةِ والأدوات نحوُ مئةٍ
   وخمسين، وخمسُ فجواتٍ بستّةَ عشرَ — فالحدُّ الأدنى نحوُ 660 بكسلاً.
   و`.main` أضيقُ من النافذة بـ 334 (الشريطُ الجانبيُّ وحشوتُها)، فنافذةُ
   1024 تترك له 690: آخرُ عرضٍ تتّسع فيه الأعمدةُ الستّة قبل أن تنضغط. */
@media (max-width: 1024px) {
  .att-row {
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-3);
    padding: var(--sp-3);
  }
  .att-who { grid-column: 1 / -1; }
  .att-state, .att-tools { justify-self: start; }
}

@media (max-width: 640px) {
  .toolbar { flex-direction: column; align-items: stretch; gap: var(--sp-3); }
  .toolbar-actions { justify-content: stretch; }
  .toolbar-actions .btn, .toolbar-actions .form-input { flex: 1; }

  .team-grid { grid-template-columns: 1fr; }

  .shift-row { grid-template-columns: 1fr 1fr; }
  .shift-day { grid-column: 1 / -1; }
  .shift-sep { display: none; }

  .audit-item { grid-template-columns: auto 1fr; }
  .audit-time { grid-column: 2; justify-self: start; margin-top: 2px; }
}
