/* Design Tokens & Shared UI Components */
@import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');
/* Bootstrap Icons v1.11.3 (MIT) — self-hosted so the public landing page and
   the hamburger glyph still render without an internet connection.
   Source: assets/vendor/bootstrap-icons/ (css + woff2/woff). */
@import url('../vendor/bootstrap-icons/bootstrap-icons.min.css');
/* DataTables 1.13.8 and Select2 4.1.0-rc.0 — self-hosted alongside the icon
   font. The dashboards must keep working on an unreliable connection, and a
   compromised CDN on an authenticated page could exfiltrate session tokens. */
@import url('../vendor/datatables/jquery.dataTables.min.css');
@import url('../vendor/select2/select2.min.css');

:root {
  --primary: #0f5132;
  --primary-hover: #0b3d26;
  --primary-light: #198754;
  --primary-soft: #e8f3ed;
  --accent: #c89b3c;
  --accent-hover: #b3872b;
  --accent-soft: #fbf5e6;

  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-alt: #f8faf9;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --success: #15803d;
  --success-bg: #dcfce7;
  --warning: #b45309;
  --warning-bg: #fef3c7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --info: #0369a1;
  --info-bg: #e0f2fe;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 40px rgba(15, 81, 50, 0.12);

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-arabic: 'Amiri', 'Traditional Arabic', serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.arabic-text {
  font-family: var(--font-arabic);
  direction: rtl;
  unicode-bidi: isolate;
}

img {
  max-width: 100%;
  display: block;
}

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

.hidden {
  display: none !important;
}

/* Typography utilities */
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-danger { color: var(--danger); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 42px;
  padding: 0.55rem 1.15rem;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-sm {
  min-height: 34px;
  padding: 0.35rem 0.78rem;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(15, 81, 50, 0.24);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.btn-soft {
  background: var(--primary-soft);
  color: var(--primary);
}
.btn-soft:hover:not(:disabled) {
  background: #d7ebdf;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) {
  background: #991b1b;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.input, .select, .textarea {
  width: 100%;
  min-height: 42px;
  padding: 0.55rem 0.8rem;
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.textarea {
  min-height: 92px;
  resize: vertical;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 81, 50, 0.12);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 999px;
  text-transform: capitalize;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: #f1f5f9; color: #475569; }
.badge-gold { background: var(--accent-soft); color: #8c6614; border: 1px solid rgba(200, 155, 60, 0.35); }

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.data-table th {
  text-align: left;
  padding: 0.75rem 0.9rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

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

table.data-table tbody tr:last-child td {
  border-bottom: none;
}

table.data-table tbody tr:hover {
  background: #fafcfb;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}

.modal-card {
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
}

.modal-card.modal-lg {
  max-width: 880px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.15rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}

/* Alerts & Toasts */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  border: 1px solid transparent;
}
.alert-info { background: var(--info-bg); color: var(--info); border-color: #bae6fd; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: #bbf7d0; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: #fde68a; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }

.toast-container {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  z-index: 2000;
  max-width: calc(100vw - 2rem);
}

.toast {
  min-width: 260px;
  max-width: 400px;
  padding: 0.85rem 1.05rem;
  border-radius: var(--radius-md);
  background: #1e293b;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
}
.toast.toast-success { background: var(--primary); }
.toast.toast-error { background: var(--danger); }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Avatar & Stylized Photo Uploader */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary-soft);
  background: var(--primary-soft);
  flex-shrink: 0;
}
.avatar-lg {
  width: 96px;
  height: 96px;
}

.photo-upload-wrap {
  position: relative;
  display: inline-block;
  width: 104px;
  height: 104px;
  flex-shrink: 0;
}

.photo-upload-avatar {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--primary-soft);
  background: var(--primary-soft);
  box-shadow: var(--shadow-sm);
  display: block;
}

.photo-upload-btn {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid #f1f5f9;
  background: #ffffff;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.16);
  transition: transform 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.photo-upload-btn:hover {
  transform: scale(1.06);
  color: var(--primary);
  border-color: var(--primary);
}

.photo-upload-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}
