/* ==========================================================================
   WABEL Smart Attendance — نظام التصميم الموحّد (RTL)
   هوية شركة وابل الدولية للتدريب والاستشارات — أسود / أبيض / أحمر
   ========================================================================== */

:root {
  --w-red: #c8102e;
  --w-red-bright: #e63950;
  --w-red-dark: #8e0e22;
  --w-red-grad: linear-gradient(135deg, #e63950 0%, #c8102e 45%, #8e0e22 100%);
  --w-bg: #0b0c10;
  --w-bg-2: #101218;
  --w-panel: #14161d;
  --w-panel-2: #191c25;
  --w-border: rgba(255, 255, 255, .07);
  --w-border-strong: rgba(255, 255, 255, .12);
  --w-text: #f4f5f7;
  --w-text-2: #a7adb9;
  --w-text-3: #6f7683;
  --w-green: #22c55e;
  --w-amber: #f59e0b;
  --w-blue: #3b82f6;
  --w-violet: #8b5cf6;
  --w-danger: #ef4444;
  --w-radius: 14px;
  --w-radius-sm: 10px;
  --w-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --w-shadow-soft: 0 4px 18px rgba(0, 0, 0, .25);
  --w-font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  --w-sidebar-w: 264px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--w-font);
  background: var(--w-bg);
  color: var(--w-text);
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.35; }
p { line-height: 1.8; }
a { color: var(--w-red-bright); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: rgba(200, 16, 46, .45); color: #fff; }

/* أشرطة تمرير أنيقة */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #262a35; border-radius: 20px; border: 2px solid var(--w-bg); }
::-webkit-scrollbar-thumb:hover { background: #333947; }

/* ============ أزرار ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--w-font); font-size: .92rem; font-weight: 600;
  padding: 10px 18px; border-radius: var(--w-radius-sm);
  border: 1px solid transparent; cursor: pointer; user-select: none;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease, opacity .2s;
  text-decoration: none !important; line-height: 1.4; white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn svg { width: 17px; height: 17px; flex: none; }

.btn-primary { background: var(--w-red-grad); color: #fff; box-shadow: 0 6px 18px rgba(200, 16, 46, .35); }
.btn-primary:hover { box-shadow: 0 8px 26px rgba(200, 16, 46, .5); filter: brightness(1.07); }

.btn-ghost { background: rgba(255, 255, 255, .05); color: var(--w-text); border-color: var(--w-border-strong); }
.btn-ghost:hover { background: rgba(255, 255, 255, .09); }

.btn-soft { background: rgba(200, 16, 46, .12); color: #ff8fa0; border-color: rgba(200, 16, 46, .25); }
.btn-soft:hover { background: rgba(200, 16, 46, .2); }

.btn-green { background: rgba(34, 197, 94, .14); color: #6ee7a0; border-color: rgba(34, 197, 94, .3); }
.btn-green:hover { background: rgba(34, 197, 94, .22); }

.btn-amber { background: rgba(245, 158, 11, .13); color: #fbbf24; border-color: rgba(245, 158, 11, .3); }
.btn-amber:hover { background: rgba(245, 158, 11, .22); }

.btn-danger { background: rgba(239, 68, 68, .13); color: #fda4af; border-color: rgba(239, 68, 68, .3); }
.btn-danger:hover { background: rgba(239, 68, 68, .22); }

.btn-sm { padding: 6px 12px; font-size: .82rem; border-radius: 8px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; border-radius: 12px; }
.btn-block { width: 100%; }

/* ============ حقول ============ */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 4px; }
.field label { font-size: .82rem; font-weight: 600; color: var(--w-text-2); }
.field label .req { color: var(--w-red-bright); }

.input, .select, .textarea {
  width: 100%; font-family: var(--w-font); font-size: .95rem; color: var(--w-text);
  background: var(--w-bg-2); border: 1px solid var(--w-border-strong);
  border-radius: var(--w-radius-sm); padding: 11px 14px;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.input::placeholder, .textarea::placeholder { color: var(--w-text-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: rgba(200, 16, 46, .65);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, .18); background: #0d0f14;
}
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--w-text-2) 50%), linear-gradient(135deg, var(--w-text-2) 50%, transparent 50%); background-position: left 16px top 50%, left 11px top 50%; background-size: 5px 5px; background-repeat: no-repeat; cursor: pointer; }
.textarea { min-height: 90px; resize: vertical; }
.hint { font-size: .76rem; color: var(--w-text-3); }

/* ============ بطاقات ============ */
.card {
  background: linear-gradient(180deg, var(--w-panel) 0%, #12141a 100%);
  border: 1px solid var(--w-border); border-radius: var(--w-radius);
  box-shadow: var(--w-shadow-soft);
}
.card-pad { padding: 22px; }
.card-title { display: flex; align-items: center; gap: 10px; font-size: 1.02rem; font-weight: 700; margin-bottom: 16px; }
.card-title svg { width: 19px; height: 19px; color: var(--w-red-bright); }

/* بطاقة إحصائية */
.stat-card {
  background: linear-gradient(180deg, var(--w-panel-2) 0%, var(--w-panel) 100%);
  border: 1px solid var(--w-border); border-radius: var(--w-radius);
  padding: 18px 20px; display: flex; align-items: center; gap: 14px;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
  position: relative; overflow: hidden;
}
.stat-card:hover { transform: translateY(-3px); border-color: var(--w-border-strong); box-shadow: var(--w-shadow); }
.stat-card::after { content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 3px; background: var(--w-accent, var(--w-red)); opacity: .8; border-radius: 3px; }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--w-accent, var(--w-red)) 14%, transparent); color: var(--w-accent, #ff8fa0); flex: none; }
.stat-icon svg { width: 22px; height: 22px; }
.stat-value { font-size: 1.55rem; font-weight: 800; letter-spacing: -.5px; line-height: 1.2; }
.stat-label { font-size: .78rem; color: var(--w-text-2); font-weight: 500; }
.stat-sub { font-size: .72rem; color: var(--w-text-3); }

/* ============ شارات الحالة ============ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .74rem; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap; line-height: 1.6;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-present, .badge-active { background: rgba(34, 197, 94, .12); color: #4ade80; border-color: rgba(34, 197, 94, .25); }
.badge-late { background: rgba(245, 158, 11, .12); color: #fbbf24; border-color: rgba(245, 158, 11, .28); }
.badge-rejected, .badge-cancelled { background: rgba(239, 68, 68, .12); color: #f87171; border-color: rgba(239, 68, 68, .28); }
.badge-pending_review { background: rgba(139, 92, 246, .13); color: #c4b5fd; border-color: rgba(139, 92, 246, .3); }
.badge-open { background: rgba(59, 130, 246, .12); color: #7fb0ff; border-color: rgba(59, 130, 246, .3); }
.badge-closed { background: rgba(255, 255, 255, .06); color: var(--w-text-2); border-color: var(--w-border-strong); }
.badge-paused { background: rgba(245, 158, 11, .12); color: #fbbf24; border-color: rgba(245, 158, 11, .28); }
.badge-completed { background: rgba(255, 255, 255, .06); color: var(--w-text-2); border-color: var(--w-border-strong); }
.badge-role { background: rgba(255, 255, 255, .06); color: var(--w-text-2); border-color: var(--w-border-strong); }

/* ============ جداول ============ */
.table-wrap { overflow-x: auto; border-radius: var(--w-radius); border: 1px solid var(--w-border); background: var(--w-panel); }
table.w-table { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 720px; }
.w-table thead th {
  background: #171a22; color: var(--w-text-2); font-size: .76rem; font-weight: 700;
  text-align: right; padding: 12px 14px; border-bottom: 1px solid var(--w-border-strong);
  white-space: nowrap; position: sticky; top: 0; z-index: 2;
}
.w-table tbody td { padding: 11px 14px; border-bottom: 1px solid var(--w-border); color: var(--w-text); vertical-align: middle; }
.w-table tbody tr { transition: background .15s; }
.w-table tbody tr:hover { background: rgba(255, 255, 255, .025); }
.w-table tbody tr:last-child td { border-bottom: none; }
.w-table .num { font-variant-numeric: tabular-nums; }
.w-table .actions { display: flex; gap: 6px; justify-content: flex-start; }
.w-table .cell-strong { font-weight: 700; }
.w-table .cell-muted { color: var(--w-text-3); font-size: .8rem; }
.table-empty { padding: 42px 20px; text-align: center; color: var(--w-text-3); font-size: .9rem; }
.table-empty svg { width: 34px; height: 34px; opacity: .4; margin-bottom: 8px; }

/* ============ نموذج بحث وفلاتر ============ */
.filters-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.filters-bar .input, .filters-bar .select { width: auto; min-width: 160px; padding: 9px 13px; font-size: .87rem; }
.search-box { position: relative; }
.search-box svg { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--w-text-3); pointer-events: none; }
.search-box .input { padding-inline-start: 38px; }

/* ============ تنبيهات Toast ============ */
.toast-zone { position: fixed; bottom: 22px; inset-inline-start: 22px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 44px)); }
.toast {
  display: flex; align-items: flex-start; gap: 11px; padding: 14px 16px;
  border-radius: 12px; background: #1a1d26; border: 1px solid var(--w-border-strong);
  box-shadow: var(--w-shadow); animation: toast-in .35s cubic-bezier(.2, .9, .3, 1.2);
  font-size: .88rem; line-height: 1.6;
}
.toast svg { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.toast-success { border-color: rgba(34, 197, 94, .35); } .toast-success svg { color: #4ade80; }
.toast-error { border-color: rgba(239, 68, 68, .4); } .toast-error svg { color: #f87171; }
.toast-info { border-color: rgba(59, 130, 246, .35); } .toast-info svg { color: #7fb0ff; }
.toast-out { animation: toast-out .3s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px) scale(.97); } }

/* ============ نوافذ منبثقة Modal ============ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9000; background: rgba(5, 6, 10, .72);
  backdrop-filter: blur(6px); display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; animation: fade-in .2s ease; }
.modal {
  background: var(--w-panel); border: 1px solid var(--w-border-strong); border-radius: 18px;
  box-shadow: var(--w-shadow); width: 100%; max-width: 560px; max-height: 88vh;
  display: flex; flex-direction: column; animation: modal-in .28s cubic-bezier(.2, .9, .3, 1.15);
}
.modal-lg { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--w-border); }
.modal-head h3 { font-size: 1.05rem; display: flex; align-items: center; gap: 9px; }
.modal-head h3 svg { width: 19px; height: 19px; color: var(--w-red-bright); }
.modal-close { background: rgba(255,255,255,.05); border: 1px solid var(--w-border); color: var(--w-text-2); width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; cursor: pointer; transition: .2s; }
.modal-close:hover { background: rgba(239,68,68,.15); color: #f87171; border-color: rgba(239,68,68,.3); }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { padding: 15px 22px; border-top: 1px solid var(--w-border); display: flex; gap: 10px; justify-content: flex-start; flex-wrap: wrap; }
@keyframes modal-in { from { opacity: 0; transform: translateY(18px) scale(.97); } }
@keyframes fade-in { from { opacity: 0; } }

/* ============ الشعار ============ */
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 40px; width: auto; object-fit: contain; }
.brand-name { font-weight: 800; font-size: 1.02rem; letter-spacing: .2px; line-height: 1.3; }
.brand-sub { font-size: .7rem; color: var(--w-text-3); font-weight: 500; letter-spacing: .6px; }

/* ============ شاشة تحميل / سكيليتون ============ */
.skeleton { background: linear-gradient(90deg, #171a22 25%, #20242f 50%, #171a22 75%); background-size: 400% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.spinner { width: 22px; height: 22px; border: 2.5px solid rgba(255,255,255,.12); border-top-color: var(--w-red-bright); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
.spinner-lg { width: 42px; height: 42px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: grid; place-items: center; padding: 48px; gap: 12px; color: var(--w-text-3); font-size: .85rem; }

/* ============ صفحة فارغة ============ */
.empty-state { text-align: center; padding: 52px 20px; color: var(--w-text-3); }
.empty-state svg { width: 46px; height: 46px; opacity: .35; margin-bottom: 12px; }
.empty-state h4 { color: var(--w-text-2); margin-bottom: 6px; font-size: .98rem; }
.empty-state p { font-size: .84rem; margin: 0; }

/* ============ شبكات ============ */
.grid-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }

/* ============ أنماط الطباعة (تقارير PDF + ورقة QR) ============ */
.print-sheet { display: none; }
@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff !important; }
  body > *:not(.print-sheet) { display: none !important; }
  .print-sheet { display: block !important; direction: rtl; color: #111; font-family: var(--w-font); }
}

/* ============ شريط وضع المعاينة (Demo) ============ */
.demo-banner {
  position: sticky; top: 0; z-index: 500; display: flex; align-items: center; gap: 10px; justify-content: center;
  background: repeating-linear-gradient(45deg, #3a2b00, #3a2b00 12px, #42310a 12px, #42310a 24px);
  color: #ffd479; font-size: .8rem; font-weight: 600; padding: 8px 14px; border-bottom: 1px solid rgba(245, 158, 11, .3);
}
.demo-banner svg { width: 16px; height: 16px; }

/* أدوات صغيرة */
.muted { color: var(--w-text-3); }
.small { font-size: .78rem; }
.mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 20px; } .mt-4 { margin-top: 30px; }
.mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 20px; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1; }
.mono { font-family: 'Consolas', 'Courier New', monospace; direction: ltr; unicode-bidi: embed; }
.hidden { display: none !important; }

/* حركة دخول اللوحات */
.page-enter { animation: page-in .3s ease; }
@keyframes page-in { from { opacity: 0; transform: translateY(10px); } }

/* نبضة إشعار تسجيل جديد */
.pulse-dot { position: relative; width: 9px; height: 9px; border-radius: 50%; background: var(--w-green); }
.pulse-dot::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--w-green); animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { transform: scale(.6); opacity: 1; } 100% { transform: scale(1.7); opacity: 0; } }

/* استجابة الشاشات */
@media (max-width: 768px) {
  .stat-value { font-size: 1.3rem; }
  .card-pad { padding: 16px; }
  .modal-body { padding: 16px; }
  .filters-bar .input, .filters-bar .select { flex: 1 1 140px; }
}
