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

:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-success: #16a34a;
  --color-danger: #dc2626;
  --color-bg: #f3f4f6;
  --color-surface: #ffffff;
  --color-text: #1f2937;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --radius: 12px;
  --sidebar-width: 220px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  direction: rtl;
  font-family: 'Cairo', 'Tajawal', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

a { color: inherit; }

/* Login page */
.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  width: 100%;
  max-width: 380px;
}

.app-title {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--color-primary-dark);
}

.app-subtitle {
  text-align: center;
  color: var(--color-text-muted);
  margin-bottom: 24px;
  font-size: 14px;
}

/* App shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: #111827;
  color: #f9fafb;
  padding: 20px 14px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  font-weight: 800;
  font-size: 17px;
  margin-bottom: 24px;
  padding: 0 8px;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.sidebar nav a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: #d1d5db;
  font-size: 14px;
  font-weight: 600;
}

.sidebar nav a:hover {
  background: #1f2937;
  color: #fff;
}

.sidebar nav a.active {
  background: var(--color-primary);
  color: #fff;
}

.sidebar .logout-btn {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #374151;
  background: transparent;
  color: #d1d5db;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
}

.main {
  flex: 1;
  padding: 24px 28px;
  overflow-x: auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.page-title {
  font-size: 20px;
  font-weight: 800;
}

/* Buttons */
button, .btn {
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  padding: 10px 16px;
  text-decoration: none;
  display: inline-block;
}

button:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: #fff; color: var(--color-primary); border: 1px solid var(--color-primary); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--color-border); color: var(--color-text-muted); }
.btn-sm { padding: 6px 10px; font-size: 13px; }

/* Cards / stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.stat-card .label { font-size: 13px; color: var(--color-text-muted); margin-bottom: 6px; }
.stat-card .value { font-size: 26px; font-weight: 800; }

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.chart-card h3 { margin: 0 0 12px; font-size: 15px; }

/* Card container (forms, filters) */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  margin-bottom: 20px;
}

.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label { font-size: 12px; color: var(--color-text-muted); font-weight: 600; }

input, select {
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  font-size: 14px;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
}

input:focus, select:focus { outline: none; border-color: var(--color-primary); }

/* Table */
.table-wrap {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th, td {
  padding: 12px 14px;
  text-align: right;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

th { background: #f9fafb; font-weight: 700; color: var(--color-text-muted); font-size: 13px; }

tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge-active { background: #dcfce7; color: #166534; }
.badge-inactive { background: #fee2e2; color: #991b1b; }

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 14px;
}

.pagination span { font-size: 13px; color: var(--color-text-muted); }

.error-text { color: var(--color-danger); font-size: 14px; margin-bottom: 12px; min-height: 18px; }

.muted-center { text-align: center; color: var(--color-text-muted); padding: 24px 0; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 { margin-top: 0; }

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-row input, .form-row select { width: 100%; }

.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions button { flex: 1; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  max-width: 90%; padding: 14px 20px; border-radius: 10px; font-weight: 700;
  text-align: center; color: #fff; z-index: 2000; box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.toast-success { background: var(--color-success); }
.toast-error { background: var(--color-danger); }
.toast-info { background: #374151; }
