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

:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --sidebar-bg: #0b1530;
  --sidebar-bg-active: #16234a;
  --sidebar-text: #aab4d4;
  --sidebar-text-active: #ffffff;
  --primary: #2457e8;
  --primary-dark: #1a3fb8;
  --primary-light: #eef2ff;
  --accent: #17b2e0;
  --text: #16192b;
  --muted: #6b7280;
  --border: #e4e7ee;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== الهيكل العام: سايد بار + محتوى ===== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.5rem 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar .brand img { width: 34px; height: 34px; object-fit: contain; }
.sidebar .brand .brand-text { font-weight: 700; font-size: 1.05rem; color: #fff; line-height: 1.3; }
.sidebar .brand .brand-text small { display: block; font-weight: 400; font-size: 0.7rem; color: var(--sidebar-text); }

.sidebar nav { flex: 1; padding: 0.75rem 0.75rem; display: flex; flex-direction: column; gap: 0.2rem; }

.sidebar nav .nav-section-label {
  font-size: 0.72rem;
  color: #5c6690;
  padding: 0.9rem 0.75rem 0.3rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.62rem 0.85rem;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar nav a .icon { width: 18px; text-align: center; opacity: 0.9; }

.sidebar .guide-link { border: 1px solid rgba(255,255,255,0.12); }

.sidebar .user-box {
  margin: 0.75rem;
  padding: 0.85rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 1rem;
}
.sidebar .user-box .name { color: #fff; font-weight: 600; font-size: 0.88rem; }
.sidebar .user-box .role { font-size: 0.72rem; margin-top: 0.15rem; }
.sidebar .user-box form { margin-top: 0.6rem; }
.sidebar .user-box button {
  width: 100%;
  background: rgba(255,255,255,0.08);
  color: #dfe4f5;
  border: none;
  padding: 0.5rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}
.sidebar .user-box button:hover { background: rgba(255,255,255,0.16); }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.75rem;
  display: none;
}

.main-content { flex: 1; padding: 0; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge.role-manager { background: #fde68a; color: #92400e; }
.badge.role-admin { background: #c7d2fe; color: #3730a3; }
.badge.role-user { background: #d1fae5; color: #065f46; }

.container { max-width: 980px; margin: 0 auto; padding: 2rem 1.75rem; }
.container.narrow { max-width: 460px; }

/* شاشات الدخول/التسجيل بدون سايد بار */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #16234a 0%, #0b1530 55%, #070c1c 100%);
  padding: 1.5rem;
}
.auth-page .auth-card {
  background: var(--card);
  border-radius: 18px;
  padding: 2.5rem 2.25rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 30px 60px rgba(6, 12, 30, 0.35);
}
.auth-page .auth-logo { display: flex; justify-content: center; margin-bottom: 1.5rem; }
.auth-page .auth-logo img { max-width: 220px; height: auto; }
.auth-page h1 { text-align: center; font-size: 1.25rem; margin-bottom: 0.35rem; }
.auth-page .auth-subtitle { text-align: center; color: var(--muted); font-size: 0.88rem; margin-bottom: 1.5rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.6rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.4rem; margin: 0 0 0.3rem; }
.page-header p { color: var(--muted); font-size: 0.9rem; margin: 0; }

h1 { font-size: 1.4rem; margin-top: 0; font-weight: 700; }
h2 { font-size: 1.08rem; font-weight: 700; margin-top: 0; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-box { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.15rem; text-align: center; }
.stat-box .value { font-size: 1.9rem; font-weight: 800; color: var(--primary); }
.stat-box .label { color: var(--muted); font-size: 0.83rem; margin-top: 0.2rem; }

label { display: block; margin: 0.9rem 0 0.35rem; font-weight: 600; font-size: 0.88rem; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: 0.62rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 0.93rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-light); border-color: var(--primary); }
textarea { min-height: 100px; resize: vertical; }
small.hint { display: block; color: var(--muted); margin-top: 0.35rem; font-size: 0.79rem; line-height: 1.5; }

.suggestion-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.5rem; }
.suggestion-chips .suggestion-label { font-size: 0.78rem; color: var(--muted); width: 100%; margin-bottom: 0.15rem; }
.suggestion-chips .chip {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.79rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.suggestion-chips .chip:hover { background: #dfe6fd; border-color: var(--primary-light); }
.suggestion-chips .chip:active { transform: scale(0.97); }
code { background: #f1f3f9; padding: 0.1rem 0.4rem; border-radius: 4px; font-size: 0.85em; }

.btn {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border-radius: 9px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn.secondary { background: #eef1f7; color: var(--text); }
.btn.secondary:hover { background: #e2e6f0; }
.btn.danger { background: var(--danger); }
.btn.success { background: var(--success); }
.btn.small { padding: 0.32rem 0.75rem; font-size: 0.8rem; }
.btn.block { display: block; width: 100%; text-align: center; }

.alert { padding: 0.8rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: 0.88rem; line-height: 1.6; }
.alert.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert.success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert.info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: 0.65rem 0.5rem; border-bottom: 1px solid var(--border); text-align: right; }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }

.status { padding: 0.15rem 0.55rem; border-radius: 6px; font-size: 0.76rem; font-weight: 700; }
.status.active, .status.verified, .status.sent { background: #ecfdf3; color: #067647; }
.status.paused, .status.pending, .status.skipped { background: #fffaeb; color: #b54708; }
.status.rejected, .status.failed { background: #fef3f2; color: #b42318; }

.empty { color: var(--muted); text-align: center; padding: 2.2rem 0; font-size: 0.9rem; }

.actions-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }

.step-card { display: flex; gap: 1rem; align-items: flex-start; }
.step-card .step-num {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.95rem;
}
.step-card .step-body h3 { margin: 0 0 0.35rem; font-size: 1rem; }
.step-card .step-body p, .step-card .step-body ul { color: #3a4051; font-size: 0.88rem; line-height: 1.8; margin: 0.35rem 0; }
.step-card .step-body ul { padding-inline-start: 1.3rem; }
.step-card + .step-card { margin-top: 1.4rem; padding-top: 1.4rem; border-top: 1px dashed var(--border); }

footer.page-footer { text-align: center; color: var(--muted); font-size: 0.78rem; padding: 2rem 1.75rem; }

/* ===== صفحات قانونية عامة (سياسة الخصوصية / الشروط / تعليمات حذف البيانات) - ثنائية اللغة ===== */
/* body تفرض rtl افتراضيًا لباقي المنصة العربية؛ الصفحات القانونية بالإنجليزية (اللغة الافتراضية لها) تُلغي ذلك محليًا */
.legal-page.ltr { direction: ltr; text-align: left; }
.legal-page.rtl { direction: rtl; text-align: right; }
.legal-page { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.legal-topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.legal-brand { display: flex; align-items: center; gap: 0.55rem; font-weight: 700; color: var(--text); }
.legal-brand:hover { text-decoration: none; }
.legal-brand img { width: 28px; height: 28px; }
.legal-topbar-actions { display: flex; align-items: center; gap: 1rem; }
.lang-switch { display: flex; align-items: center; gap: 0.4rem; font-size: 0.82rem; color: var(--muted); }
.lang-switch a { color: var(--muted); padding: 0.2rem 0.45rem; border-radius: 6px; }
.lang-switch a:hover { text-decoration: none; background: var(--primary-light); }
.lang-switch a.active { color: var(--primary); font-weight: 700; background: var(--primary-light); }
.lang-switch span { color: var(--border); }

.legal-article {
  flex: 1;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 1.75rem 3rem;
}
.legal-article h1 { font-size: 1.6rem; margin-bottom: 0.4rem; }
.legal-article .legal-updated { color: var(--muted); font-size: 0.85rem; margin-bottom: 2rem; }
.legal-article h2 { font-size: 1.1rem; margin-top: 2.2rem; margin-bottom: 0.6rem; padding-top: 1.4rem; border-top: 1px solid var(--border); }
.legal-article h2:first-of-type { border-top: none; padding-top: 0; margin-top: 1.5rem; }
.legal-article p, .legal-article li { font-size: 0.92rem; line-height: 1.95; color: #333a4d; }
.legal-article ul, .legal-article ol { padding-inline-start: 1.4rem; margin: 0.6rem 0; }
.legal-article li { margin-bottom: 0.4rem; }
.legal-article strong { color: var(--text); }
.legal-article .toc { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.4rem; margin-bottom: 1.5rem; }
.legal-article .toc-title { font-weight: 700; font-size: 0.88rem; margin-bottom: 0.55rem; }
.legal-article .toc ol { margin: 0; padding-inline-start: 1.2rem; }
.legal-article .toc li { font-size: 0.85rem; margin-bottom: 0.3rem; }
.legal-article .toc a { color: var(--text); }

/* استجابة للشاشات الصغيرة */
@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; }
  .sidebar nav { flex-direction: row; overflow-x: auto; }
  .sidebar .user-box { display: none; }
  .container { padding: 1.25rem 1rem; }
}
