/* ============================================
   Management System - Styles
   Bilingual (AR/EN) | RTL/LTR Support
   ============================================ */

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --bg: #f1f5f9;
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.05);
}

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

body {
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ============ شاشة التحميل ============ */
.loading-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 9999; gap: 16px;
}
.spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ صفحة المصادقة ============ */
.auth-body {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; position: relative;
}
.auth-container { width: 100%; max-width: 440px; padding: 20px; }
.auth-card {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  padding: 40px 32px;
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .logo-icon { font-size: 48px; }
.auth-logo h1 { font-size: 22px; margin-top: 8px; color: var(--primary); }
.auth-logo p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.auth-form .form-group { margin-bottom: 16px; }
.auth-form label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.auth-form input {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 15px;
  transition: border .2s;
}
.auth-form input:focus { outline: none; border-color: var(--primary); }
.form-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px; font-size: 13px;
}
.checkbox-label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.link-small { color: var(--primary); text-decoration: none; }
.link-small:hover { text-decoration: underline; }
.form-error {
  background: #fef2f2; color: var(--danger);
  padding: 10px 14px; border-radius: 8px;
  font-size: 13px; margin-top: 12px;
}
.form-success {
  background: #f0fdf4; color: var(--success);
  padding: 10px 14px; border-radius: 8px;
  font-size: 13px; margin-top: 12px;
}
.auth-footer {
  text-align: center; margin-top: 22px;
  font-size: 14px; color: var(--text-muted);
}
.auth-footer a { color: var(--primary); font-weight: 600; text-decoration: none; }

.lang-switch {
  position: absolute; top: 20px; inset-inline-end: 20px;
  display: flex; gap: 6px; z-index: 10;
}
.lang-switch button {
  padding: 6px 14px; border: none; border-radius: 20px;
  background: rgba(255,255,255,.25); color: #fff;
  cursor: pointer; font-weight: 600; font-size: 13px;
}
.lang-switch button.active { background: #fff; color: var(--primary); }

/* ============ الأزرار ============ */
.btn {
  padding: 10px 20px; border: none; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .2s; display: inline-flex;
  align-items: center; gap: 6px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon {
  background: none; border: none; cursor: pointer;
  font-size: 16px; padding: 4px 6px; border-radius: 6px;
}
.btn-icon:hover { background: var(--bg); }

/* ============ التطبيق ============ */
.app { display: flex; min-height: 100vh; }

/* ============ الشريط الجانبي ============ */
.sidebar {
  width: 260px; background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex; flex-direction: column;
  position: fixed; inset-block: 0; inset-inline-start: 0;
  z-index: 100; overflow-y: auto;
}
.sidebar-logo {
  padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-logo .logo-icon { font-size: 28px; }
.sidebar-logo h2 { font-size: 16px; color: #fff; }
.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 10px;
  color: var(--sidebar-text); text-decoration: none;
  font-size: 14px; font-weight: 500; transition: all .2s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav a.active { background: var(--primary); color: #fff; }
.sidebar-footer { padding: 16px 12px; border-top: 1px solid rgba(255,255,255,.08); }
.lang-switch-sidebar { display: flex; gap: 6px; margin-bottom: 12px; }
.lang-switch-sidebar button {
  flex: 1; padding: 8px; border: none; border-radius: 8px;
  background: rgba(255,255,255,.1); color: var(--sidebar-text);
  cursor: pointer; font-weight: 600; font-size: 13px;
}
.lang-switch-sidebar button.active { background: var(--primary); color: #fff; }

/* ============ المحتوى ============ */
.main {
  flex: 1; margin-inline-start: 260px;
  padding: 0 28px 28px; min-width: 0;
}
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 0; margin-bottom: 8px;
}
.topbar-welcome h3 { font-size: 20px; }
.topbar-welcome small { color: var(--text-muted); font-size: 13px; }
.today { color: var(--text-muted); font-size: 14px; }

.page { display: none; }
.page[style*="block"] { display: block; animation: fadeIn .3s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============ الإحصائيات ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px; margin-bottom: 24px;
}
.stat-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 20px; display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow); border-inline-start: 4px solid transparent;
}
.stat-icon { font-size: 32px; }
.stat-info h3 { font-size: 28px; font-weight: 700; }
.stat-info p { color: var(--text-muted); font-size: 13px; }
.stat-blue { border-inline-start-color: #3b82f6; }
.stat-purple { border-inline-start-color: #8b5cf6; }
.stat-green { border-inline-start-color: #10b981; }
.stat-orange { border-inline-start-color: #f59e0b; }
.stat-teal { border-inline-start-color: #14b8a6; }
.stat-red { border-inline-start-color: #ef4444; }

/* ============ البطاقات ============ */
.card {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; margin-bottom: 24px;
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.card-header h4 { font-size: 16px; }

/* ============ الجداول ============ */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 13px 18px; text-align: start;
  font-size: 14px; border-bottom: 1px solid var(--border);
}
.table th {
  background: #f8fafc; font-weight: 600;
  color: var(--text-muted); font-size: 13px;
}
.table tr:hover { background: #f8fafc; }
.no-data { text-align: center; color: var(--text-muted); padding: 40px !important; }

/* ============ الشارات ============ */
.badge {
  display: inline-block; padding: 4px 12px;
  border-radius: 20px; font-size: 12px; font-weight: 600;
}
.badge-active, .badge-done, .badge-completed { background: #d1fae5; color: #065f46; }
.badge-paused, .badge-pending, .badge-cancelled { background: #f1f5f9; color: #475569; }
.badge-in_progress { background: #dbeafe; color: #1e40af; }
.badge-review { background: #fef3c7; color: #92400e; }
.badge-archived { background: #f3f4f6; color: #6b7280; }
.badge-priority-low { background: #f0fdf4; color: #166534; }
.badge-priority-medium { background: #fef9c3; color: #854d0e; }
.badge-priority-high { background: #ffedd5; color: #9a3412; }
.badge-priority-urgent { background: #fee2e2; color: #991b1b; }
.badge-role { background: #ede9fe; color: #5b21b6; }

/* ============ سجل النشاط ============ */
.activity-list { padding: 8px 0; max-height: 400px; overflow-y: auto; }
.activity-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px; border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon { font-size: 20px; }
.activity-body { flex: 1; font-size: 14px; }
.activity-body strong { display: block; font-size: 13px; }
.activity-body span { color: var(--text-muted); font-size: 13px; }
.activity-item time { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

/* ============ النماذج ============ */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 14px;
  font-family: inherit; transition: border .2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary);
}
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.settings-form { padding: 22px; max-width: 500px; }

/* ============ النوافذ المنبثقة ============ */
.modal {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 1000;
  align-items: center; justify-content: center; padding: 20px;
}
.modal.show { display: flex; }
.modal-content {
  background: var(--card-bg); border-radius: 16px;
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  animation: modalIn .25s;
}
@keyframes modalIn { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 18px; }
.modal-close {
  background: none; border: none; font-size: 26px;
  cursor: pointer; color: var(--text-muted); line-height: 1;
}
.modal-content form { padding: 24px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ============ الاستجابة ============ */
@media (max-width: 768px) {
  .sidebar { width: 70px; }
  .sidebar-logo h2, .sidebar-nav span, .sidebar-footer .btn { display: none; }
  .sidebar-nav a { justify-content: center; padding: 14px; }
  .main { margin-inline-start: 70px; padding: 0 14px 14px; }
  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .form-row-2 { grid-template-columns: 1fr; }
  .table { display: block; overflow-x: auto; }
}
