:root {
  /* Color Palette - Dark Mode Optimized */
  --bg-main: #0f111a;
  --bg-sidebar: #151822;
  --bg-card: #1c1f2e;
  --bg-hover: #262a3f;
  
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-primary: #3b82f6; /* Blue */
  --accent-secondary: #8b5cf6; /* Purple */
  --accent-success: #10b981; /* Green */
  --accent-warning: #f59e0b; /* Yellow */
  --accent-danger: #ef4444; /* Red */
  
  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 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.2), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-glow: 0 0 15px rgba(59, 130, 246, 0.3);
  
  /* Border Radius */
  --radius-md: 0.5rem;
  --radius-lg: 1rem;
  --radius-full: 9999px;
  
  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Mode Variables */
:root[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f1f5f9;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 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.05);
  
  --border-color: rgba(0, 0, 0, 0.1);
  --glass-bg: rgba(255, 255, 255, 0.8);
}

:root {
  --border-color: rgba(255, 255, 255, 0.05);
  --glass-bg: rgba(15, 17, 26, 0.8);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  display: flex;
  height: 100vh;
  overflow: hidden;
  direction: rtl; /* RTL for Arabic */
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: all var(--transition-normal);
  z-index: 10;
}

.logo-container {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--gradient-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.2rem;
  box-shadow: var(--shadow-glow);
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-links {
  padding: 1.5rem 1rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  font-weight: 500;
}

.nav-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
  transform: translateX(-4px); /* RTL */
}

.nav-item.active {
  background-color: rgba(59, 130, 246, 0.1);
  color: var(--accent-primary);
  border-left: 3px solid var(--accent-primary); /* RTL */
}

.nav-item i {
  font-size: 1.2rem;
}

.user-profile {
  padding: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background-color: var(--bg-card);
  border: 2px solid var(--accent-primary);
  object-fit: cover;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.user-role {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Main Content */
.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.header {
  height: 72px;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--glass-bg);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn {
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

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

.content-wrapper {
  padding: 2rem;
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(59, 130, 246, 0.3);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 4px;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.stat-title {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background-color: rgba(59, 130, 246, 0.1);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  direction: ltr;
  text-align: right;
}

.stat-change {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.875rem;
}

.change-positive {
  color: var(--accent-success);
}

.change-negative {
  color: var(--accent-danger);
}

/* Charts Area */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.chart-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  border: 1px solid var(--border-color);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.chart-placeholder {
  height: 300px;
  width: 100%;
  background: linear-gradient(180deg, rgba(38, 42, 63, 0) 0%, rgba(38, 42, 63, 0.5) 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border: 1px dashed var(--border-color);
  position: relative;
  overflow: hidden;
}

/* Animations */
@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

.ai-badge {
  background: linear-gradient(90deg, #8b5cf6, #ec4899);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: bold;
  margin-right: auto;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
  animation: pulse 2s infinite;
}

/* Campaigns Table */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: right;
  padding: 1rem;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.875rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

td {
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  vertical-align: middle;
}

tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

.campaign-name {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.platform-icon {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}

.platform-meta { background-color: #1877F2; color: white; }
.platform-google { background-color: #EA4335; color: white; }
.platform-tiktok { background-color: #000000; color: white; border: 1px solid #333; }
/* View Management */
.view-section {
  display: block;
}

.view-section.hidden {
  display: none;
}

/* Wallet Styles */
.wallet-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.balance-card {
  background: var(--gradient-primary);
  border-radius: var(--radius-lg);
  padding: 2rem;
  color: white;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.balance-card::after {
  content: '\f51e';
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  top: -20px;
  left: -20px;
  font-size: 10rem;
  opacity: 0.1;
  transform: rotate(-15deg);
}

.balance-label {
  font-size: 1rem;
  opacity: 0.8;
  margin-bottom: 0.5rem;
}

.balance-amount {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  font-family: monospace;
}

/* Integrations Styles */
.integrations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.integration-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: all var(--transition-fast);
}

.integration-card:hover {
  transform: translateY(-5px);
  border-color: var(--accent-primary);
}

.integration-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.integration-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.integration-desc {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

/* Users Styles */
.user-avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background-color: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.status-active {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--accent-success);
}

.status-paused {
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--accent-warning);
}

/* Glassmorphism elements */
.glass-panel {
  background: rgba(28, 31, 46, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
}
