@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;900&display=swap');

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #ede9fe;
  --secondary: #7c3aed;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --dark: #1a1a2e;
  --gray: #6b7280;
  --light: #f8f9ff;
  --border: #e5e7eb;
  --white: #ffffff;
  --sidebar-w: 260px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'Cairo', sans-serif;
  direction: rtl;
  background: var(--light);
  color: var(--dark);
  line-height: 1.6;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c7c7c7; border-radius: 3px; }

/* ── Sidebar ── */
.sidebar {
  position: fixed; right: 0; top: 0;
  width: var(--sidebar-w); height: 100vh;
  background: linear-gradient(180deg, #312e81 0%, #4f46e5 50%, #7c3aed 100%);
  display: flex; flex-direction: column; z-index: 200;
  overflow-y: auto; transition: transform .3s;
}
.sidebar-logo {
  padding: 22px 18px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.15);
}
.sidebar-logo img { width: 42px; height: 42px; border-radius: 10px; object-fit: cover; }
.sidebar-logo .logo-placeholder {
  width: 42px; height: 42px; border-radius: 10px;
  background: rgba(255,255,255,.2); display: flex; align-items: center;
  justify-content: center; font-size: 22px; flex-shrink: 0;
}
.sidebar-logo-text .name { color: #fff; font-weight: 700; font-size: 15px; }
.sidebar-logo-text .role { color: rgba(255,255,255,.6); font-size: 11px; }

.sidebar-nav { flex: 1; padding: 12px 10px; }
.nav-group-label {
  color: rgba(255,255,255,.45); font-size: 10px;
  text-transform: uppercase; letter-spacing: 1px;
  padding: 10px 10px 4px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 9px; margin-bottom: 2px;
  color: rgba(255,255,255,.8); font-size: 13.5px;
  text-decoration: none; transition: all .15s; position: relative;
}
.nav-link:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav-link.active { background: rgba(255,255,255,.22); color: #fff; font-weight: 700; }
.nav-link i { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-right: auto; background: #f43f5e; color: #fff;
  border-radius: 10px; padding: 1px 8px; font-size: 10px; font-weight: 700;
}

.sidebar-footer {
  padding: 14px; border-top: 1px solid rgba(255,255,255,.15);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.1); border-radius: 10px; padding: 10px 12px;
}
.sidebar-user .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.25); display: flex; align-items: center;
  justify-content: center; font-weight: 700; color: #fff; font-size: 14px; flex-shrink: 0;
}
.sidebar-user .u-name { color: #fff; font-size: 13px; font-weight: 600; }
.sidebar-user .u-role { color: rgba(255,255,255,.6); font-size: 11px; }
.sidebar-user .logout-btn {
  margin-right: auto; color: rgba(255,255,255,.6); font-size: 18px;
  background: none; border: none; cursor: pointer; transition: color .15s;
}
.sidebar-user .logout-btn:hover { color: #fff; }

/* ── Main layout ── */
.main-wrap { margin-right: var(--sidebar-w); min-height: 100vh; }

/* ── Topbar ── */
.topbar {
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 62px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow);
}
.topbar-title { font-size: 18px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-icon-btn {
  width: 38px; height: 38px; border-radius: 9px;
  border: 1px solid var(--border); background: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative; color: var(--gray); font-size: 18px;
  text-decoration: none; transition: all .15s;
}
.topbar-icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.notif-dot {
  position: absolute; top: 7px; right: 7px;
  width: 8px; height: 8px; background: #f43f5e;
  border-radius: 50%; border: 2px solid #fff;
}

/* ── Page content ── */
.page-content { padding: 24px; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.page-header h1 { font-size: 20px; font-weight: 700; }
.breadcrumb { font-size: 12px; color: var(--gray); margin-top: 2px; }
.breadcrumb a { color: var(--primary); text-decoration: none; }

/* ── Stats cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: #fff; border-radius: var(--radius);
  padding: 18px 20px; border: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-icon {
  width: 50px; height: 50px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-num { font-size: 26px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--gray); margin-top: 2px; }
.stat-change { font-size: 11px; font-weight: 600; margin-top: 3px; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }
.text-primary { color: var(--primary); }
.text-gray { color: var(--gray); }

/* ── Card ── */
.card {
  background: #fff; border-radius: var(--radius);
  border: 1px solid var(--border); padding: 22px;
  margin-bottom: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 15px; font-weight: 700; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  background: var(--light); padding: 11px 14px;
  text-align: right; font-weight: 600; color: var(--gray);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td {
  padding: 13px 14px; border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
tbody tr:hover { background: #fafafe; }
tbody tr:last-child td { border-bottom: none; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger  { background: #fee2e2; color: #dc2626; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-info    { background: #dbeafe; color: #1d4ed8; }
.badge-purple  { background: #ede9fe; color: #7c3aed; }
.badge-gray    { background: #f3f4f6; color: #6b7280; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 9px; font-size: 13.5px;
  font-weight: 600; cursor: pointer; border: none;
  transition: all .15s; text-decoration: none; font-family: 'Cairo', sans-serif;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline {
  background: #fff; color: var(--primary);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--primary); background: var(--primary-light); }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 7px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 7px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 13px; font-weight: 600; color: #374151; }
.form-label .req { color: var(--danger); }
.form-control {
  padding: 10px 13px; border: 1.5px solid var(--border);
  border-radius: 9px; font-size: 13.5px; font-family: 'Cairo', sans-serif;
  outline: none; width: 100%; background: #fff; transition: border .15s;
  color: var(--dark);
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.form-control::placeholder { color: #9ca3af; }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { appearance: none; cursor: pointer; }
.form-hint { font-size: 11.5px; color: var(--gray); margin-top: 2px; }
.form-error { font-size: 11.5px; color: var(--danger); margin-top: 2px; }

/* ── Alerts ── */
.alert {
  padding: 12px 16px; border-radius: 9px; font-size: 13.5px;
  margin-bottom: 16px; display: flex; align-items: center; gap: 10px;
}
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Pagination ── */
.pagination {
  display: flex; align-items: center; gap: 6px;
  justify-content: center; margin-top: 20px;
}
.page-btn {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: #fff;
  cursor: pointer; font-size: 13px; text-decoration: none; color: var(--dark);
  transition: all .15s;
}
.page-btn:hover, .page-btn.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

/* ── Toggle switch ── */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle-switch {
  width: 46px; height: 25px; background: #d1d5db; border-radius: 13px;
  cursor: pointer; position: relative; transition: background .2s; flex-shrink: 0;
}
.toggle-switch.on { background: var(--primary); }
.toggle-switch::after {
  content: ''; position: absolute; top: 3px; right: 3px;
  width: 19px; height: 19px; background: #fff; border-radius: 50%;
  transition: right .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-switch.on::after { right: calc(100% - 22px); }

/* ── Progress ── */
.progress { height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 4px; transition: width .5s; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 20px; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; transform: translateY(20px); transition: transform .2s;
}
.modal-overlay.show .modal { transform: translateY(0); }
.modal-header {
  padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: #fff;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: var(--light); cursor: pointer; font-size: 18px;
  display: flex; align-items: center; justify-content: center; color: var(--gray);
}
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ── Avatar ── */
.avatar-circle {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-right: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 0 14px; }
  .page-content { padding: 14px; }
}

/* ── Utilities ── */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 18px; }
.mb-4 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-small { font-size: 12px; }
.fw-bold { font-weight: 700; }
.w-100 { width: 100%; }
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.three-col { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
@media (max-width: 900px) { .two-col, .three-col { grid-template-columns: 1fr; } }

/* ── Login page ── */
.login-page {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #312e81 0%, #4f46e5 60%, #7c3aed 100%);
}
.login-card {
  background: #fff; border-radius: 20px; padding: 40px;
  width: 100%; max-width: 420px; box-shadow: var(--shadow-md);
}
.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo .icon { font-size: 52px; }
.login-logo h1 { font-size: 22px; font-weight: 900; color: var(--primary); margin-top: 8px; }
.login-logo p { font-size: 13px; color: var(--gray); }

/* ── Public site ── */
.public-nav {
  background: var(--primary);
  padding: 0 32px; height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.public-nav .brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.public-nav .brand span { font-size: 17px; font-weight: 700; }
.public-nav ul { display: flex; gap: 4px; list-style: none; }
.public-nav ul a {
  color: rgba(255,255,255,.85); text-decoration: none;
  padding: 8px 14px; border-radius: 8px; font-size: 14px; transition: all .15s;
}
.public-nav ul a:hover { background: rgba(255,255,255,.15); color: #fff; }
.hero-section {
  background: linear-gradient(135deg, #312e81 0%, #4f46e5 60%, #7c3aed 100%);
  padding: 80px 32px; text-align: center; color: #fff;
}
.hero-section h1 { font-size: 38px; font-weight: 900; margin-bottom: 14px; }
.hero-section p { font-size: 17px; opacity: .85; margin-bottom: 28px; }
.services-section { padding: 60px 32px; background: #fff; }
.services-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 20px; margin-top: 24px; }
.service-card { background: var(--light); border-radius: 14px; padding: 24px; text-align: center; border: 1px solid var(--border); transition: all .2s; }
.service-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.service-card .icon { font-size: 36px; margin-bottom: 12px; }
.service-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.service-card p { font-size: 13px; color: var(--gray); }
.section-title { text-align: center; font-size: 26px; font-weight: 900; }
.section-subtitle { text-align: center; color: var(--gray); margin-top: 6px; font-size: 14px; }
