/* إعدادات عامة */
* {
  box-sizing: border-box;
  font-family: 'Tajawal', 'Segoe UI', system-ui, sans-serif;
}

html, body {
  margin: 0;
  padding: 0;
  background: #f5f7fb;
  color: #111827;
  direction: rtl;
}

/* زر الوضع الليلي */
.theme-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  padding: 8px 14px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.25);
  transition: all 0.2s ease;
  z-index: 20;
}

.theme-btn:hover {
  background: #1e40af;
}

/* الحاوية العامة */
.container {
  max-width: 1100px;
  margin: 80px auto 40px;
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
}

/* العنوان الرئيسي */
h1 {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 700;
  color: #111827;
  text-align: center;
}

.credit {
  text-align: center;
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 20px;
}

/* أدوات البحث */
.tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 8px;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 260px;
}

#searchBox {
  width: 100%;
  padding: 12px 40px 12px 12px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  font-size: 14px;
  outline: none;
  transition: 0.2s;
}

#searchBox:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.clear-btn {
  position: absolute;
  top: 50%;
  left: 10px;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  color: #9ca3af;
}

.clear-btn:hover {
  color: #111827;
}

/* اختيار عدد الصفوف */
#pageSize {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  font-size: 13px;
  background: #fff;
  cursor: pointer;
}

/* عدد النتائج */
.count {
  font-size: 14px;
  color: #374151;
  text-align: right;
  margin: 6px 0 14px;
}

/* كارد الجدول */
.card {
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}

/* تغليف الجدول */
.table-wrap {
  overflow-x: auto;
}

/* الجدول */
table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed; /* الأعمدة متساوية */
}

thead {
  background: #f3f4ff;
}

/* القاعدة العامة للأعمدة */
th,
td {
  width: 33.33%;              /* ثلاث أعمدة متساوية */
  padding: 10px 8px;
  border-bottom: 1px solid #e5e7eb;
  text-align: center;
  font-size: 13px;
  white-space: nowrap;        /* افتراضياً: لا يلف السطر */
  overflow: hidden;
  text-overflow: ellipsis;    /* نقاط للنص الطويل */
}

/* عنوان الأعمدة */
th {
  font-weight: 600;
  font-size: 14px;
  color: #374151;
}

/* ✅ السماح لاسم البند أن يظهر كاملاً مع لفّ منظم */
th:nth-child(1),
td:nth-child(1) {
  white-space: normal;        /* يسمح بتعدد الأسطر */
  text-overflow: clip;        /* بدون نقاط */
  text-align: right;          /* محاذاة لليمين لقراءة أوضح */
  line-height: 1.5;
  padding-right: 10px;
}

/* الكمية + وحدة البند تبقى في سطر واحد ومرتّبة */
th:nth-child(2),
td:nth-child(2),
th:nth-child(3),
td:nth-child(3) {
  text-align: center;
}

/* صفوف */
tbody tr:nth-child(even) {
  background: #f9fafb;
}

tbody tr:hover {
  background: #eff6ff;
  transition: background-color 0.2s ease;
}

/* النص عند عدم وجود نتائج */
.no-results {
  text-align: center;
  padding: 14px;
  font-size: 13px;
  color: #9ca3af;
}

/* تمييز نتيجة البحث */
.hl {
  background: #fffbeb;
  padding: 0 2px;
  border-radius: 3px;
}

/* الترقيم */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 12px;
  flex-wrap: wrap;
}

.page-btn {
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  background: #e5e7eb;
  cursor: pointer;
  font-size: 13px;
  transition: 0.2s;
}

.page-btn:hover {
  background: #dbeafe;
}

.page-btn.active {
  background: #2563eb;
  color: #fff;
}

.page-btn.ghost {
  opacity: 0.8;
}

.dots {
  color: #9ca3af;
  font-size: 13px;
  padding: 0 4px;
}

/* تأثير تحميل */
.skeleton {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}

.sk-row {
  height: 16px;
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: 6px;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* التذييل */
.footer {
  text-align: center;
  font-size: 13px;
  color: #6b7280;
  margin-top: 16px;
  padding: 10px;
}

/* الوضع الليلي */
.dark body {
  background: #0f172a;
  color: #e2e8f0;
}

.dark .container {
  background: #1e293b;
  color: #e2e8f0;
}

.dark table {
  color: #e2e8f0;
}

.dark thead {
  background: #334155;
}

.dark tbody tr:nth-child(even) {
  background: #111827;
}

.dark .card {
  border-color: #4b5563;
  background: #0f172a;
}

.dark .page-btn {
  background: #334155;
  color: #e2e8f0;
}

.dark .page-btn.active {
  background: #2563eb;
  color: #fff;
}

.dark .theme-btn {
  background: #475569;
  color: #fff;
}
