/* =========================================================
   مركز وكلاء الذكاء الاصطناعي - القالب العام (RTL / Dark)
   ========================================================= */

:root {
  --bg: #0b0f14;
  --bg-alt: #10151c;
  --panel: #151b23;
  --panel-2: #1a212b;
  --border: #232b36;
  --text: #e7edf3;
  --text-muted: #8b98a9;
  --accent: #2dd4bf;
  --accent-2: #22c1e8;
  --accent-soft: rgba(45, 212, 191, 0.12);
  --danger: #f0576b;
  --danger-soft: rgba(240, 87, 107, 0.12);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.12);
  --warning: #f2b84b;
  --warning-soft: rgba(242, 184, 75, 0.12);
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

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

a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }

/* ---------- تخطيط عام ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--bg-alt);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 22px;
}

.sidebar-brand .logo-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #04201c;
}

.sidebar-brand .brand-name {
  font-weight: 700;
  font-size: 15px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
}

.sidebar nav a:hover {
  background: var(--panel);
  color: var(--text);
}

.sidebar nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.sidebar .nav-section-title {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 16px 12px 6px;
}

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

.topbar {
  height: 62px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .page-title {
  font-size: 17px;
  font-weight: 700;
}

.topbar .user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--panel-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid var(--border);
}

.role-badge {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(45,212,191,.25);
}

.content {
  padding: 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- بطاقات ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card + .card { margin-top: 18px; }

.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 900px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat-card .stat-label {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-size: 26px;
  font-weight: 700;
}

.stat-card .stat-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items:center; justify-content:center;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 10px;
  font-size: 18px;
}

/* ---------- عناوين الصفحات ---------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 20px;
  margin: 0 0 4px;
}

.page-header p {
  color: var(--text-muted);
  margin: 0;
  font-size: 13.5px;
}

/* ---------- أزرار ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  transition: all .15s;
}

.btn:hover { border-color: var(--accent); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04201c;
  border: none;
}

.btn-primary:hover { filter: brightness(1.08); }

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(240,87,107,.3);
}

.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- نماذج ---------- */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.form-control, select.form-control, textarea.form-control {
  width: 100%;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea.form-control { resize: vertical; min-height: 90px; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row > .form-group { flex: 1; min-width: 200px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }

/* ---------- جداول ---------- */
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.8px;
}

.data-table th {
  text-align: right;
  color: var(--text-muted);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background: rgba(255,255,255,0.02); }

/* ---------- شارات الحالة ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--panel-2); color: var(--text-muted); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- تنبيهات ---------- */
.alert {
  padding: 12px 16px;
  border-radius: 9px;
  font-size: 13.8px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.alert-success { background: var(--success-soft); color: var(--success); border-color: rgba(52,211,153,.25); }
.alert-danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(240,87,107,.25); }
.alert-info { background: var(--accent-soft); color: var(--accent); border-color: rgba(45,212,191,.25); }

.muted { color: var(--text-muted); }
.text-center { text-align: center; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 34px; margin-bottom: 10px; }

/* ---------- صفحة تسجيل الدخول ---------- */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(circle at 30% 20%, #10221f 0%, var(--bg) 60%);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
}

.auth-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  margin: 0 auto 18px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
}

.auth-card h1 {
  text-align: center;
  font-size: 19px;
  margin: 0 0 6px;
}

.auth-card .muted { text-align: center; margin-bottom: 22px; font-size: 13.5px; }

/* ---------- محادثة الوكيل ---------- */
.chat-wrap {
  display: flex;
  flex-direction: column;
  height: 70vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg { max-width: 75%; padding: 11px 15px; border-radius: 14px; font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.msg-user { align-self: flex-start; background: var(--accent-soft); color: var(--text); border-bottom-left-radius: 4px; }
.msg-agent { align-self: flex-end; background: var(--panel-2); border: 1px solid var(--border); border-bottom-right-radius: 4px; }
.msg-meta { font-size: 11px; color: var(--text-muted); margin-top: 5px; }

.chat-input-bar {
  display: flex;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
}

.chat-input-bar textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
}

.typing-indicator { align-self: flex-end; color: var(--text-muted); font-size: 12.5px; }

/* ---------- متفرقات ---------- */
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--panel-2); border: 1px solid var(--border); padding: 5px 12px; border-radius: 20px; font-size: 12.5px; display:flex; align-items:center; gap:6px; }
.section-title { font-size: 15px; font-weight: 700; margin: 0 0 12px; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display:flex; align-items:center; justify-content:center; z-index: 100; }
.modal-box { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 480px; max-height: 85vh; overflow-y:auto; }
