/* CSS Variables for Theme Management */
:root {
  /* Light Theme Colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --shadow-color: rgba(0, 0, 0, 0.1);
  
  /* Gradient Colors */
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --gradient-accent: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --gradient-success: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
  --gradient-warning: linear-gradient(135deg, #ffd89b 0%, #19547b 100%);
  --gradient-wallet: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  
  /* Sidebar */
  --sidebar-bg: rgba(255, 255, 255, 0.95);
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 70px;
  
  /* Glass Effect */
  --glass-bg: rgba(255, 255, 255, 0.25);
  --glass-border: rgba(255, 255, 255, 0.18);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
  --glow-color: rgba(102, 126, 234, 0.4);
  
  /* Animation Variables */
  --transition-speed: 0.3s;
  --bounce-easing: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Dark Theme */
.dark-theme {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --border-color: #334155;
  --shadow-color: rgba(0, 0, 0, 0.3);
  
  --sidebar-bg: rgba(15, 23, 42, 0.95);
  --glass-bg: rgba(15, 23, 42, 0.25);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --glow-color: rgba(102, 126, 234, 0.6);
}

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow-x: hidden;
  transition: all var(--transition-speed) ease;
}

/* Animated Background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--gradient-primary);
  opacity: 0.05;
  z-index: -1;
  animation: gradientShift 10s ease infinite;
}

@keyframes gradientShift {
  0%, 100% { transform: translateX(0) translateY(0); }
  25% { transform: translateX(-2%) translateY(-1%); }
  50% { transform: translateX(2%) translateY(1%); }
  75% { transform: translateX(-1%) translateY(2%); }
}

/* Sidebar Styles */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  transform: translateX(0);
  transition: all var(--transition-speed) var(--bounce-easing);
  z-index: 1000;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.logo i {
  font-size: 1.5rem;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.5rem;
  transition: all var(--transition-speed) ease;
}

.sidebar-toggle:hover {
  background: var(--bg-tertiary);
  transform: rotate(90deg);
}

.sidebar-menu {
  list-style: none;
  padding: 1rem 0;
}

.menu-item {
  margin: 0.25rem 0;
}

.menu-item a {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.5rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition-speed) ease;
  position: relative;
  overflow: hidden;
}

.menu-item a::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: var(--gradient-primary);
  opacity: 0.1;
  transition: left var(--transition-speed) ease;
}

.menu-item a:hover::before,
.menu-item.active a::before {
  left: 0;
}

.menu-item a:hover,
.menu-item.active a {
  color: var(--text-primary);
  background: var(--glass-bg);
  transform: translateX(0.25rem);
}

.menu-item a i {
  font-size: 1.1rem;
  width: 1.5rem;
  transition: all var(--transition-speed) var(--bounce-easing);
}

.menu-item a:hover i {
  transform: scale(1.2);
  color: #667eea;
}

.menu-item.active a i {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-primary);
  transition: margin-left var(--transition-speed) ease;
}

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

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

.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.5rem;
  transition: all var(--transition-speed) ease;
}

.mobile-menu-toggle:hover {
  background: var(--bg-tertiary);
}

.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.theme-toggle {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 2rem;
  padding: 0.5rem;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  width: 3rem;
  height: 3rem;
  transition: all var(--transition-speed) ease;
}

.theme-toggle:hover {
  transform: scale(1.05);
  box-shadow: var(--glass-shadow);
}

.theme-toggle i {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: all var(--transition-speed) ease;
}

.theme-toggle .fa-moon {
  opacity: 1;
  color: #f59e0b;
}

.theme-toggle .fa-sun {
  opacity: 0;
  color: #f59e0b;
  transform: translate(-50%, -50%) rotate(180deg);
}

.dark-theme .theme-toggle .fa-moon {
  opacity: 0;
  transform: translate(-50%, -50%) rotate(-180deg);
}

.dark-theme .theme-toggle .fa-sun {
  opacity: 1;
  transform: translate(-50%, -50%) rotate(0deg);
}

.dashboard-btn {
  display: inline;
  align-items: center;
  gap: 0.5rem;
  background: var(--gradient-primary);
  color: white;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  font-weight: 600;
  transition: all var(--transition-speed) ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

/* Content Area */
.content-area {
  padding: 2rem;
  background: var(--bg-secondary);
  min-height: calc(100vh - 80px);
  animation: fadeInUp 0.6s ease-out;
}

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

/* Section Titles */
.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Wallet Overview Section */
.wallet-overview {
  margin-bottom: 2rem;
  animation: slideInFromTop 0.8s ease-out;
}

@keyframes slideInFromTop {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.wallet-card {
  background: var(--gradient-wallet);
  border-radius: 1rem;
  padding: 2rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 30px var(--glow-color);
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  color: white;
  animation: glowPulse 3s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 30px var(--glow-color); }
  50% { box-shadow: 0 0 50px var(--glow-color); }
}

.wallet-label {
  font-size: 1rem;
  opacity: 0.9;
  margin-bottom: 0.5rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.wallet-value {
  font-size: 2.5rem;
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.wallet-icon {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 2rem;
  opacity: 0.3;
}

/* Referral Section */
.referral-section {
  margin-bottom: 2rem;
  animation: slideInFromLeft 0.8s ease-out;
}

@keyframes slideInFromLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.referral-container {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}

.referral-link-box,
.referred-by-box {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 0 20px var(--glow-color);
  transition: all var(--transition-speed) ease;
}

.referral-link-box:hover,
.referred-by-box:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 30px var(--glow-color);
}

.referral-link-box label,
.referred-by-box label {
  display: block;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.link-input-container {
  display: flex;
  gap: 0.5rem;
}

.link-input-container input {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 0.75rem;
  color: var(--text-primary);
  font-size: 0.875rem;
}

.copy-btn {
  background: var(--gradient-primary);
  border: none;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  color: white;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
}

.copy-btn:hover {
  transform: scale(1.05);
}

.referred-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-tertiary);
  border-radius: 0.5rem;
  padding: 0.75rem;
}

.referred-info i {
  color: var(--text-secondary);
}

.referred-info span {
  font-weight: 500;
  color: var(--text-primary);
}

/* Packages Section */
.packages-section {
  margin-bottom: 2rem;
  animation: slideInFromRight 0.8s ease-out;
}

@keyframes slideInFromRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.packages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.package-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
  padding: 1.5rem;
  text-align: center;
  box-shadow: 0 0 20px var(--glow-color);
  transition: all var(--transition-speed) ease;
  cursor: pointer;
}

.package-card:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 0 40px var(--glow-color);
}

.package-price {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

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

/* Daily Royalty Countdown Section */
.royalty-section {
  margin-bottom: 2rem;
  animation: fadeInUp 0.8s ease-out 0.2s both;
}

.royalty-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.royalty-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
  padding: 1.5rem;
  text-align: center;
  box-shadow: 0 0 20px var(--glow-color);
  transition: all var(--transition-speed) ease;
  animation: fadeInUp 0.6s ease-out;
}

.royalty-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 0 30px var(--glow-color);
}

.royalty-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
  animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.royalty-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.royalty-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.royalty-countdown {
  font-size: 0.875rem;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border-radius: 0.5rem;
  padding: 0.25rem 0.75rem;
  display: inline-block;
}

/* Stats Section */
.stats-section {
  margin-bottom: 2rem;
  animation: fadeInUp 0.8s ease-out 0.4s both;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 0 20px var(--glow-color);
  transition: all var(--transition-speed) ease;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 30px var(--glow-color);
}

.stat-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 0.75rem;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.2rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.stat-content {
  flex: 1;
}

.stat-title {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Ranks Section */
.ranks-section {
  animation: fadeInUp 0.8s ease-out 0.6s both;
}

.ranks-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.rank-item {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 0 20px var(--glow-color);
  transition: all var(--transition-speed) ease;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.rank-item:hover {
  transform: translateX(5px);
  box-shadow: 0 0 30px var(--glow-color);
}

.rank-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.2rem;
}

.rank-info {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rank-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1.1rem;
}

.rank-amount {
  font-weight: 500;
  color: var(--text-secondary);
}

/* Referral Table Section */
.referral-table-section {
  animation: fadeInUp 0.8s ease-out;
}

.table-container {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
  box-shadow: 0 0 20px var(--glow-color);
  overflow: hidden;
  transition: all var(--transition-speed) ease;
}

.table-container:hover {
  box-shadow: 0 0 30px var(--glow-color);
}

.table-wrapper {
  overflow-x: auto;
}

.referral-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.referral-table thead {
  background: var(--gradient-primary);
}

.referral-table thead th {
  color: white;
  font-weight: 600;
  padding: 1rem;
  text-align: left;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: none;
}

.referral-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: all var(--transition-speed) ease;
}

.referral-table tbody tr:hover {
  background: var(--bg-tertiary);
  transform: scale(1.01);
}

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

.referral-table tbody td {
  padding: 1rem;
  color: var(--text-primary);
  border: none;
  vertical-align: middle;
}

.address-cell {
  font-family: 'Courier New', monospace;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

/* Placeholder Sections */
.community-section,
.downline-section {
  animation: fadeInUp 0.8s ease-out;
}

.community-placeholder,
.downline-placeholder {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 300px;
}

.placeholder-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
  padding: 3rem;
  text-align: center;
  box-shadow: 0 0 20px var(--glow-color);
  transition: all var(--transition-speed) ease;
  width: 100% !important;
}

.placeholder-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 0 30px var(--glow-color);
}

.placeholder-icon {
  font-size: 3rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.placeholder-text h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.placeholder-text p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Overlay */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-speed) ease;
  z-index: 999;
}

.overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .packages-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }
  
  .royalty-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
  
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.active {
    transform: translateX(0);
  }
  
  .sidebar-toggle {
    display: block;
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .mobile-menu-toggle {
    display: block;
  }
  
  .header {
    padding: 1rem;
  }
  
  .content-area {
    padding: 1rem;
  }
  
  .page-title {
    font-size: 1.25rem;
  }
  
  .referral-container {
    grid-template-columns: 1fr;
  }
  
  .packages-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .royalty-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .wallet-value {
    font-size: 2rem;
  }
  
  .referral-table {
    font-size: 0.75rem;
  }
  
  .referral-table thead th,
  .referral-table tbody td {
    padding: 0.75rem 0.5rem;
  }
}

@media (max-width: 480px) {
  .header {
    padding: 0.75rem;
  }
  
  .content-area {
    padding: 0.75rem;
  }
  
  .wallet-card {
    padding: 1.5rem;
  }
  
  .referral-link-box,
  .referred-by-box,
  .package-card,
  .royalty-card,
  .stat-card,
  .rank-item {
    padding: 1rem;
  }
  
  .page-title {
    font-size: 1.125rem;
  }
  
  .wallet-value {
    font-size: 1.75rem;
  }
  
  .package-price {
    font-size: 1.25rem;
  }
  
  .royalty-icon {
    font-size: 1.5rem;
  }
  
  .referral-table {
    font-size: 0.7rem;
  }
  
  .referral-table thead th,
  .referral-table tbody td {
    padding: 0.5rem 0.25rem;
  }
  
  .table-container {
    border-radius: 0.5rem;
  }
}

/* Dark theme specific animations */
.dark-theme .wallet-card,
.dark-theme .package-card:hover,
.dark-theme .royalty-card:hover,
.dark-theme .stat-card:hover,
.dark-theme .rank-item:hover,
.dark-theme .table-container:hover {
  box-shadow: 0 0 40px rgba(102, 126, 234, 0.4);
}

/* Loading animation for theme switch */
body.theme-transitioning * {
  transition: all var(--transition-speed) ease !important;
}