/* General Styles */
* {
  box-sizing: border-box;
}

:root {
  --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --header-bg: rgba(255, 255, 255, 0.1);
  --header-color: white;
  --header-border: rgba(255, 255, 255, 0.2);
  --text-color: #333;
  --card-bg: rgba(255, 255, 255, 0.95);
  --card-border: rgba(255, 255, 255, 0.2);
  --input-border: #e1e5e9;
  --input-focus-border: #667eea;
  --input-focus-shadow: rgba(102, 126, 234, 0.1);
  --btn-bg: linear-gradient(45deg, #28a745, #20c997);
  --btn-hover: linear-gradient(45deg, #218838, #17a2b8);
  --submit-bg: linear-gradient(45deg, #667eea, #764ba2);
  --submit-hover: linear-gradient(45deg, #5a67d8, #6b46c1);
  --dropdown-bg: rgba(255, 255, 255, 0.95);
  --dropdown-hover: rgba(102, 126, 234, 0.1);
  --profile-bg: #667eea;
  --profile-border: rgba(255, 255, 255, 0.5);
  --nav-bg: #ffffff;
  --nav-border: #e0e0e0;
  --nav-active: #25d366;
  --nav-hover: rgba(37, 211, 102, 0.1);
  --list-item-bg: #f8f9fa;
  --list-item-border: #dee2e6;
  --notification-bg: rgba(255, 255, 255, 0.95);
  --notification-border: rgba(255, 255, 255, 0.2);
  --notification-sender: #667eea;
  --account-bg: rgba(255, 255, 255, 0.95);
  --account-border: rgba(255, 255, 255, 0.2);
  --account-text: #555;
  --account-strong: #333;
  --toggle-bg: linear-gradient(45deg, #28a745, #20c997);
  --toggle-hover: linear-gradient(45deg, #218838, #17a2b8);
}

body.dark-mode {
  --bg-gradient: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 100%);
  --header-bg: rgba(0, 0, 0, 0.3);
  --header-color: #e0e0e0;
  --header-border: rgba(255, 255, 255, 0.1);
  --text-color: #e0e0e0;
  --card-bg: rgba(30, 30, 46, 0.95);
  --card-border: rgba(255, 255, 255, 0.1);
  --input-border: #4a5568;
  --input-focus-border: #63b3ed;
  --input-focus-shadow: rgba(99, 179, 237, 0.1);
  --btn-bg: linear-gradient(45deg, #38a169, #2f855a);
  --btn-hover: linear-gradient(45deg, #2f855a, #22543d);
  --submit-bg: linear-gradient(45deg, #2d3748, #1a202c);
  --submit-hover: linear-gradient(45deg, #1a202c, #0f1419);
  --dropdown-bg: rgba(30, 30, 46, 0.95);
  --dropdown-hover: rgba(99, 179, 237, 0.1);
  --profile-bg: #2d3748;
  --profile-border: rgba(255, 255, 255, 0.3);
  --nav-bg: #1a202c;
  --nav-border: #2d3748;
  --nav-active: #63b3ed;
  --nav-hover: rgba(99, 179, 237, 0.1);
  --list-item-bg: #2d3748;
  --list-item-border: #4a5568;
  --notification-bg: rgba(30, 30, 46, 0.95);
  --notification-border: rgba(255, 255, 255, 0.1);
  --notification-sender: #63b3ed;
  --account-bg: rgba(30, 30, 46, 0.95);
  --account-border: rgba(255, 255, 255, 0.1);
  --account-text: #a0aec0;
  --account-strong: #e2e8f0;
  --toggle-bg: linear-gradient(45deg, #38a169, #2f855a);
  --toggle-hover: linear-gradient(45deg, #2f855a, #22543d);
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg-gradient);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--text-color);
  transition: background 0.3s ease, color 0.3s ease;
}

header {
  background-color: var(--header-bg);
  color: var(--header-color);
  text-align: center;
  padding: 1rem;
  backdrop-filter: blur(10px);
  border-bottom: var(--header-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.theme-toggle-btn {
  background: none;
  border: none;
  color: var(--header-color);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: background-color 0.3s ease;
}

.theme-toggle-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.profile-container {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: var(--dropdown-bg);
  min-width: 160px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  z-index: 10;
  border-radius: 10px;
  backdrop-filter: blur(10px);
  border: var(--card-border);
}

.dropdown-content a {
  color: var(--text-color);
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  border-radius: 10px;
}

.dropdown-content a:hover {
  background-color: var(--dropdown-hover);
}

.profile-container:hover .dropdown-content {
  display: block;
}

.profile-pic {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #667eea;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.5);
}

main {
  flex: 1;
  /* display: flex; */
  justify-content: center;
  align-items: center;
  padding: 2rem;
  min-height: calc(100vh - 80px);
}

.dashboard-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 800px;
  padding: 2rem;
  gap: 1.5rem;
}

.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(45deg, #28a745, #20c997);
  color: white;
  text-decoration: none;
  border-radius: 50px;
  margin: 0.5rem;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.admin-btn {
  background: linear-gradient(45deg, #dc3545, #c82333);
}

form {
  background-color: rgba(255, 255, 255, 0.95);
  padding: 2.5rem;
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.form-group {
  margin-bottom: 1.5rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: #555;
}

input[type="text"], input[type="password"] {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #e1e5e9;
  border-radius: 10px;
  font-size: 1rem;
  transition: border-color 0.3s ease;
}

input[type="text"]:focus, input[type="password"]:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.checkbox-group {
  display: flex;
  align-items: center;
  margin-top: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
  margin-right: 0.5rem;
  width: auto;
}

button[type="submit"] {
  width: 100%;
  padding: 0.75rem;
  background: linear-gradient(45deg, #667eea, #764ba2);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
}

button[type="submit"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

p {
  text-align: center;
  margin-top: 1.5rem;
}

p a {
  color: #667eea;
  text-decoration: none;
  font-weight: 600;
}

p a:hover {
  text-decoration: underline;
}

/* Dashboard Styles */
#activation, #stats, #referral, #downlines {
  background-color: rgba(255, 255, 255, 0.95);
  padding: 2rem;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
}

#downlines ul {
  list-style-type: none;
  padding: 0;
}

#downlines li {
  padding: 0.5rem 0;
  border-bottom: 1px solid #eee;
}

#downlines li:last-child {
  border-bottom: none;
}

.user-item {
  background-color: #f8f9fa;
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 10px;
  border: 1px solid #dee2e6;
}

.activate-btn {
  background: linear-gradient(45deg, #28a745, #20c997);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
}

.activate-btn:hover {
  background: linear-gradient(45deg, #218838, #17a2b8);
}

#actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
}

#actions .btn {
  padding: 1rem 2rem;
  font-size: 1.2rem;
  min-width: 200px;
}

#referralLink {
  word-break: break-all;
  background-color: #f8f9fa;
  padding: 0.5rem;
  border-radius: 5px;
  margin-top: 0.5rem;
  display: block;
}

/* Admin Panel Styles */
.admin-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 1000px;
  padding: 2rem;
  gap: 1.5rem;
}

#signup-stats, #online-stats, #user-list, #withdrawals {
  background-color: rgba(255, 255, 255, 0.95);
  padding: 2rem;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  width: 100%;
  text-align: center;
}

#onlineUsersList {
  text-align: left;
}

#onlineUsersList ul {
  list-style-type: none;
  padding: 0;
}

#onlineUsersList li {
  padding: 0.5rem 0;
  border-bottom: 1px solid #eee;
}

#onlineUsersList li:last-child {
  border-bottom: none;
}

.pay-btn {
  background: linear-gradient(45deg, #28a745, #20c997);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
  margin-left: 1rem;
}

.pay-btn:hover {
  background: linear-gradient(45deg, #218838, #17a2b8);
}

/* Notification Styles */
.notification-item {
  background-color: rgba(255, 255, 255, 0.95);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.notification-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.notification-sender {
  font-weight: bold;
  color: #667eea;
}

.notification-message {
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.notification-time {
  font-size: 0.8rem;
  color: #666;
  cursor: pointer;
  margin-top: 0.5rem;
  text-align: right;
}

.notification-time:hover {
  color: #667eea;
}

.notification-full-time {
  font-size: 0.8rem;
  color: #888;
  margin-top: 0.25rem;
  text-align: right;
}

/* Mobile Navigation */
#mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #ffffff;
  border-top: 1px solid #e0e0e0;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 60px;
}

#mobile-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #333;
  font-size: 0.7rem;
  transition: all 0.3s ease;
  flex: 1;
  padding: 0.25rem;
}

#mobile-nav .nav-item.active {
  color: #25d366;
}

#mobile-nav .nav-item:hover {
  background-color: rgba(37, 211, 102, 0.1);
}

#mobile-nav .nav-item span:first-child {
  font-size: 1.2rem;
  margin-bottom: 0.1rem;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  body {
    overflow-x: hidden;
    font-size: 16px; /* Prevent zoom on iOS */
  }

  main {
    padding: 0.5rem;
    padding-bottom: 6rem; /* More space for nav bar */
    width: 100%;
    box-sizing: border-box;
  }

  form {
    padding: 1.5rem;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    border-radius: 12px;
  }

  header {
    padding: 0.5rem;
    width: 100%;
    box-sizing: border-box;
    font-size: 1.2rem;
  }

  .btn {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    width: 100%;
    box-sizing: border-box;
    min-height: 48px; /* Touch-friendly */
    border-radius: 8px;
  }

  .admin-main {
    padding: 0.5rem;
    width: 100%;
    box-sizing: border-box;
  }

  #signup-stats, #online-stats, #user-list, #withdrawals {
    padding: 1rem;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 1rem;
  }

  #activation, #stats, #referral, #downlines {
    width: 100%;
    box-sizing: border-box;
    padding: 1.5rem;
    margin-bottom: 1rem;
  }

  #mobile-nav {
    width: 100%;
    box-sizing: border-box;
    height: 80px; /* Taller for touch */
    padding: 0.5rem 0;
  }

  #mobile-nav .nav-item {
    font-size: 0.8rem;
    padding: 0.5rem;
  }

  #mobile-nav .nav-item span:first-child {
    font-size: 1.5rem;
    margin-bottom: 0.2rem;
  }

  .dropdown-content {
    right: 0;
    left: auto;
    max-width: calc(100vw - 1rem);
    position: absolute;
    top: 100%;
  }

  .notification-item {
    padding: 1rem;
    max-width: 100%;
    margin: 0.5rem;
  }

  .notification-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .account-container {
    gap: 1rem;
    margin: 0 0.5rem;
  }

  .account-info, .account-settings, .withdrawal-history, .downline-history {
    padding: 1.5rem;
    margin: 0.5rem auto;
  }

  .profile-avatar {
    width: 70px;
    height: 70px;
    font-size: 1.8rem;
  }

  .profile-name {
    font-size: 1.3rem;
  }

  .account-info p {
    font-size: 1rem;
  }

  .account-settings button {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    min-height: 48px;
  }

  .toggle-btn {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    min-height: 48px;
    align-self: stretch;
  }

  /* Enhanced readability */
  h1, h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
  }

  p {
    font-size: 0.95rem;
    line-height: 1.5;
  }

  input[type="text"], input[type="password"] {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0.75rem;
    border-radius: 8px;
  }

  button[type="submit"] {
    min-height: 48px;
    font-size: 1rem;
  }

  .dashboard-main {
    padding: 0.5rem;
    gap: 1rem;
  }

  .profile-pic {
    width: 50px;
    height: 50px;
  }

  .user-item {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
  }

  .activate-btn, .pay-btn {
    min-height: 44px;
    font-size: 0.9rem;
  }

  .notification-message {
    font-size: 0.95rem;
  }

  .withdrawal-history li, .downline-history li {
    padding: 0.5rem;
    font-size: 0.85rem;
  }
}

/* Desktop Scaling */
@media (min-width: 769px) {
  .notification-item {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
  }

  main {
    padding: 2rem;
  }

  .notification-item {
    padding: 1rem;
  }
}

/* Account Page Styles */
.account-info, .account-settings, .withdrawal-history, .downline-history {
  background-color: var(--account-bg);
  padding-bottom: 2rem;
  display: grid;
  flex-direction: column;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  border: var(--account-border);
  width: 100%;
  max-width: 600px;
  align-items: center;
  text-align: center;
}

.account-info p {
  margin: 1rem 0;
  font-size: 1.1rem;
  color: var(--account-text);
}

.account-info strong {
  color: var(--account-strong);
  font-weight: 600;
}

.account-settings {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.account-settings button {
  padding: 0.75rem 1.5rem;
  background: linear-gradient(45deg, #667eea, #764ba2);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
}

.account-settings button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.withdrawal-history ul, .downline-history ul {
  list-style-type: none;
  padding: 0;
  text-align: left;
}

.withdrawal-history li, .downline-history li {
  padding: 0.75rem;
  border-bottom: 1px solid #eee;
  background-color: var(--list-item-bg);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  color: var(--text-color);
}

.withdrawal-history li:last-child, .downline-history li:last-child {
  border-bottom: none;
}

.toggle-btn {
  background: linear-gradient(45deg, #28a745, #20c997);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
  margin-top: 1rem;
}

.toggle-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.downline-history .full-activated, .downline-history .full-pending {
  margin-bottom: 1.5rem;
}

.downline-history h3 {
  color: #333;
  margin-bottom: 1rem;
  font-size: 1.2rem;
}
