/* === DASHBOARD LAYOUT === */
.dashboard-wrapper {
  min-height: 100vh;
  display: flex;
  overflow-x: hidden; /* لایه محافظ اضافه برای جلوگیری از اسکرول افقی کل صفحه در موبایل */
}

/* Sidebar */
.sidebar {
  width: 260px;
  min-height: 100vh;
  background: rgba(255,255,255,0.03);
  border-left: 1px solid var(--border);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-logo {
  padding: 0.5rem 0.5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.sidebar-logo a {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  text-decoration: none;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: 'Vazirmatn', sans-serif;
  width: 100%;
  text-align: right;
}

.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(124,58,237,0.15);
  color: var(--accent);
  border: 1px solid rgba(124,58,237,0.2);
}

.nav-item .nav-icon { font-size: 1.1rem; flex-shrink: 0; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

/* Main Content */
.dashboard-main {
  flex: 1;
  min-width: 0; /* جلوگیری از سرریز کل صفحه به‌خاطر جدول‌های عریض (رفع مشکل شکستگی موبایل) */
  margin-right: 260px;
  padding: 2rem;
  min-height: 100vh;
}

/* Top Bar */
.dashboard-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 40px; height: 40px;
  background: var(--gradient-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: white;
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 100% at 100% 0%, rgba(124,58,237,0.22), transparent 65%);
  pointer-events: none;
}

.stat-card:hover { border-color: var(--border-light); }

.stat-icon {
  width: 48px; height: 48px;
  background: rgba(124,58,237,0.15);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Subscription Card */
.subscription-card {
  background: var(--gradient-card);
  border: 1px solid var(--primary);
  border-radius: var(--radius-xl);
  padding: 2rem;
  margin-bottom: 2rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2rem;
  align-items: center;
}

.sub-info {}
.sub-plan { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.sub-name { font-size: 1.4rem; font-weight: 700; margin-bottom: 1rem; }

.sub-meta {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.sub-meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.sub-meta-label { font-size: 0.75rem; color: var(--text-muted); }
.sub-meta-value { font-size: 1rem; font-weight: 600; }

/* Progress Bar */
.progress-wrapper {
  margin-top: 1.25rem;
}
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.progress-bar {
  height: 8px;
  background: rgba(255,255,255,0.08);
  border-radius: 100px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 100px;
  transition: width 0.8s ease;
}

/* Config Box */
.config-box {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.config-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.config-value {
  font-size: 0.85rem;
  color: var(--text-secondary);
  word-break: break-all;
  font-family: 'Courier New', monospace;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  padding: 0.4rem 0.875rem;
  margin-top: 0.5rem;
  cursor: pointer;
}

.copy-btn.copied {
  background: rgba(16,185,129,0.15);
  color: #34D399;
  border-color: rgba(16,185,129,0.3);
}

/* QR Code */
.qr-wrapper {
  background: white;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  width: fit-content;
}

/* Orders Table */
.table-wrapper {
  overflow-x: auto;
  max-width: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: 0.875rem 1.25rem;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
}

.data-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.875rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* Mobile Sidebar */
.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 48px; height: 48px;
  background: var(--gradient-primary);
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 200;
  box-shadow: 0 4px 15px rgba(124,58,237,0.4);
  font-size: 1.25rem;
  color: white;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 99;
  backdrop-filter: blur(4px);
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(100%) !important;
  }
  .sidebar.open {
    transform: translateX(0) !important;
  }
  .sidebar-overlay.active { display: block !important; }
  .dashboard-main { margin-right: 0 !important; padding: 1.25rem !important; }
  .sidebar-toggle { display: flex !important; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .subscription-card { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .dashboard-main { padding: 1.25rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
  .stat-card { padding: 1rem; }
  .stat-icon { width: 36px; height: 36px; font-size: 1rem; margin-bottom: 0.6rem; }
  .stat-value { font-size: 1.25rem; }
  .stat-label { font-size: 0.7rem; }
}