/* ═══════════════════════════════════════════
   THEME.CSS — طبقة التحديث البصري (تُحمَّل أخيراً)
   خط عربي أوضح + بطاقات وجداول محسّنة + موبايل
═══════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&display=swap');

:root {
  --font-main: 'IBM Plex Sans Arabic', 'Cairo', system-ui, sans-serif;
  --slate-100: #f4f6fa;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.08);
  --shadow-md: 0 6px 20px rgba(15,23,42,.08), 0 2px 6px rgba(15,23,42,.05);
  --radius-md: 12px;
  --radius-lg: 18px;
}

html { font-size: 14.5px; }
body { letter-spacing: 0; }

/* ── أيقونات SVG ── */
.nav-icon, .logo-icon { display: inline-flex; align-items: center; justify-content: center; }
.nav-icon svg { width: 19px; height: 19px; }
.logo-icon svg { width: 30px; height: 30px; }

/* ── SIDEBAR ── */
.sidebar {
  background: linear-gradient(180deg, #0b1226 0%, #0a0f1e 55%, #0d1430 100%);
}
.nav-item {
  border-radius: 10px;
  margin: 2px 10px;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}
.nav-item:hover { transform: translateX(-2px); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(245,158,11,.18), rgba(245,158,11,.05));
  box-shadow: inset 3px 0 0 var(--amber-400);
}

/* ── CARDS ── */
.card {
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
  overflow: hidden;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  background: linear-gradient(180deg, #fff, #fafbfe);
  border-bottom: 1px solid var(--slate-200);
}
.card-title { letter-spacing: -.1px; }

/* ── KPI ── */
.kpi-card {
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120px 60px at 85% -10%, color-mix(in srgb, var(--kpi-accent, var(--navy-600)) 14%, transparent), transparent),
    #fff;
}
.kpi-value { font-variant-numeric: tabular-nums; }

/* ── TABLES ── */
.table-wrapper { border-radius: var(--radius-md); border: 1px solid var(--slate-200); }
.table-wrapper table { border-collapse: separate; border-spacing: 0; width: 100%; }
.table-wrapper thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--navy-900); color: #e6ebf5;
  font-weight: 600; font-size: 12.5px;
  padding: 10px 12px;
}
.table-wrapper tbody tr:nth-child(even) { background: #f8fafd; }
.table-wrapper tbody tr:hover { background: #eef4ff; }
.table-wrapper td { padding: 9px 12px; border-bottom: 1px solid var(--slate-200); }
.table-wrapper tfoot td { background: var(--slate-100); font-weight: 700; }

/* ── BUTTONS ── */
.btn { border-radius: 10px; font-weight: 600; }
.btn-primary {
  background: linear-gradient(135deg, var(--amber-500), #e8890b);
  box-shadow: 0 2px 8px rgba(245,158,11,.35);
  border: none; color: #1a1206;
}
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }

/* ── BADGES ── */
.badge { border-radius: 999px; font-weight: 600; padding: 3px 10px; }

/* ── FORMS ── */
.form-control { border-radius: 10px; }
.form-control:focus { box-shadow: 0 0 0 3px rgba(245,158,11,.18); border-color: var(--amber-400); }

/* ── MODALS ── */
.modal { border-radius: var(--radius-lg); }

/* ── MOBILE (≤ 860px): الشريط الجانبي يتحول لشريط سفلي قابل للتمرير ── */
@media (max-width: 860px) {
  body { flex-direction: column; }
  .sidebar {
    position: fixed; inset: auto 0 0 0;
    width: 100%; min-height: 0; height: 62px;
    flex-direction: row; align-items: center;
    border-left: none; border-top: 1px solid rgba(255,255,255,.08);
    padding: 0 6px;
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar-logo, .sidebar-footer, .nav-divider, .db-status { display: none !important; }
  .sidebar-nav {
    display: flex !important; flex-direction: row !important;
    align-items: center; gap: 2px; overflow: visible; padding: 0 !important;
  }
  .nav-item {
    flex-direction: column; gap: 3px;
    font-size: 10px; padding: 6px 10px; margin: 0;
    min-width: 64px; text-align: center; white-space: nowrap;
  }
  .nav-item:hover { transform: none; }
  .nav-item.active { box-shadow: inset 0 -3px 0 var(--amber-400); background: rgba(245,158,11,.12); }
  .nav-icon svg { width: 20px; height: 20px; }

  .main-content { margin-right: 0 !important; padding-bottom: 78px !important; width: 100% !important; }
  #pageContainer { padding: 12px !important; }

  .page-header { flex-direction: column; align-items: stretch; gap: 10px; }
  .page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; }
  .form-row { grid-template-columns: 1fr !important; }
  .table-wrapper { overflow-x: auto; }
  .table-wrapper table { min-width: 640px; }
  .modal { max-width: 94vw; max-height: 88vh; overflow-y: auto; }
}

/* ── PRINT POLISH ── */
@media print {
  .table-wrapper, .card, .kpi-card { box-shadow: none !important; border-color: #bbb !important; }
  .table-wrapper thead th { background: #1e2d4a !important; color: #fff !important; }
  .table-wrapper tbody tr:nth-child(even) { background: #f3f4f6 !important; }
  .report-print-header { display: block !important; }
}

/* ترويسة الطباعة الموحدة للتقارير والكشوف */
.report-print-header { display: none; text-align: center; margin-bottom: 14px; }
.report-print-header .rph-company { font-size: 17px; font-weight: 800; }
.report-print-header .rph-title   { font-size: 14px; font-weight: 700; margin-top: 2px; }
.report-print-header .rph-meta    { font-size: 11px; color: #555; margin-top: 2px; }
.report-print-header hr { border: none; border-top: 2px solid #1e2d4a; margin-top: 8px; }
