:root {
  --primary: #2563EB;
  --primary-light: #DBEAFE;
  --primary-dark: #1D4ED8;
  --accent: #0EA5E9;
  --accent-light: #E0F2FE;
  --success: #10B981;
  --success-light: #D1FAE5;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --danger: #EF4444;
  --danger-light: #FEE2E2;
  --purple: #8B5CF6;
  --purple-light: #EDE9FE;
  --orange: #F97316;
  --orange-light: #FFF7ED;
  --teal: #14B8A6;
  --teal-light: #CCFBF1;
  --indigo: #6366F1;
  --indigo-light: #E0E7FF;
  --rose: #F43F5E;
  --rose-light: #FFF1F2;
  --gray-50: #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1E293B;
  --gray-900: #0F172A;
  --white: #FFFFFF;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.07), 0 4px 6px -4px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Tajawal', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 350px;
  background: linear-gradient(135deg, #EEF2FF 0%, #F0F9FF 30%, #ECFDF5 60%, #FFF7ED 100%);
  z-index: -2;
}

body::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 350px;
  background: radial-gradient(ellipse at 30% 40%, rgba(99,102,241,0.04) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 30%, rgba(20,184,166,0.04) 0%, transparent 50%);
  z-index: -1;
}

/* === Sidebar === */
.sidebar {
  position: fixed; right: 0; top: 0; bottom: 0;
  width: 260px;
  background: var(--white);
  border-left: 1px solid var(--gray-200);
  z-index: 100;
  display: flex; flex-direction: column;
  box-shadow: -4px 0 20px rgba(0,0,0,0.03);
}

.sidebar-header { padding: 24px 20px; border-bottom: 1px solid var(--gray-100); }
.sidebar-logo { display: flex; align-items: center; gap: 12px; }
.sidebar-logo-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 20px;
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}
.sidebar-logo-text { font-family: 'Noto Kufi Arabic', sans-serif; font-size: 16px; font-weight: 700; color: var(--gray-800); }
.sidebar-logo-sub { font-size: 11px; color: var(--gray-400); font-weight: 400; margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-section { margin-bottom: 24px; }
.nav-section-title { font-size: 11px; font-weight: 700; color: var(--gray-400); letter-spacing: 1px; padding: 0 12px; margin-bottom: 8px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: var(--transition);
  color: var(--gray-600); font-size: 14px; font-weight: 500;
  position: relative; text-decoration: none;
}
.nav-item:hover { background: var(--gray-50); color: var(--gray-800); }
.nav-item.active { background: var(--indigo-light); color: var(--indigo); font-weight: 700; }
.nav-item.active::before {
  content: ''; position: absolute; right: -12px; top: 6px; bottom: 6px;
  width: 3px; background: var(--indigo); border-radius: 3px;
}
.nav-item-icon { width: 20px; text-align: center; font-size: 16px; flex-shrink: 0; }
.nav-badge { margin-right: auto; margin-left: 0; background: var(--danger); color: white; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; }

.sidebar-footer { padding: 16px 12px; border-top: 1px solid var(--gray-100); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer; transition: var(--transition); text-decoration: none; color: inherit; }
.user-card:hover { background: var(--gray-50); }
.user-avatar { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--indigo), var(--purple)); display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 14px; }
.user-info { flex: 1; }
.user-name { font-size: 13px; font-weight: 700; color: var(--gray-800); }
.user-role { font-size: 11px; color: var(--gray-400); }
.user-logout-btn { background: none; border: none; color: var(--gray-400); cursor: pointer; font-size: 16px; padding: 6px; border-radius: 6px; transition: var(--transition); }
.user-logout-btn:hover { color: var(--danger); background: var(--danger-light); }

/* === Main Content === */
.main-content { margin-right: 260px; min-height: 100vh; }

/* === Top Header === */
.top-header {
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(226,232,240,0.6);
  padding: 0 32px; height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--gray-400); }
.breadcrumb a { color: var(--gray-400); text-decoration: none; transition: var(--transition); }
.breadcrumb a:hover { color: var(--indigo); }
.breadcrumb .current { color: var(--gray-700); font-weight: 600; }
.breadcrumb .sep { color: var(--gray-300); }

.header-left { display: flex; align-items: center; gap: 12px; }
.header-icon-btn {
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--gray-200); background: var(--white);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: var(--transition); color: var(--gray-500);
  position: relative; font-size: 18px;
}
.header-icon-btn:hover { border-color: var(--indigo); color: var(--indigo); box-shadow: var(--shadow); }
.header-icon-btn .notif-dot { position: absolute; top: 8px; left: 8px; width: 8px; height: 8px; background: var(--danger); border-radius: 50%; border: 2px solid var(--white); }

/* === Page === */
.page-content { padding: 28px 32px; }
.page-title-section { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.page-title-group { display: flex; flex-direction: column; gap: 6px; }
.page-title {
  font-family: 'Noto Kufi Arabic', sans-serif; font-size: 26px; font-weight: 700;
  color: var(--gray-900); display: flex; align-items: center; gap: 12px;
}
.page-title-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--indigo-light), var(--teal-light));
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.page-subtitle { font-size: 14px; color: var(--gray-500); padding-right: 56px; }
.page-actions { display: flex; gap: 10px; }

/* === Buttons === */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-family: 'Tajawal', sans-serif; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: var(--transition); border: none; white-space: nowrap;
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--indigo), #4F46E5);
  color: white; box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(99,102,241,0.4); }
.btn-outline { background: var(--white); color: var(--gray-600); border: 1px solid var(--gray-200); }
.btn-outline:hover { border-color: var(--indigo); color: var(--indigo); background: var(--indigo-light); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; }
.btn-success { background: linear-gradient(135deg, var(--success), #059669); color: white; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

/* === Stats Cards === */
.stats-scroll { display: flex; gap: 14px; margin-bottom: 24px; overflow-x: auto; padding-bottom: 4px; }
.stat-card {
  background: var(--white); border-radius: var(--radius);
  padding: 18px 20px; min-width: 170px; flex: 1;
  border: 1px solid var(--gray-100);
  cursor: pointer; transition: var(--transition);
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: ''; position: absolute; bottom: 0; right: 0; left: 0;
  height: 3px; border-radius: 0 0 12px 12px;
}
.stat-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); border-color: transparent; }
.stat-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.stat-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 17px; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--gray-900); font-family: 'Noto Kufi Arabic', sans-serif; margin-bottom: 2px; }
.stat-label { font-size: 12px; color: var(--gray-500); font-weight: 500; }

.stat-card.c-indigo::after { background: var(--indigo); } .stat-card.c-indigo .stat-icon { background: var(--indigo-light); color: var(--indigo); }
.stat-card.c-teal::after { background: var(--teal); }     .stat-card.c-teal .stat-icon { background: var(--teal-light); color: var(--teal); }
.stat-card.c-success::after { background: var(--success); } .stat-card.c-success .stat-icon { background: var(--success-light); color: var(--success); }
.stat-card.c-warning::after { background: var(--warning); } .stat-card.c-warning .stat-icon { background: var(--warning-light); color: var(--warning); }
.stat-card.c-danger::after { background: var(--danger); } .stat-card.c-danger .stat-icon { background: var(--danger-light); color: var(--danger); }
.stat-card.c-purple::after { background: var(--purple); } .stat-card.c-purple .stat-icon { background: var(--purple-light); color: var(--purple); }
.stat-card.c-orange::after { background: var(--orange); } .stat-card.c-orange .stat-icon { background: var(--orange-light); color: var(--orange); }

/* === Toolbar === */
.toolbar-section {
  background: var(--white); border-radius: var(--radius-lg);
  border: 1px solid var(--gray-100); padding: 18px 20px;
  margin-bottom: 20px; box-shadow: var(--shadow-sm);
}
.toolbar-row { display: flex; align-items: center; gap: 12px; }
.search-box { flex: 1; position: relative; }
.search-box input {
  width: 100%; padding: 11px 44px 11px 16px;
  border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm);
  font-family: 'Tajawal', sans-serif; font-size: 14px; color: var(--gray-800);
  background: var(--gray-50); transition: var(--transition);
}
.search-box input:focus { outline: none; border-color: var(--indigo); background: var(--white); box-shadow: 0 0 0 3px rgba(99,102,241,0.1); }
.search-box .s-icon { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--gray-400); }

/* === Table === */
.table-container {
  background: var(--white); border-radius: var(--radius-lg);
  border: 1px solid var(--gray-100); overflow: hidden; box-shadow: var(--shadow-sm);
}
.table-scroll { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; }
.data-table thead { background: var(--gray-50); border-bottom: 2px solid var(--gray-100); }
.data-table thead th { padding: 13px 14px; text-align: right; font-size: 11px; font-weight: 700; color: var(--gray-500); white-space: nowrap; letter-spacing: 0.3px; }
.data-table tbody tr { border-bottom: 1px solid var(--gray-100); transition: var(--transition); }
.data-table tbody tr:hover { background: rgba(99,102,241,0.02); }
.data-table tbody td { padding: 14px; font-size: 13px; color: var(--gray-700); vertical-align: middle; }
.data-table tbody tr:last-child { border-bottom: none; }

/* === Badges === */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 12px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
}
.badge.indigo { background: var(--indigo-light); color: var(--indigo); }
.badge.teal { background: var(--teal-light); color: var(--teal); }
.badge.success { background: var(--success-light); color: var(--success); }
.badge.warning { background: var(--warning-light); color: var(--warning); }
.badge.danger { background: var(--danger-light); color: var(--danger); }
.badge.purple { background: var(--purple-light); color: var(--purple); }
.badge.gray { background: var(--gray-100); color: var(--gray-500); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* === User mini === */
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-mini-avatar {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 13px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--indigo), var(--purple));
}
.user-cell-info .name { font-size: 13px; font-weight: 600; color: var(--gray-800); }
.user-cell-info .email { font-size: 11px; color: var(--gray-400); }

/* === Actions === */
.action-btn {
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: transparent; color: var(--gray-400); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: var(--transition); font-size: 14px;
}
.action-btn:hover { background: var(--indigo-light); color: var(--indigo); }
.action-btn.danger:hover { background: var(--danger-light); color: var(--danger); }

/* === Form === */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.form-label .req { color: var(--danger); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm);
  font-family: 'Tajawal', sans-serif; font-size: 14px; color: var(--gray-800);
  background: var(--white); transition: var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.form-error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.form-hint { color: var(--gray-400); font-size: 12px; margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 6px 0; }
.form-check input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--indigo); cursor: pointer; }
.form-check span { font-size: 14px; color: var(--gray-700); }

/* === Modal === */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; backdrop-filter: blur(4px);
}
.modal-box {
  background: var(--white); border-radius: var(--radius-lg);
  width: 90%; max-width: 560px; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
  overflow: hidden;
}
.modal-box.lg { max-width: 780px; }
.modal-box.sm { max-width: 420px; }
.modal-header {
  padding: 20px 24px; border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-family: 'Noto Kufi Arabic', sans-serif; font-size: 17px; font-weight: 700; color: var(--gray-900); display: flex; align-items: center; gap: 10px; }
.modal-title-icon { width: 34px; height: 34px; border-radius: 10px; background: var(--indigo-light); color: var(--indigo); display: flex; align-items: center; justify-content: center; font-size: 16px; }
.modal-close {
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: var(--gray-100); color: var(--gray-500); cursor: pointer;
  font-size: 18px; display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.modal-close:hover { background: var(--danger-light); color: var(--danger); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--gray-100);
  display: flex; justify-content: flex-start; gap: 10px;
}

/* === Toast === */
.toasts-container {
  position: fixed; top: 20px; left: 20px; z-index: 2000;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: var(--white); border-radius: var(--radius);
  padding: 14px 18px; min-width: 280px; max-width: 420px;
  box-shadow: var(--shadow-lg); border-right: 4px solid var(--indigo);
  display: flex; align-items: center; gap: 12px;
  animation: toastIn 0.3s ease;
}
.toast.success { border-right-color: var(--success); }
.toast.error { border-right-color: var(--danger); }
.toast.warning { border-right-color: var(--warning); }
.toast-icon { width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 15px; }
.toast.success .toast-icon { background: var(--success-light); color: var(--success); }
.toast.error .toast-icon { background: var(--danger-light); color: var(--danger); }
.toast.warning .toast-icon { background: var(--warning-light); color: var(--warning); }
.toast.info .toast-icon { background: var(--indigo-light); color: var(--indigo); }
.toast-msg { flex: 1; font-size: 13px; color: var(--gray-700); font-weight: 500; }
.toast-close { background: none; border: none; color: var(--gray-400); cursor: pointer; font-size: 16px; padding: 4px; }
.toast-close:hover { color: var(--gray-700); }

@keyframes toastIn { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } }

/* Empty state */
.empty-state { padding: 60px 20px; text-align: center; }
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-title { font-size: 16px; font-weight: 700; color: var(--gray-600); margin-bottom: 6px; }
.empty-desc { font-size: 13px; color: var(--gray-400); }

/* ═══════════════════════════════════════════════════════════
   LTR OVERRIDES — يُطبَّق عندما تكون اللغة إنجليزية
   ═══════════════════════════════════════════════════════════ */

/* Use a font friendlier for English while keeping Arabic support */
[dir="ltr"] body {
  font-family: 'Inter', 'Segoe UI', 'Tajawal', system-ui, sans-serif;
}

/* Sidebar → left */
[dir="ltr"] .sidebar {
  right: auto; left: 0;
  border-left: none;
  border-right: 1px solid var(--gray-200);
  box-shadow: 4px 0 20px rgba(0,0,0,0.03);
}

/* Main content margin flips */
[dir="ltr"] .main-content {
  margin-right: 0;
  margin-left: 260px;
}

/* Active nav-item indicator: right → left */
[dir="ltr"] .nav-item.active::before {
  right: auto; left: -12px;
}

/* Stat-card bottom border radius shouldn't need flipping */

/* Tables align left */
[dir="ltr"] .data-table thead th { text-align: left; }
[dir="ltr"] .data-table tbody td { text-align: left; }

/* Modal footer buttons align */
[dir="ltr"] .modal-footer { justify-content: flex-end; }

/* Toasts — from left to right */
[dir="ltr"] .toasts-container {
  left: auto; right: 20px;
}
[dir="ltr"] .toast { border-right: none; border-left: 4px solid var(--indigo); }
[dir="ltr"] .toast.success { border-left-color: var(--success); }
[dir="ltr"] .toast.error { border-left-color: var(--danger); }
[dir="ltr"] .toast.warning { border-left-color: var(--warning); }
[dir="ltr"] @keyframes toastInLtr { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
[dir="ltr"] .toast { animation-name: toastInLtr; }

/* Breadcrumb separator arrow faces the right direction (›) — already universal */

/* Page title subtitle padding */
[dir="ltr"] .page-subtitle { padding-right: 0; padding-left: 56px; }

/* User logout button border-right → border-left */
[dir="ltr"] .sidebar-footer .user-card { flex-direction: row; }

/* Search icon position */
[dir="ltr"] .search-box input { padding: 11px 16px 11px 44px; }
[dir="ltr"] .search-box .s-icon { right: auto; left: 14px; }

/* Filter select arrow position */
[dir="ltr"] .filter-select { padding-left: 30px; padding-right: 12px; background-position: right 12px center; }

/* Form check direction */
[dir="ltr"] .form-check { flex-direction: row; }

/* Dropdown menus (notifications bell + user menu) position */
[dir="ltr"] [x-data="notifBell()"] > div[x-show] { left: auto !important; right: 0 !important; }
[dir="ltr"] .header-left > div[x-data^="{ open"] > div[x-show] { left: auto !important; right: 0 !important; }

/* Sidebar active border */
[dir="ltr"] .sidebar-footer { border-top: 1px solid var(--gray-100); }

/* Action button spacing in kanban cards */
[dir="ltr"] .kb-card { border-right: none; border-left: 3px solid var(--indigo); }
[dir="ltr"] .kb-card.p-critical { border-left-color: var(--danger); }
[dir="ltr"] .kb-card.p-high { border-left-color: var(--orange); }
[dir="ltr"] .kb-card.p-normal { border-left-color: var(--indigo); }
[dir="ltr"] .kb-card.p-low { border-left-color: var(--gray-400); }

/* Responsive */
@media (max-width: 900px) {
  [dir="ltr"] .main-content { margin-left: 0; }
}
