/* ============================================================
   رقيم — css/components.css
   مكوّنات واجهة عامة قابلة لإعادة الاستخدام
   ============================================================ */

/* ── البطاقات ── */
.card {
  background: var(--bg1);
  border: 1px solid var(--b1);
  border-radius: var(--r3);
  padding: var(--s4);
}
.card-sm { padding: var(--s3); border-radius: var(--r2); }
.card-title {
  display: flex; align-items: center; gap: var(--s2);
  font-size: 13.5px; font-weight: 700; color: var(--t1);
  margin-bottom: var(--s3);
}
.card-title svg { width: 16px; height: 16px; color: var(--ac); flex-shrink: 0; }

/* ── الأزرار ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: var(--r2); font-weight: 700; font-size: 13px;
  padding: 10px 18px; transition: transform var(--tr), background var(--tr), box-shadow var(--tr), opacity var(--tr);
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--ac); color: #fff; box-shadow: var(--sh1); }
.btn-primary:hover { background: var(--ac2); }
.btn-ghost { background: var(--bg3); color: var(--t2); }
.btn-ghost:hover { background: var(--bg4); }
.btn-outline { background: transparent; border: 1.5px solid var(--b2); color: var(--t2); }
.btn-outline:hover { border-color: var(--ac); color: var(--ac); }
.btn-danger { background: var(--miss); color: #fff; }
.btn-danger:hover { opacity: .88; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-icon { padding: 9px; border-radius: var(--r2); background: var(--bg3); color: var(--t2); }
.btn-icon:hover { background: var(--bg4); color: var(--t1); }
.btn:disabled { opacity: .5; pointer-events: none; }

/* ── الإدخالات ── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s3); }
.field label { font-size: 12.5px; font-weight: 600; color: var(--t2); }
.input, .select, textarea.input {
  background: var(--bg2); border: 1.5px solid var(--b1); border-radius: var(--r2);
  padding: 11px 13px; font-size: 13.5px; color: var(--t1); width: 100%;
  transition: border-color var(--tr); font-family: var(--font);
}
.input:focus, .select:focus, textarea.input:focus { outline: none; border-color: var(--ac); }
.input::placeholder { color: var(--t4); }
textarea.input { resize: vertical; min-height: 70px; }
.hint { font-size: 11px; color: var(--t4); }
.error-text { font-size: 12px; color: var(--miss); min-height: 14px; }

/* ── الشارات ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: var(--rf); font-size: 11px; font-weight: 700; }
.badge-done { background: #1A7A581a; color: var(--done); }
.badge-pending { background: #B8862A1a; color: var(--pending); }
.badge-miss { background: #C0392B1a; color: var(--miss); }

/* ── شريط التقدم ── */
.progress { height: 7px; background: var(--bg4); border-radius: var(--rf); overflow: hidden; }
.progress-fill { height: 100%; border-radius: var(--rf); transition: width .4s ease; background: var(--ac); }

/* ── حالة فارغة ── */
.empty-state { text-align: center; padding: var(--s7) var(--s4); color: var(--t3); }
.empty-state .ei { width: 40px; height: 40px; margin: 0 auto var(--s3); color: var(--t4); }
.empty-state p { font-size: 13px; }

/* ── سكلتون تحميل ── */
.skeleton { background: linear-gradient(90deg, var(--bg3) 25%, var(--bg4) 50%, var(--bg3) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--r1); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ── سبينر تحميل ── */
.spinner { width: 18px; height: 18px; border: 2.5px solid var(--b2); border-top-color: var(--ac); border-radius: 50%; animation: spin .7s linear infinite; }

/* ── مودال ── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,12,5,.5); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0; opacity: 0; transition: opacity var(--tr2);
}
.modal-backdrop.show { opacity: 1; }
.modal {
  background: var(--bg1); border-radius: var(--r4) var(--r4) 0 0;
  width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto;
  padding: var(--s5); transform: translateY(16px); transition: transform var(--tr2);
  box-shadow: var(--sh3);
}
.modal-backdrop.show .modal { transform: translateY(0); }
@media (min-width: 880px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: var(--r4); }
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s4); }
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-foot { display: flex; gap: var(--s2); margin-top: var(--s4); }
.modal-foot .btn { flex: 1; }

/* ── تنبيهات Toast ── */
#toast-container {
  position: fixed; bottom: calc(var(--bottomnav-h) + 14px); right: 50%;
  transform: translateX(50%); z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: calc(100% - 32px); max-width: 360px;
}
@media (min-width: 880px) { #toast-container { bottom: 20px; right: 20px; transform: none; } }
.toast {
  background: var(--t1); color: var(--bg1); padding: 11px 18px; border-radius: var(--rf);
  font-size: 12.5px; font-weight: 700; box-shadow: var(--sh2);
  display: flex; align-items: center; gap: 8px;
  animation: toastIn .25s ease;
}
.toast.toast-success { background: var(--done); color: #fff; }
.toast.toast-error { background: var(--miss); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── محول (Switch) ── */
.switch { position: relative; width: 42px; height: 24px; border-radius: var(--rf); background: var(--bg4); flex-shrink: 0; transition: background var(--tr); }
.switch::after { content:''; position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform var(--tr); box-shadow: var(--sh1); }
.switch.on { background: var(--ac); }
.switch.on::after { transform: translateX(-18px); }

/* ── شرائح اختيار (Chips / Segmented) ── */
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 7px 14px; border-radius: var(--rf); border: 1.5px solid var(--b1);
  background: var(--bg2); color: var(--t2); font-size: 12.5px; font-weight: 600;
  transition: all var(--tr); cursor: pointer;
}
.chip.active { background: var(--ac); border-color: var(--ac); color: #fff; }

/* ── أفاتار حروف ── */
.avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--ac3); color: var(--ac);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}

/* قائمة عناصر عمودية بخط فاصل */
.list-divided > * + * { border-top: 1px solid var(--b1); }
