:root {
  --bg-deep: #0B1330;
  --bg-elevated: #141B3D;
  --bg-card: #1B2450;
  --accent-1: #12A9FC;
  --accent-2: #5B4FFB;
  --text-primary: #F2F4FF;
  --text-muted: #8C93C2;
  --border: #2A3266;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --font-display: 'Cairo', system-ui, sans-serif;
  --font-body: 'Tajawal', system-ui, sans-serif;
  --font-utility: 'IBM Plex Sans Arabic', system-ui, sans-serif;
}

[data-theme="light"] {
  --bg-deep: #F4F6FC;
  --bg-elevated: #FFFFFF;
  --bg-card: #FFFFFF;
  --accent-1: #0E96E0;
  --accent-2: #5B4FFB;
  --text-primary: #161B33;
  --text-muted: #6B7290;
  --border: #E2E6F5;
}
html[data-theme="light"] body { background: #E4E9F7; }

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; background: #05070F; color: var(--text-primary);
  font-family: var(--font-body); direction: rtl; min-height: 100vh;
}

.logo-mark {
  width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 12px;
  overflow: hidden;
}
.logo-mark:not(.img-mark) {
  background: conic-gradient(var(--accent-1), var(--accent-2), var(--accent-1));
  display: flex; align-items: center; justify-content: center;
}
.logo-mark span { width: 40px; height: 40px; border-radius: 10px; background: var(--bg-deep); }
.logo-mark.img-mark img { width: 100%; height: 100%; object-fit: cover; border-radius: 14px; }
.logo-mark.small { width: 34px; height: 34px; border-radius: 9px; margin: 0; }
.logo-mark.small span { width: 26px; height: 26px; border-radius: 7px; }

/* ---------- شاشة تسجيل الدخول ---------- */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box {
  width: 100%; max-width: 380px; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 32px; text-align: center;
}
.login-box h1 { font-family: var(--font-display); font-size: 24px; margin: 0 0 2px; }
.login-box p { color: var(--text-muted); font-size: 13px; margin: 0 0 22px; }

.field { margin-bottom: 14px; text-align: right; }
.field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; font-family: var(--font-utility); }
.field input, textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-md); border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-primary); font-family: var(--font-body); font-size: 14px;
}
textarea { resize: vertical; }

.btn-primary {
  width: 100%; padding: 13px; border: none; border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2)); color: #1B1330;
  font-family: var(--font-display); font-weight: 800; font-size: 14px; cursor: pointer; margin-top: 4px;
}
.btn-primary:disabled { opacity: 0.6; }

.form-error {
  background: rgba(255,95,109,0.12); border: 1px solid var(--accent-1); color: #FFB3B9;
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 12px; margin-bottom: 12px; display: none;
}
.form-error.show { display: block; }

/* ---------- تخطيط اللوحة ---------- */
.dashboard { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; flex-shrink: 0; background: var(--bg-elevated); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 20px; }
.sidebar-brand strong { font-family: var(--font-display); font-size: 15px; }

.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-link {
  text-align: right; background: none; border: none; color: var(--text-muted); padding: 11px 12px;
  border-radius: var(--radius-sm); font-family: var(--font-body); font-size: 14px; cursor: pointer;
}
.nav-link.active, .nav-link:hover { background: var(--bg-card); color: var(--text-primary); }

.sidebar-footer {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 6px 0;
  border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted);
}
.sidebar-footer button {
  background: none; border: 1px solid var(--border); color: var(--accent-1);
  padding: 5px 12px; border-radius: 999px; font-size: 11px; cursor: pointer;
}

.main-content { flex: 1; padding: 28px 32px; max-width: 1200px; }
.main-content h2 { font-family: var(--font-display); font-size: 20px; margin: 0 0 18px; }
.view-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.view-head input {
  width: 280px; padding: 10px 14px; border-radius: var(--radius-md); border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-primary); font-family: var(--font-body); font-size: 13px;
}

.hint-text { color: var(--text-muted); font-size: 12px; margin: 8px 0 16px; }

/* ---------- بطاقات الإحصائيات ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.stat-card {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px;
}
.stat-card .num { font-family: var(--font-display); font-size: 30px; font-weight: 800; color: var(--accent-2); }
.stat-card .label { color: var(--text-muted); font-size: 12px; margin-top: 6px; font-family: var(--font-utility); }

/* ---------- الجداول ---------- */
.table-wrap { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: right; padding: 12px 16px; background: var(--bg-card); color: var(--text-muted);
  font-family: var(--font-utility); font-weight: 500; font-size: 12px;
}
tbody td { padding: 12px 16px; border-top: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: rgba(255,255,255,0.02); }

.badge { font-size: 11px; padding: 3px 9px; border-radius: 999px; font-family: var(--font-utility); }
.badge.banned { background: rgba(255,95,109,0.15); color: var(--accent-1); }
.badge.active { background: rgba(46,204,113,0.15); color: #2ecc71; }
.badge.admin { background: rgba(255,195,113,0.15); color: var(--accent-2); }
.badge.verified { background: rgba(52,152,219,0.15); color: #5dade2; }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions button {
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-primary);
  padding: 5px 10px; border-radius: var(--radius-sm); font-size: 11px; cursor: pointer; font-family: var(--font-utility);
}
.row-actions button.danger { border-color: var(--accent-1); color: var(--accent-1); }
.row-actions button.success { border-color: #2ecc71; color: #2ecc71; }

.pagination { display: flex; gap: 8px; margin-top: 14px; }
.pagination button {
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-primary);
  padding: 7px 14px; border-radius: var(--radius-sm); font-size: 12px; cursor: pointer;
}
.pagination button.active { background: linear-gradient(90deg, var(--accent-1), var(--accent-2)); color: #1B1330; border: none; }

/* ---------- شبكة المنشورات بلوحة الأدمن ---------- */
.posts-grid-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.admin-post-card {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden;
}
.admin-post-card .thumb { width: 100%; aspect-ratio: 1/1; background: #000; object-fit: cover; display: block; }
.admin-post-card .info { padding: 8px 10px; font-size: 11px; color: var(--text-muted); }
.admin-post-card .info strong { color: var(--text-primary); display: block; font-family: var(--font-display); margin-bottom: 3px; }
.admin-post-card button {
  width: 100%; background: rgba(255,95,109,0.12); border: none; border-top: 1px solid var(--border);
  color: var(--accent-1); padding: 7px; font-size: 11px; cursor: pointer;
}

@media (max-width: 800px) {
  .dashboard { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar nav { flex-direction: row; }
  .sidebar-footer { display: none; }
  .main-content { padding: 18px; }
}
