:root {
  --brand: #6366f1;
  --brand-hover: #4f46e5;
  --brand-light: #f5f3ff;
  --bg: #f8fafc;
  --sidebar-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --sidebar-width: 280px;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  direction: rtl;
}

/* Layout Structure */
.wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-left: 1px solid var(--border);
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 1050;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 10px rgba(0,0,0,0.02);
}

.main-content {
  flex: 1;
  margin-right: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: calc(100% - var(--sidebar-width));
  background: var(--bg);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 991px) {
  .sidebar { transform: translateX(100%); right: 0; }
  .sidebar.active { transform: translateX(0); box-shadow: -10px 0 30px rgba(0,0,0,0.1); }
  .main-content { margin-right: 0 !important; width: 100% !important; }
}

/* Sidebar Styling */
.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.sidebar-menu hr {
  margin: 16px 8px;
  opacity: 0.1;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius);
  transition: all 0.2s;
  margin-bottom: 4px;
  font-weight: 500;
  font-size: 0.95rem;
}

.sidebar-menu a i {
  margin-left: 12px;
  font-size: 1.25rem;
  transition: all 0.2s;
}

.sidebar-menu a:hover {
  background: var(--brand-light);
  color: var(--brand);
}

.sidebar-menu a.active {
  background: var(--brand);
  color: #ffffff;
}

.sidebar-menu a.active i {
  color: #ffffff;
}

.sidebar-menu a.text-danger:hover {
  background: #fef2f2;
  color: #dc2626;
}

/* Topbar Styling */
.topbar {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1000;
}

/* Base UI Components */
.card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-title {
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 20px;
}

/* Metrics Dashboard */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.metric-card {
  display: flex;
  align-items: center;
  gap: 20px;
}

.metric-info h6 {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 4px;
  font-weight: 500;
}

.metric-info .h2 {
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0;
  font-size: 1.75rem;
}

.icon-pill {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-light);
  color: var(--brand);
  font-size: 1.5rem;
}

/* Progress Bars */
.progress {
  height: 8px;
  border-radius: 10px;
  background-color: #f1f5f9;
}

.progress-bar {
  border-radius: 10px;
}

/* Tables */
.table-container {
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table thead th {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.table tbody td {
  padding: 16px 24px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

/* Buttons */
.btn {
  border-radius: 10px;
  padding: 10px 20px;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 15px rgba(99, 102, 241, 0.4);
}

/* Status Badges Refined */
.badge {
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.75rem;
}

.bg-soft-success { background: #dcfce7 !important; color: #15803d !important; }
.bg-soft-info { background: #e0f2fe !important; color: #0369a1 !important; }
.bg-soft-warning { background: #fef9c3 !important; color: #a16207 !important; }
.bg-soft-danger { background: #fee2e2 !important; color: #b91c1c !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Utilities */
.text-primary { color: var(--brand) !important; }
.transition-hover:hover { transform: scale(1.02); transition: 0.3s; }
.scale-75 { transform: scale(0.75); }

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: #f1f5f9;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-icon:hover {
  background: var(--brand-light);
  color: var(--brand);
}
