:root {
  --font-family: 'Tajawal', system-ui, -apple-system, sans-serif;
  
  /* Zid-inspired Palette */
  --primary: #4e3895; /* Deep Purple */
  --primary-hover: #3d2c75;
  --primary-light: #f0ebff;
  
  --secondary: #3cd59e; /* Mint Green */
  --secondary-hover: #2eb584;
  
  --bg: #f9fbfd; /* Very light gray/blue tint */
  --panel: #ffffff;
  
  --text: #212529;
  --text-secondary: #6c757d;
  --text-tertiary: #adb5bd;
  
  --border: #e9ecef;
  --border-hover: #ced4da;
  
  --danger: #dc3545;
  --warning: #ffc107;
  --success: #28a745;
  --info: #17a2b8;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  
  --radius: 8px;
  --radius-lg: 12px;
  
  --sidebar-width: 260px;
  --topbar-height: 64px;
}

* {
  box-sizing: border-box;
  outline: none;
}

body {
  margin: 0;
  font-family: var(--font-family);
  background: var(--bg);
  color: var(--text);
  direction: rtl; /* Enforce RTL */
  text-align: right;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  text-decoration: none;
  color: inherit;
  transition: color 0.2s;
}

/* Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.w-full { width: 100%; }
.h-full { height: 100%; }

.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.text-muted { color: var(--text-secondary); }
.text-primary { color: var(--primary); }
.text-center { text-align: center; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  font-size: 0.9rem;
  gap: 8px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: white;
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover {
  background: var(--bg);
  border-color: var(--border-hover);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover {
  background: var(--primary-light);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: rgba(0,0,0,0.05);
  color: var(--text);
}

.btn-icon {
  padding: 8px;
  border-radius: 50%;
  width: 36px;
  height: 36px;
}

/* Inputs */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.input-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}
.input-control {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  transition: border-color 0.2s;
  font-size: 0.95rem;
}
.input-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

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

/* Layout */
.dashboard-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--panel);
  border-inline-end: 1px solid var(--border);
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  transition: width 0.3s;
}

.main-content {
  margin-right: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

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

.content-area {
  padding: 32px;
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Sidebar Items */
.sidebar-logo {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 24px;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
}

.nav-menu {
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 4px;
  transition: all 0.2s;
  gap: 12px;
}
.nav-item:hover {
  background: var(--bg);
  color: var(--primary);
}
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}
.nav-icon {
  width: 20px;
  height: 20px;
}

/* Auth Page */
.auth-page {
  display: flex;
  min-height: 100vh;
  background: white;
}
.auth-visual {
  flex: 1;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  position: relative;
  overflow: hidden;
}
.auth-visual::before {
  content: '';
  position: absolute;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
  top: -50%;
  right: -50%;
}
.auth-form-container {
  width: 480px;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth-header {
  margin-bottom: 32px;
  text-align: center;
}
.auth-logo {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 16px;
  display: block;
}

/* Tables */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  font-size: 0.9rem;
}
.data-table th {
  text-align: right;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-weight: 600;
  background: #f8f9fa;
}
.data-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.data-table tr:last-child td {
  border-bottom: none;
}
.data-table tr:hover td {
  background: #f8f9fa;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-neutral { background: #e2e3e5; color: #383d41; }

/* Grid */
.grid-cols-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}
.grid-cols-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

/* Stat Card */
.stat-card {
  background: white;
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.stat-label { color: var(--text-secondary); font-size: 0.9rem; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--text); }
.stat-trend { font-size: 0.85rem; display: flex; align-items: center; gap: 4px; }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* Animation */
.fade-in {
  animation: fadeIn 0.3s ease-in-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(100%); }
  .main-content { margin-right: 0; }
  .auth-visual { display: none; }
  .auth-form-container { width: 100%; }
}
