/* المكونات: بطاقات، أزرار، حقول، مؤشرات، شارات، جداول، Kanban، Timeline */

/* البطاقات */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.card.pad-sm { padding: var(--space-4); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); margin-bottom: var(--space-4);
}
.card-title { font-weight: 700; font-size: var(--font-size-base); margin: 0; }
.card-subtitle { color: var(--text-muted); font-size: var(--font-size-xs); }

/* بطاقات KPI */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-2);
  position: relative; overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.kpi:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.kpi::after {
  content: ""; position: absolute; inset-block-start: 0; inset-inline-start: 0;
  width: 4px; height: 100%; background: var(--kpi-accent, var(--primary));
}
.kpi .kpi-label { color: var(--text-muted); font-size: var(--font-size-xs); font-weight: 500; }
.kpi .kpi-value {
  font-size: var(--font-size-3xl); font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
}
.kpi .kpi-delta {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--font-size-xs); font-weight: 600;
}
.kpi .kpi-delta.up { color: var(--moe-green-700); }
.kpi .kpi-delta.down { color: var(--status-late); }
.kpi.accent-gold { --kpi-accent: var(--moe-gold-500); }
.kpi.accent-blue { --kpi-accent: var(--status-new); }
.kpi.accent-red  { --kpi-accent: var(--status-late); }

/* الأزرار */
.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 600; font-size: var(--font-size-sm);
  transition: background var(--transition-fast), transform var(--transition-fast);
}
.btn:hover { background: var(--ink-100); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: var(--primary-fg); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-muted); }
.btn.danger { background: var(--status-late); color: #fff; }
.btn.block { display: flex; width: 100%; justify-content: center; }
.btn.sm { padding: 6px 12px; font-size: var(--font-size-xs); }

/* الحقول */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-4); }
.field label { font-size: var(--font-size-sm); font-weight: 600; color: var(--text); }
.field .hint { font-size: var(--font-size-xs); color: var(--text-muted); }
.field .error { font-size: var(--font-size-xs); color: var(--status-late); }
.input, .select, .textarea {
  width: 100%;
  padding: 10px var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 44, 129, 0.12);
}
.textarea { min-height: 96px; resize: vertical; }

.checkbox {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-size: var(--font-size-sm); cursor: pointer;
}

/* الشارات (Status) */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 600;
  background: var(--ink-100); color: var(--ink-700);
}
.badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.badge.status-new      { background: #dbeafe; color: #1e40af; }
.badge.status-progress { background: #fef3c7; color: #92400e; }
.badge.status-review   { background: #ede9fe; color: #5b21b6; }
.badge.status-approved { background: var(--moe-green-100); color: var(--moe-green-800); }
.badge.status-closed   { background: var(--ink-100); color: var(--ink-700); }
.badge.status-late     { background: #fee2e2; color: #991b1b; }

/* أشرطة التقدم */
.progress {
  height: 8px; background: var(--ink-100); border-radius: 999px; overflow: hidden;
}
.progress > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--moe-green-600), var(--moe-green-700));
  border-radius: 999px;
  transition: width 400ms ease;
}

/* رسم دائري بسيط لنسبة الإنجاز */
.ring {
  --value: 0;
  --size: 96px;
  width: var(--size); height: var(--size); border-radius: 50%;
  background:
    conic-gradient(var(--primary) calc(var(--value) * 1%), var(--ink-100) 0);
  display: grid; place-items: center; position: relative;
}
.ring::before {
  content: ""; position: absolute; inset: 8px;
  background: var(--surface); border-radius: 50%;
}
.ring > span {
  position: relative; font-weight: 700; font-size: var(--font-size-lg);
  color: var(--text);
}

/* الجداول */
.table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); overflow: hidden;
}
.table th, .table td {
  padding: 12px var(--space-4); text-align: start;
  border-bottom: 1px solid var(--border); font-size: var(--font-size-sm);
}
.table th {
  background: var(--surface-muted); font-weight: 600; color: var(--text-muted);
  font-size: var(--font-size-xs); text-transform: none;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-muted); }

/* الإشعارات */
.toast-region {
  position: fixed; inset-block-start: 20px; inset-inline-end: 20px;
  display: flex; flex-direction: column; gap: var(--space-2);
  z-index: 1000; pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 260px; max-width: 380px;
  padding: 12px var(--space-4);
  background: var(--surface); border: 1px solid var(--border);
  border-inline-start: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-size-sm);
  animation: toastIn 200ms ease-out;
}
.toast.success { border-inline-start-color: var(--moe-green-700); }
.toast.error   { border-inline-start-color: var(--status-late); }
.toast.warn    { border-inline-start-color: var(--status-progress); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* لوحة كانبن (Workflow) — تُستخدم في المرحلة 3 */
.kanban {
  display: grid;
  grid-template-columns: repeat(5, minmax(240px, 1fr));
  gap: var(--space-3);
  overflow-x: auto;
}
.kanban-col {
  background: var(--surface-muted);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  min-height: 200px;
}
.kanban-col h4 {
  font-size: var(--font-size-sm); font-weight: 700;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-3);
}
.kanban-col h4 .count {
  background: var(--surface); border: 1px solid var(--border);
  padding: 1px 8px; border-radius: 999px; font-size: 11px; color: var(--text-muted);
}
.kanban-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: var(--space-3);
  margin-bottom: var(--space-2); font-size: var(--font-size-sm);
  cursor: grab; box-shadow: var(--shadow-sm);
}
.kanban-card:hover { border-color: var(--primary); }

/* الحوارات */
.dialog-backdrop {
  position: fixed; inset: 0; background: rgba(29, 23, 40, 0.55);
  display: grid; place-items: center; z-index: 900;
  animation: fadeIn 160ms ease-out;
}
.dialog {
  background: var(--surface); border-radius: var(--radius-lg);
  width: min(560px, 92vw); max-height: 88vh; overflow: auto;
  box-shadow: var(--shadow-lg);
  animation: dialogIn 200ms ease-out;
}
.dialog header {
  padding: var(--space-5); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.dialog .body { padding: var(--space-5); }
.dialog footer {
  padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border);
  display: flex; gap: var(--space-2); justify-content: flex-end;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes dialogIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

/* الأيقونات */
.icon { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; }

/* ===== المرحلة 3: بطاقات دورة التحسين، الخطوات، الجدول الزمني، الإشعارات، البحث ===== */
.cycle-card { display: flex; gap: 14px; align-items: flex-start; cursor: pointer; transition: transform .12s, box-shadow .12s; }
.cycle-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.cycle-num {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--moe-green-100); color: var(--moe-green-800); font-weight: 800; flex: 0 0 auto;
}

.stepper { display: flex; gap: 6px; flex-wrap: wrap; }
.stepper .step {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface-muted); color: var(--text-muted); font-size: var(--font-size-xs); font-weight: 600;
}
.stepper .step .dot {
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink-100); color: var(--ink-700); font-size: 11px;
}
.stepper .step.done { background: var(--moe-green-100); color: var(--moe-green-800); }
.stepper .step.done .dot { background: var(--moe-green-700); color: #fff; }
.stepper .step.current { background: #fef3c7; color: #92400e; }
.stepper .step.current .dot { background: #92400e; color: #fff; }

.readonly-value {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; background: var(--surface-muted); font-size: var(--font-size-sm); white-space: pre-wrap;
}

.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list > li {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.plain-list > li:last-child { border-bottom: none; }
.plain-list > li.unread { background: var(--moe-green-100); }

.timeline { list-style: none; margin: 0; padding: 0 14px 0 0; border-inline-start: 2px solid var(--border); }
.timeline > li { position: relative; padding: 6px 14px 10px; }
.timeline > li::before {
  content: ""; position: absolute; inset-inline-start: -7px; top: 12px;
  width: 10px; height: 10px; border-radius: 50%; background: var(--primary);
}

.search-results {
  position: absolute; inset-inline-start: 0; inset-inline-end: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); z-index: 60; max-height: 60vh; overflow: auto;
}
.search-item {
  display: flex; gap: 10px; align-items: center; padding: 10px 12px;
  border-bottom: 1px solid var(--border); text-decoration: none; color: inherit;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--surface-muted); }

.bell-btn { position: relative; }
.bell-count {
  position: absolute; top: -6px; inset-inline-end: -6px; min-width: 18px; height: 18px;
  border-radius: 999px; background: var(--status-late); color: #fff;
  font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 4px;
}
.bell-panel {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; width: min(340px, 88vw);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); z-index: 60; max-height: 70vh; overflow: auto;
}
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 700; }
.bell-item { display: block; padding: 10px 12px; border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; }
.bell-item:last-child { border-bottom: none; }
.bell-item:hover { background: var(--surface-muted); }
.bell-item.unread { background: var(--moe-green-100); }
