/* Global Styles - Same color scheme as yes2.html */
:root {
  --bg: #0f1724;
  --card: #0b1220;
  --muted: #9aa4b2;
  --accent1: #7c3aed;
  --accent2: #06b6d4;
  --accent3: #f97316;
  --glass: rgba(255, 255, 255, 0.04);
  --success: #22c55e;
  --error: #ef4444;
}

* {
  box-sizing: border-box;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
}

html, body {
  height: 100%;
  margin: 0;
  background: linear-gradient(180deg, #071028 0%, #091327 50%, #061220 100%);
  color: #e6eef6;
}

body {
  overflow-x: hidden;
}

.container {
  max-width: 1100px;
  margin: 28px auto;
  padding: 18px;
}

/* Header */
header {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.logo {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
}

h1 {
  margin: 0;
  font-size: 18px;
}

p.sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* Cards */
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 6px 20px rgba(4, 6, 12, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.03);
}

/* Buttons */
.btn {
  background: linear-gradient(90deg, var(--accent1), var(--accent2));
  border: none;
  padding: 8px 12px;
  border-radius: 10px;
  color: white;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(124, 58, 237, 0.18);
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(124, 58, 237, 0.25);
}

.btn:active {
  transform: translateY(0);
}

.btn.ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: none;
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.05);
}

.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn.ghost:disabled,
.btn.ghost.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn.full-width {
  width: 100%;
  padding: 12px;
  font-size: 16px;
}

/* Form Elements */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(90deg, #0b1220, rgba(255, 255, 255, 0.01));
  color: #e6eef6;
  font-size: 14px;
  transition: border-color 0.2s;
}

/* Date input styling */
.form-group input[type="date"] {
  cursor: pointer;
  position: relative;
  pointer-events: auto !important;
}

.form-group input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  filter: invert(1);
  opacity: 0.7;
  pointer-events: auto !important;
}

.form-group input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

/* Ensure date input is always editable */
.form-group input[type="date"]:not([readonly]):not([disabled]) {
  background: linear-gradient(90deg, #0b1220, rgba(255, 255, 255, 0.01)) !important;
  cursor: pointer !important;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent1);
}

.form-group input::placeholder {
  color: var(--muted);
}

/* Stats */
.stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.stat {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
  min-width: 160px;
}

.stat h3 {
  margin: 0;
  font-size: 16px;
}

.stat p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* Referral Link */
.ref-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.ref-link {
  flex: 1;
  background: linear-gradient(90deg, #0b1220, rgba(255, 255, 255, 0.01));
  padding: 10px;
  border-radius: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#referralLink {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  padding: 10px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.03);
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 600;
}

/* Badge */
.badge {
  padding: 6px 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent2), var(--accent3));
  font-weight: 700;
  display: inline-block;
}

.chip {
  display: inline-block;
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 13px;
}

/* Team Tree */
.team ul {
  list-style: none;
  padding-left: 12px;
  margin: 8px 0;
}

.team-tree-container {
  padding: 20px 0;
}

.team-member-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  transition: all 0.2s;
}

.team-member-card:hover {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  border-color: rgba(124, 58, 237, 0.3);
  transform: translateX(4px);
}

.team-member-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.team-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
  flex-shrink: 0;
}

.team-member-info {
  flex: 1;
  min-width: 0;
}

.team-member-name {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 4px;
  color: #e6eef6;
}

.team-member-id {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 4px;
}

.team-member-stats {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.team-stat-badge {
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.2);
  font-size: 12px;
  color: var(--accent2);
}

.team-expand-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--accent2);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s;
  flex-shrink: 0;
}

.team-expand-btn:hover {
  background: rgba(6, 182, 212, 0.1);
  border-color: var(--accent2);
}

.team-children {
  margin-top: 8px;
  margin-left: 0 !important;
  padding-left: 0 !important;
  border-left: none;
}

.team-expand-indicator {
  display: inline-block;
  color: var(--accent1);
  font-size: 12px;
  margin-left: 8px;
  transition: transform 0.2s;
  vertical-align: middle;
}

.team-level-indicator {
  position: absolute;
  left: -30px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 2px;
  background: rgba(124, 58, 237, 0.5);
}

.team-member-wrapper {
  position: relative;
  margin-left: 0 !important;
  padding-left: 0 !important;
  margin-right: 0 !important;
}

/* Ensure no indentation for team members at any level */
#teamPage .team-member-wrapper,
.team-member-wrapper .team-member-wrapper {
  margin-left: 0 !important;
  padding-left: 0 !important;
}

.member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  transition: background 0.2s;
}

.member:hover {
  background: rgba(255, 255, 255, 0.01);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* Commission Table */
.comm-table {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.comm-item {
  padding: 12px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
  text-align: center;
}

.comm-item h4 {
  margin: 0;
  font-size: 14px;
}

.comm-item p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* Grid Layout */
.grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 18px;
  margin-top: 18px;
}

/* Error/Success Messages */
.message {
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 16px;
}

.message.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--error);
}

.message.success {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--success);
}

/* Loading Spinner */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  border-top-color: var(--accent1);
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Page Container */
.page {
  display: none;
}

.page.active {
  display: block;
}

/* Auth Pages */
.auth-container {
  max-width: 400px;
  margin: 60px auto;
  padding: 18px;
}

.auth-card {
  padding: 32px;
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-header h1 {
  font-size: 24px;
  margin-bottom: 8px;
}

.auth-header p.sub {
  font-size: 14px;
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  color: var(--muted);
  font-size: 14px;
}

.auth-footer a {
  color: var(--accent2);
  text-decoration: none;
  cursor: pointer;
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 880px) {
  .grid {
    grid-template-columns: 1fr;
  }
  
  .right-col {
    order: 2;
  }
  
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  .comm-table {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .stats {
    flex-direction: column;
  }
  
  .stat {
    min-width: 100%;
  }

  .ref-row {
    flex-direction: column;
    align-items: stretch;
  }

  .ref-link {
    flex-direction: column;
    align-items: flex-start;
  }

  #referralLink {
    white-space: normal;
    overflow: visible;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .header-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Profile Page */
.profile-section {
  margin-bottom: 24px;
}

.profile-section h3 {
  margin: 0 0 16px 0;
  font-size: 18px;
  color: var(--accent2);
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

@media (max-width: 600px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }
}

/* Back Button */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  color: var(--accent2);
  text-decoration: none;
  cursor: pointer;
  font-size: 14px;
  transition: color 0.2s;
}

.back-btn:hover {
  color: var(--accent1);
  text-decoration: underline;
}

/* Hide payment history table on dashboard - only show on dedicated payment history page */
/* Target any table within the Payment History card on dashboard */
#dashboardPage .card table,
#dashboardPage table {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  opacity: 0 !important;
}

/* Explicitly hide payment history table containers if they exist */
#dashboardPage #paymentHistoryTableContainer,
#dashboardPage #paymentTable,
#dashboardPage .card:has(h3:contains("Payment History")) + * table,
#dashboardPage .card:has(#viewPaymentHistoryBtn) + * table {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
}

/* Ensure payment history table is visible on the dedicated payment history page */
#paymentHistoryPage table {
  display: table !important;
  visibility: visible !important;
  height: auto !important;
  overflow: visible !important;
  opacity: 1 !important;
}

/* Mobile-specific: Hide all tables on dashboard and remove team indentation */
/* Apply to all mobile devices (phones and small tablets) */
@media (max-width: 768px), (max-width: 1024px) and (orientation: portrait) {
  /* Hide payment history tables on dashboard */
  #dashboardPage .card table,
  #dashboardPage table,
  #dashboardPage .card:has(#viewPaymentHistoryBtn) ~ * table {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    opacity: 0 !important;
  }
  
  /* Remove all team indentation on mobile */
  .team-member-wrapper,
  #teamPage .team-member-wrapper,
  .team-member-wrapper .team-member-wrapper,
  .team-member-wrapper[style*="margin-left"],
  .team-member-wrapper[style*="padding-left"] {
    margin-left: 0 !important;
    padding-left: 0 !important;
    margin-right: 0 !important;
  }
  
  .team-children,
  #teamPage .team-children,
  .team-member-wrapper .team-children {
    margin-left: 0 !important;
    padding-left: 0 !important;
    margin-right: 0 !important;
  }
  
  .team-member-card {
    margin-left: 0 !important;
    padding-left: 0 !important;
  }
}

