/* =========================================================
   نظام إدارة ومتابعة الرخص والشهادات الحكومية
   ملف التنسيقات الرئيسي
   ========================================================= */

:root{
  --primary: #0d2a5c;
  --primary-dark: #081b3d;
  --primary-light: #1a3c6e;
  --accent: #00b8a9;
  --accent-2: #00838f;
  --success: #2e7d32;
  --warning: #f9a825;
  --danger: #c62828;
  --info: #1976d2;
  --purple: #6a1b9a;
  --gray-50: #f7f9fc;
  --gray-100: #eef1f7;
  --gray-200: #e3e8f0;
  --gray-300: #cdd6e4;
  --gray-500: #8592a6;
  --gray-700: #4b5768;
  --gray-900: #1f2937;
  --sidebar-width: 270px;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow-sm: 0 2px 8px rgba(13,42,92,0.06);
  --shadow-md: 0 6px 20px rgba(13,42,92,0.10);
  --shadow-lg: 0 12px 32px rgba(13,42,92,0.16);
  --font: 'IBM Plex Sans Arabic', 'Tajawal', sans-serif;
}

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

html{ scroll-behavior: smooth; }

body{
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-900);
  direction: rtl;
  overflow-x: hidden;
}

a{ text-decoration:none; color:inherit; }
ul{ list-style:none; }
button{ font-family: inherit; cursor:pointer; border:none; background:none; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar{ width:8px; height:8px; }
::-webkit-scrollbar-track{ background: var(--gray-100); }
::-webkit-scrollbar-thumb{ background: var(--gray-300); border-radius:10px; }
::-webkit-scrollbar-thumb:hover{ background: var(--gray-500); }

/* ============ Layout ============ */
.app-shell{
  display:flex;
  min-height:100vh;
}

/* ============ Sidebar ============ */
.sidebar{
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  color:#fff;
  position:fixed;
  top:0; right:0; bottom:0;
  overflow-y:auto;
  z-index:100;
  transition: transform .3s ease;
  box-shadow: 4px 0 24px rgba(0,0,0,0.15);
}

.sidebar-brand{
  display:flex;
  align-items:center;
  gap:12px;
  padding:22px 20px;
  border-bottom:1px solid rgba(255,255,255,0.12);
}
.sidebar-brand .brand-icon{
  width:46px; height:46px;
  border-radius:12px;
  background: rgba(255,255,255,0.12);
  display:flex; align-items:center; justify-content:center;
  font-size:22px;
  color:#4dd0c9;
  flex-shrink:0;
}
.sidebar-brand h1{
  font-size:15px;
  font-weight:700;
  line-height:1.4;
}
.sidebar-brand span{
  font-size:11px;
  color:#a9c2e8;
  display:block;
  margin-top:2px;
}

.sidebar-nav{ padding:14px 12px 30px; }
.sidebar-section-title{
  font-size:11px;
  color:#7f9cd0;
  padding:14px 10px 6px;
  text-transform:uppercase;
  letter-spacing:.5px;
  font-weight:700;
}
.sidebar-nav a{
  display:flex;
  align-items:center;
  gap:12px;
  padding:11px 14px;
  border-radius:10px;
  color:#d3ddf0;
  font-size:14px;
  font-weight:500;
  margin-bottom:3px;
  transition: all .2s;
  position:relative;
}
.sidebar-nav a i{
  width:20px;
  text-align:center;
  font-size:15px;
  color:#8fb1e8;
  transition: color .2s;
}
.sidebar-nav a:hover{
  background: rgba(255,255,255,0.08);
  color:#fff;
}
.sidebar-nav a.active{
  background: linear-gradient(90deg, rgba(0,184,169,0.25), rgba(0,184,169,0.05));
  color:#fff;
  box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar-nav a.active i{ color: var(--accent); }
.nav-badge{
  margin-right:auto;
  background: rgba(255,255,255,0.15);
  font-size:10px;
  padding:2px 7px;
  border-radius:20px;
  color:#fff;
}
.nav-badge.danger{ background: var(--danger); }
.nav-badge.warning{ background: var(--warning); color:#1f2937; }

/* ============ Main content ============ */
.main-content{
  margin-right: var(--sidebar-width);
  flex:1;
  min-height:100vh;
  width: calc(100% - var(--sidebar-width));
}

.topbar{
  background:#fff;
  border-bottom:1px solid var(--gray-200);
  padding:14px 28px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  position:sticky;
  top:0;
  z-index:50;
  gap:16px;
}
.topbar h2{
  font-size:19px;
  font-weight:700;
  color: var(--gray-900);
}
.topbar .breadcrumb{
  font-size:12.5px;
  color: var(--gray-500);
  margin-top:2px;
}
.topbar-right{ display:flex; align-items:center; gap:14px; }
.topbar-search{
  display:flex;
  align-items:center;
  background: var(--gray-100);
  border-radius:10px;
  padding:8px 14px;
  gap:8px;
  min-width:230px;
}
.topbar-search input{
  border:none; background:none; outline:none; font-family:inherit; font-size:13.5px; width:100%;
}
.topbar-icon-btn{
  width:38px; height:38px;
  border-radius:10px;
  background: var(--gray-100);
  display:flex; align-items:center; justify-content:center;
  color: var(--gray-700);
  position:relative;
  font-size:15px;
}
.topbar-icon-btn .dot{
  position:absolute; top:6px; left:7px;
  width:8px; height:8px; border-radius:50%;
  background: var(--danger);
  border:2px solid #fff;
}
.menu-toggle{
  display:none;
  font-size:20px;
  color: var(--gray-700);
}
.user-chip{
  display:flex; align-items:center; gap:10px;
  padding:6px 12px 6px 6px;
  background: var(--gray-100);
  border-radius:30px;
}
.user-chip img, .user-chip .avatar{
  width:32px; height:32px; border-radius:50%;
  background: var(--primary);
  color:#fff; display:flex; align-items:center; justify-content:center;
  font-size:13px; font-weight:700;
}
.user-chip .u-name{ font-size:12.5px; font-weight:600; }
.user-chip .u-role{ font-size:10.5px; color: var(--gray-500); }

.page-body{ padding:26px 28px 50px; }

/* ============ Cards ============ */
.card{
  background:#fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding:22px;
  border:1px solid var(--gray-100);
}
.card-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:18px;
  gap:10px;
  flex-wrap:wrap;
}
.card-header h3{ font-size:16px; font-weight:700; display:flex; align-items:center; gap:8px;}
.card-header h3 i{ color: var(--accent-2); }
.card-header .card-sub{ font-size:12px; color:var(--gray-500); margin-top:2px; }

.section-title{
  display:flex;
  align-items:center;
  gap:10px;
  margin: 8px 0 18px;
}
.section-title .num-badge{
  width:30px; height:30px;
  border-radius:9px;
  background: var(--primary);
  color:#fff;
  display:flex; align-items:center; justify-content:center;
  font-size:13px; font-weight:700;
}
.section-title h2{ font-size:18px; font-weight:800; }
.section-title p{ font-size:12.5px; color:var(--gray-500); }

/* ============ Grid helpers ============ */
.grid{ display:grid; gap:18px; }
.grid-2{ grid-template-columns: repeat(2,1fr); }
.grid-3{ grid-template-columns: repeat(3,1fr); }
.grid-4{ grid-template-columns: repeat(4,1fr); }
.grid-6{ grid-template-columns: repeat(6,1fr); }
@media (max-width:1200px){ .grid-4{grid-template-columns:repeat(2,1fr);} .grid-6{grid-template-columns:repeat(3,1fr);} }
@media (max-width:820px){ .grid-2,.grid-3,.grid-4,.grid-6{grid-template-columns:1fr 1fr;} }
@media (max-width:560px){ .grid-2,.grid-3,.grid-4,.grid-6{grid-template-columns:1fr;} }

/* ============ KPI cards ============ */
.kpi-card{
  background:#fff;
  border-radius: var(--radius);
  padding:18px 20px;
  box-shadow: var(--shadow-sm);
  border:1px solid var(--gray-100);
  position:relative;
  overflow:hidden;
  transition: transform .2s, box-shadow .2s;
}
.kpi-card:hover{ transform: translateY(-3px); box-shadow: var(--shadow-md); }
.kpi-card .kpi-top{ display:flex; align-items:center; justify-content:space-between; margin-bottom:10px;}
.kpi-card .kpi-icon{
  width:42px; height:42px; border-radius:11px;
  display:flex; align-items:center; justify-content:center;
  font-size:18px; color:#fff;
}
.kpi-card .kpi-value{ font-size:28px; font-weight:800; line-height:1; }
.kpi-card .kpi-label{ font-size:12.5px; color:var(--gray-500); margin-top:6px; font-weight:600; }
.kpi-card .kpi-trend{ font-size:11px; margin-top:8px; display:flex; align-items:center; gap:4px; font-weight:700; }
.kpi-trend.up{ color: var(--success); }
.kpi-trend.down{ color: var(--danger); }

.bg-blue{ background: linear-gradient(135deg,#1976d2,#0d47a1); }
.bg-green{ background: linear-gradient(135deg,#43a047,#2e7d32); }
.bg-orange{ background: linear-gradient(135deg,#fb8c00,#e65100); }
.bg-red{ background: linear-gradient(135deg,#e53935,#b71c1c); }
.bg-purple{ background: linear-gradient(135deg,#8e24aa,#4a148c); }
.bg-teal{ background: linear-gradient(135deg,#00acc1,#00695c); }
.bg-yellow{ background: linear-gradient(135deg,#fdd835,#f9a825); }

/* ============ Badges / status pills ============ */
.badge{
  display:inline-flex;
  align-items:center;
  gap:5px;
  font-size:11.5px;
  font-weight:700;
  padding:4px 11px;
  border-radius:20px;
  white-space:nowrap;
}
.badge i{ font-size:9px; }
.badge-success{ background:#e6f4ea; color:var(--success); }
.badge-warning{ background:#fff6e0; color:#a56800; }
.badge-danger{ background:#fdeaea; color:var(--danger); }
.badge-info{ background:#e5f1fb; color:var(--info); }
.badge-gray{ background:var(--gray-100); color:var(--gray-700); }
.badge-purple{ background:#f1e3f9; color:var(--purple); }
.badge-teal{ background:#e0f5f3; color:var(--accent-2); }

/* ============ Buttons ============ */
.btn{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:10px 18px;
  border-radius:10px;
  font-size:13.5px;
  font-weight:700;
  transition: all .2s;
  white-space:nowrap;
}
.btn-primary{ background: var(--primary); color:#fff; }
.btn-primary:hover{ background: var(--primary-dark); }
.btn-accent{ background: var(--accent); color:#fff; }
.btn-accent:hover{ background: var(--accent-2); }
.btn-outline{ background:#fff; border:1.5px solid var(--gray-200); color:var(--gray-700); }
.btn-outline:hover{ border-color: var(--primary); color: var(--primary); }
.btn-danger{ background:#fdeaea; color:var(--danger); }
.btn-sm{ padding:6px 12px; font-size:12px; }
.btn-icon{ width:36px; height:36px; border-radius:9px; display:flex; align-items:center; justify-content:center; background:var(--gray-100); color:var(--gray-700); }
.btn-icon:hover{ background: var(--gray-200); }

/* ============ Table ============ */
.table-wrap{ overflow-x:auto; }
table.data-table{ width:100%; border-collapse:collapse; font-size:13.5px; }
table.data-table thead th{
  text-align:right;
  padding:12px 14px;
  background: var(--gray-50);
  color: var(--gray-700);
  font-weight:700;
  font-size:12.5px;
  border-bottom:2px solid var(--gray-200);
  white-space:nowrap;
}
table.data-table tbody td{
  padding:13px 14px;
  border-bottom:1px solid var(--gray-100);
  vertical-align:middle;
}
table.data-table tbody tr{ transition: background .15s; }
table.data-table tbody tr:hover{ background: var(--gray-50); }
table.data-table tbody tr:last-child td{ border-bottom:none; }

.progress-bar{ height:8px; border-radius:6px; background:var(--gray-100); overflow:hidden; }
.progress-bar span{ display:block; height:100%; border-radius:6px; }

/* ============ Forms ============ */
.form-group{ margin-bottom:16px; }
.form-group label{ display:block; font-size:13px; font-weight:700; margin-bottom:7px; color:var(--gray-700); }
.form-control{
  width:100%;
  padding:10px 14px;
  border:1.5px solid var(--gray-200);
  border-radius:10px;
  font-family:inherit;
  font-size:13.5px;
  outline:none;
  transition: border-color .2s;
  background:#fff;
}
.form-control:focus{ border-color: var(--accent); }
textarea.form-control{ resize:vertical; min-height:80px; }

/* ============ Modal ============ */
.modal-overlay{
  position:fixed; inset:0; background: rgba(15,25,45,0.55);
  display:none; align-items:center; justify-content:center;
  z-index:1000; padding:20px;
  backdrop-filter: blur(2px);
}
.modal-overlay.open{ display:flex; }
.modal-box{
  background:#fff; border-radius:16px; width:100%; max-width:560px;
  max-height:90vh; overflow-y:auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn .25s ease;
}
@keyframes modalIn{ from{ opacity:0; transform:translateY(20px);} to{opacity:1; transform:translateY(0);} }
.modal-head{ display:flex; align-items:center; justify-content:space-between; padding:18px 22px; border-bottom:1px solid var(--gray-100); }
.modal-head h3{ font-size:16px; font-weight:800; }
.modal-body{ padding:22px; }
.modal-foot{ padding:16px 22px; border-top:1px solid var(--gray-100); display:flex; justify-content:flex-end; gap:10px; }
.modal-close{ font-size:18px; color:var(--gray-500); }

/* ============ Toast ============ */
.toast-wrap{ position:fixed; bottom:24px; left:24px; z-index:2000; display:flex; flex-direction:column; gap:10px; }
.toast{
  background:#1f2937; color:#fff; padding:13px 18px; border-radius:10px;
  font-size:13.5px; box-shadow: var(--shadow-lg); display:flex; align-items:center; gap:10px;
  animation: toastIn .25s ease;
}
.toast i{ color: var(--accent); }
.toast.error i{ color: var(--danger); }
@keyframes toastIn{ from{opacity:0; transform:translateY(10px);} to{opacity:1; transform:translateY(0);} }

/* ============ Timeline / workflow steps ============ */
.workflow-steps{ display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:8px; }
.workflow-step{ flex:1; min-width:110px; text-align:center; position:relative; }
.workflow-step .wf-circle{
  width:52px; height:52px; border-radius:50%;
  background: var(--gray-100); color: var(--gray-500);
  display:flex; align-items:center; justify-content:center; font-size:19px;
  margin:0 auto 8px; border:3px solid #fff; box-shadow: 0 0 0 3px var(--gray-200);
  transition: all .2s;
}
.workflow-step.done .wf-circle{ background: var(--success); color:#fff; box-shadow:0 0 0 3px #c8e6c9; }
.workflow-step.active .wf-circle{ background: var(--accent); color:#fff; box-shadow:0 0 0 3px #b2ebe6; animation: pulse 1.6s infinite; }
@keyframes pulse{ 0%{box-shadow:0 0 0 0 rgba(0,184,169,.5);} 70%{box-shadow:0 0 0 8px rgba(0,184,169,0);} 100%{box-shadow:0 0 0 0 rgba(0,184,169,0);} }
.workflow-step .wf-label{ font-size:12px; font-weight:700; color: var(--gray-700); }
.workflow-step .wf-sub{ font-size:10.5px; color:var(--gray-500); }
.workflow-connector{ flex:0.5; height:3px; background: var(--gray-200); margin-top:-30px; border-radius:2px; }
.workflow-connector.done{ background: var(--success); }

/* ============ Empty state ============ */
.empty-state{ text-align:center; padding:50px 20px; color: var(--gray-500); }
.empty-state i{ font-size:40px; margin-bottom:12px; color: var(--gray-300); }

/* ============ Chip / Filter tabs ============ */
.filter-tabs{ display:flex; gap:8px; flex-wrap:wrap; }
.filter-tab{
  padding:8px 16px; border-radius:20px; font-size:12.5px; font-weight:700;
  background: var(--gray-100); color:var(--gray-700); border:1.5px solid transparent; cursor:pointer;
}
.filter-tab.active{ background: var(--primary); color:#fff; }

/* ============ Utility ============ */
.text-muted{ color: var(--gray-500); }
.flex{ display:flex; }
.flex-between{ display:flex; align-items:center; justify-content:space-between; }
.flex-center{ display:flex; align-items:center; justify-content:center; }
.gap-8{ gap:8px; } .gap-10{gap:10px;} .gap-14{gap:14px;}
.mt-10{margin-top:10px;} .mt-16{margin-top:16px;} .mt-20{margin-top:20px;}
.mb-10{margin-bottom:10px;} .mb-16{margin-bottom:16px;} .mb-20{margin-bottom:20px;}
.w-full{ width:100%; }
.text-center{ text-align:center; }
.pointer{ cursor:pointer; }
.overflow-x{ overflow-x:auto; }
.chart-box{ position:relative; width:100%; }

/* ============ Responsive sidebar ============ */
.sidebar-overlay{ position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:99; display:none; }
.sidebar-overlay.open{ display:block; }

@media (max-width: 1024px){
  .sidebar{ transform: translateX(280px); }
  .sidebar.open{ transform: translateX(0); }
  .main-content{ margin-right:0; width:100%; }
  .menu-toggle{ display:flex; }
  .topbar-search{ display:none; }
}

@media (max-width: 640px){
  .page-body{ padding:16px; }
  .topbar{ padding:12px 16px; }
  .user-chip .u-name, .user-chip .u-role{ display:none; }
}

/* ============ Notice / read-only banner ============ */
.notice-banner{
  display:flex;
  align-items:flex-start;
  gap:14px;
  background: linear-gradient(90deg, #fff8e1, #fffde7);
  border: 1.5px solid #ffe082;
  border-radius: var(--radius);
  padding:16px 20px;
  margin-bottom:20px;
}
.notice-banner .nb-icon{
  width:38px; height:38px; border-radius:10px; flex-shrink:0;
  background:#ffb300; color:#fff; display:flex; align-items:center; justify-content:center; font-size:16px;
}
.notice-banner strong{ font-size:13.5px; color:#5d4200; }
.notice-banner p{ font-size:12.5px; color:#6d5300; margin-top:4px; line-height:1.7; }

.sidebar-brand-logo{
  width:44px; height:44px; border-radius:10px; object-fit:contain;
  background:#fff; padding:4px; flex-shrink:0;
}
.company-tag{
  margin-top:6px; font-size:10.5px; color:#4dd0c9; font-weight:700;
  display:flex; align-items:center; gap:5px;
}

/* print */
@media print{
  .sidebar, .topbar, .no-print{ display:none !important; }
  .main-content{ margin-right:0; }
}
