/* ============================================================
   الفارس ERP — تصميم مشترك لجميع الصفحات
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700;900&display=swap');

:root {
  --bg:       #0d1117;
  --surface:  #161b22;
  --surface2: #1c2330;
  --surface3: #21262d;
  --border:   rgba(255,255,255,0.06);
  --border2:  rgba(255,255,255,0.1);
  --green:    #2ea043;
  --green-l:  #3fb950;
  --gold:     #d29922;
  --gold-l:   #e3b341;
  --blue:     #58a6ff;
  --red:      #da3633;
  --text:     #e6edf3;
  --muted:    #8b949e;
  --sidebar-w: 260px;
  --header-h:  64px;
}

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

body {
  font-family: 'Cairo', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  direction: rtl;
}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--green), #1a5c34);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}

.brand-text h2 { font-size: 13px; font-weight: 900; }
.brand-text p  { font-size: 10px; color: var(--muted); }

.nav-section { padding: 4px 10px; margin-top: 2px; }

.nav-label {
  font-size: 9px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px;
  padding: 6px 8px 3px; display: block;
}

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 7px;
  cursor: pointer; transition: all 0.2s;
  color: var(--muted); font-size: 13px; font-weight: 600;
  text-decoration: none; margin-bottom: 1px;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav-item.active { background: rgba(46,160,67,0.15); color: var(--green-l); }
.nav-icon { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-badge { margin-right: auto; background: var(--red); color: #fff;
  font-size: 9px; font-weight: 700; padding: 2px 5px; border-radius: 20px; }

.sidebar-footer {
  margin-top: auto; padding: 12px 10px;
  border-top: 1px solid var(--border);
}
.user-card {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  border-radius: 8px; background: var(--surface2); cursor: pointer;
}
.user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--gold), var(--gold-l));
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.user-info h4 { font-size: 12px; font-weight: 700; }
.user-info p  { font-size: 10px; color: var(--muted); }

/* ── Main ─────────────────────────────────────────────── */
.main { margin-right: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; }

.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title h1 { font-size: 17px; font-weight: 900; }
.topbar-title p  { font-size: 11px; color: var(--muted); }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 9px;
  font-family: 'Cairo', sans-serif; font-size: 13px; font-weight: 700;
  cursor: pointer; border: none; transition: all 0.2s; text-decoration: none;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-l); transform: translateY(-1px); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border2); }
.btn-secondary:hover { background: var(--surface3); }
.btn-danger { background: rgba(218,54,51,0.15); color: var(--red); border: 1px solid rgba(218,54,51,0.2); }
.btn-danger:hover { background: rgba(218,54,51,0.25); }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 7px; }
.btn-icon { width: 36px; height: 36px; padding: 0; justify-content: center;
  background: var(--surface2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; }
.btn-icon:hover { border-color: var(--green); color: var(--green-l); }

/* ── Page Content ─────────────────────────────────────── */
.page-content { padding: 24px; flex: 1; }

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 700; }
.card-body { padding: 20px; }

/* ── Stats row ────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.stat-card .stat-val { font-size: 22px; font-weight: 900; margin-bottom: 3px; }
.stat-card .stat-lbl { font-size: 12px; color: var(--muted); }
.stat-card .stat-icon { font-size: 22px; margin-bottom: 8px; }

/* ── Table ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 2px solid var(--border2); }
th { padding: 11px 14px; text-align: right; font-size: 12px; font-weight: 700;
     color: var(--muted); white-space: nowrap; }
td { padding: 11px 14px; font-size: 13px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { transition: background 0.15s; }
tbody tr:hover { background: rgba(255,255,255,0.02); }
tbody tr:last-child td { border-bottom: none; }

.actions-cell { display: flex; gap: 6px; flex-wrap: nowrap; }

/* ── Filter Bar ───────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px; align-items: center;
}
.search-box {
  position: relative; flex: 1; min-width: 200px;
}
.search-box input { width: 100%; }
.search-box .search-ico {
  position: absolute; top: 50%; right: 12px;
  transform: translateY(-50%); font-size: 15px; opacity: 0.4; pointer-events: none;
}

/* ── Form ─────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.cols-3 { grid-template-columns: repeat(3,1fr); }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 700; color: var(--muted); }
input, select, textarea {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 9px;
  padding: 10px 13px;
  color: var(--text);
  font-family: 'Cairo', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.6; }
select option { background: var(--surface2); }
textarea { resize: vertical; min-height: 80px; }

/* ── Modal ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 16px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.25s;
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end; }

/* ── Pagination ───────────────────────────────────────── */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 16px; }
.page-btn {
  width: 34px; height: 34px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 7px; color: var(--text); font-family:'Cairo';
  font-size: 13px; cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.page-btn:hover, .page-btn.active { background: var(--green); border-color: var(--green); color: #fff; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Misc ─────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

.spinner-overlay {
  position: absolute; inset: 0;
  background: rgba(13,17,23,0.7);
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px; z-index: 10;
}
.spin { display: inline-block; width: 28px; height: 28px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--green); border-radius: 50%;
  animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes fadeUp {
  from { opacity:0; transform:translateY(12px); }
  to   { opacity:1; transform:translateY(0); }
}
.fade-up { animation: fadeUp 0.4s ease forwards; }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-right: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr; }
}
