/* ============================================================
   The Win Ways MLM — Main Stylesheet
   ============================================================ */

/* ── Root Variables ── */
:root {
  --primary:      #6366f1;
  --primary-dark: #4f46e5;
  --success:      #10b981;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --info:         #0ea5e9;
  --dark:         #0f172a;
  --sidebar-w:    260px;
  --topbar-h:     64px;
  --radius:       12px;
  --shadow:       0 4px 24px rgba(0,0,0,.08);
  --font:         'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  --gradient-info:    linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  --gradient-danger:  linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 14px;
  color: #374151;
  background: #f1f5f9;
  margin: 0;
}

a { text-decoration: none; }

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-body {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #1e3a5f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-wrapper {
  width: 100%;
  max-width: 480px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 24px;
  color: #fff;
}

.auth-brand .brand-logo {
  width: 72px; height: 72px;
  background: var(--gradient-primary);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: #fff;
  margin: 0 auto 12px;
  box-shadow: 0 8px 32px rgba(99,102,241,.4);
}

.auth-brand h1 { font-size: 24px; font-weight: 700; margin: 0 0 4px; }
.auth-brand p  { font-size: 14px; opacity: .7; margin: 0; }

.admin-brand .brand-logo { background: var(--gradient-danger); }

.auth-card {
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,.3);
}

.auth-card-wide { max-width: 600px; margin: 0 auto; }

.auth-card-header {
  padding: 28px 28px 0;
  text-align: center;
}

.auth-card-header h2 { font-size: 22px; font-weight: 700; color: var(--dark); margin: 0 0 4px; }
.auth-card-header p  { color: #6b7280; margin: 0 0 20px; }

.auth-card-body { padding: 24px 28px 28px; }

.auth-divider {
  text-align: center;
  margin: 20px 0;
  position: relative;
}

.auth-divider::before {
  content: '';
  position: absolute;
  top: 50%; left: 0; right: 0;
  height: 1px;
  background: #e5e7eb;
}

.auth-divider span {
  position: relative;
  background: #fff;
  padding: 0 12px;
  color: #9ca3af;
  font-size: 12px;
}

.btn-eye {
  background: #f9fafb !important;
  border: 1px solid #d1d5db !important;
  cursor: pointer;
}

.sponsor-verified { font-size: 13px; color: var(--success); }

/* ============================================================
   APP LAYOUT (SIDEBAR + MAIN)
   ============================================================ */
.app-body { background: #f1f5f9; }

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--dark);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform .3s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  color: #fff; font-weight: 700; font-size: 15px;
}

.sidebar-logo i { font-size: 22px; color: var(--primary); }

.sidebar-toggle-btn {
  display: none;
  background: transparent;
  border: none;
  color: rgba(255,255,255,.5);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}

.sidebar-user {
  display: flex; align-items: center; gap: 12px;
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.user-avatar {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--gradient-primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}

.admin-avatar { background: var(--gradient-danger); font-size: 20px; }

.user-info .user-name  { color: #fff; font-weight: 600; font-size: 13px; }
.user-info .user-level { color: rgba(255,255,255,.4); font-size: 11px; margin-top: 2px; }

/* Sidebar Nav */
.sidebar-nav { flex: 1; padding: 8px 0; }

.sidebar-nav ul { list-style: none; margin: 0; padding: 0; }

.sidebar-nav li.nav-label {
  padding: 16px 16px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,.25);
  font-weight: 600;
}

.sidebar-nav li a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  color: rgba(255,255,255,.6);
  border-radius: 8px;
  margin: 2px 8px;
  font-size: 13px;
  font-weight: 500;
  transition: all .2s;
}

.sidebar-nav li a:hover,
.sidebar-nav li.active a {
  color: #fff;
  background: rgba(99,102,241,.2);
}

.sidebar-nav li.active a {
  color: var(--primary);
  background: rgba(99,102,241,.15);
  border-left: 3px solid var(--primary);
  margin-left: 8px;
  padding-left: 13px;
}

.sidebar-nav li a i { font-size: 16px; width: 20px; flex-shrink: 0; }

/* Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
}

/* Main Wrapper */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .3s ease;
}

/* Top Navbar */
.top-navbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}

.navbar-left { display: flex; align-items: center; gap: 16px; }
.navbar-right { display: flex; align-items: center; gap: 12px; }

.menu-toggle {
  background: none; border: none;
  font-size: 22px; cursor: pointer;
  color: #374151;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background .15s;
}

.menu-toggle:hover { background: #f3f4f6; }

.breadcrumb { font-size: 13px; }
.breadcrumb-item a { color: var(--primary); }

.page-title { font-size: 16px; font-weight: 600; }

.nav-referral {
  display: flex; align-items: center; gap: 6px;
  background: #f3f4f6;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
}

.ref-code { font-size: 12px; font-weight: 700; color: var(--primary); }

.btn-copy {
  background: none; border: none;
  cursor: pointer; color: #6b7280;
  padding: 0; font-size: 13px;
}

.btn-copy:hover { color: var(--primary); }

.nav-user-btn {
  display: flex; align-items: center; gap: 8px;
  background: none; border: none; cursor: pointer;
  font-size: 13px; color: #374151;
  padding: 6px 10px; border-radius: 8px;
  font-weight: 500;
}

.nav-user-btn:hover { background: #f3f4f6; }

.user-avatar-sm {
  width: 32px; height: 32px;
  background: var(--gradient-primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 700;
}

/* Page Content */
.page-content {
  flex: 1;
  padding: 24px;
}

.page-header {
  margin-bottom: 20px;
}

.page-heading {
  font-size: 20px;
  font-weight: 700;
  color: var(--dark);
  margin: 0 0 4px;
}

/* Footer */
.page-footer {
  padding: 16px 24px;
  border-top: 1px solid #e5e7eb;
  text-align: center;
  color: #9ca3af;
  font-size: 12px;
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: transform .2s;
}

.stat-card:hover { transform: translateY(-2px); }

.stat-card.gradient-primary { background: var(--gradient-primary); color: #fff; }
.stat-card.gradient-success  { background: var(--gradient-success);  color: #fff; }
.stat-card.gradient-warning  { background: var(--gradient-warning);  color: #fff; }
.stat-card.gradient-info     { background: var(--gradient-info);     color: #fff; }
.stat-card.gradient-danger   { background: var(--gradient-danger);   color: #fff; }

.stat-card.stat-card-light {
  background: #fff;
  border: 1px solid #e5e7eb;
}

.stat-icon {
  font-size: 32px;
  opacity: .85;
  flex-shrink: 0;
}

.stat-value { font-size: 22px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; opacity: .8; margin-top: 4px; }

/* ============================================================
   CARD PANELS
   ============================================================ */
.card-panel {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #f3f4f6;
}

.card-panel-header h6 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--dark);
}

.card-panel-body { padding: 20px; }
.card-panel-footer { border-top: 1px solid #f3f4f6; }

/* ============================================================
   TABLES
   ============================================================ */
.table { margin: 0; }
.table th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #fff;
  padding: 12px 16px;
  white-space: nowrap;
}
.table td { padding: 12px 16px; vertical-align: middle; }
.table-hover tbody tr:hover { background: #f9fafb; }

.btn-xs { padding: 2px 8px; font-size: 11px; border-radius: 4px; }

/* ============================================================
   BADGES & AVATARS
   ============================================================ */
.avatar-xs {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--gradient-primary);
  color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.profile-avatar {
  width: 80px; height: 80px;
  border-radius: 20px;
  background: var(--gradient-primary);
  color: #fff; font-size: 28px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto;
}

/* ============================================================
   MATRIX COMPONENTS
   ============================================================ */
.matrix-level-card {
  background: #fff;
  border: 2px solid #e5e7eb;
  border-radius: var(--radius);
  padding: 16px;
  transition: all .2s;
}

.matrix-level-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.matrix-level-card.status-cycled { border-color: var(--info); background: #f0f9ff; }

.mlc-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}

.level-badge-sm {
  font-size: 12px; font-weight: 700;
  color: var(--primary);
  background: rgba(99,102,241,.1);
  padding: 2px 8px; border-radius: 6px;
}

.mlc-slots {
  display: flex; gap: 6px; justify-content: center;
  margin: 8px 0;
}

.slot-dot {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid #e5e7eb;
  background: #f3f4f6;
  transition: all .2s;
}

.slot-dot.filled {
  background: var(--primary);
  border-color: var(--primary);
}

.mlc-info { text-align: center; font-size: 11px; color: #6b7280; }
.mlc-footer { margin-top: 10px; }

.rebirth-tag {
  font-size: 10px; color: var(--warning);
  font-weight: 600; margin-left: 6px;
}

/* Matrix Progress (dashboard) */
.matrix-progress-wrap { text-align: center; }

.level-badge {
  display: inline-block;
  background: var(--gradient-primary);
  color: #fff;
  font-size: 16px; font-weight: 700;
  padding: 8px 20px; border-radius: 40px;
  margin-bottom: 16px;
}

.matrix-slots {
  display: flex; gap: 12px; justify-content: center;
  margin-bottom: 12px;
}

.matrix-slot {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 64px; height: 72px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px 4px;
  font-size: 11px; color: #9ca3af;
}

.matrix-slot.filled {
  border-color: var(--primary);
  background: rgba(99,102,241,.08);
  color: var(--primary);
  font-weight: 600;
}

.matrix-slot i { font-size: 24px; }

/* Level Circle (upgrade page) */
.level-circle {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--gradient-primary);
  color: #fff; font-size: 18px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto;
  box-shadow: 0 4px 16px rgba(99,102,241,.3);
}

.level-circle-next {
  background: var(--gradient-success);
  box-shadow: 0 4px 16px rgba(16,185,129,.3);
}

/* ============================================================
   INCOME BREAKDOWN
   ============================================================ */
.income-breakdown { display: flex; flex-direction: column; gap: 12px; }

.income-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #f3f4f6;
}

.income-item:last-child { border-bottom: none; }

.income-dot {
  width: 10px; height: 10px;
  border-radius: 50%; flex-shrink: 0;
}

.income-label { flex: 1; font-size: 13px; color: #374151; }
.income-amount { font-weight: 600; font-size: 13px; }

/* ============================================================
   PROFILE
   ============================================================ */
.referral-box code {
  color: var(--primary);
  font-size: 16px;
  letter-spacing: 1px;
}

.info-rows { display: flex; flex-direction: column; gap: 6px; }

.info-row {
  display: flex; justify-content: space-between;
  font-size: 12px; color: #6b7280;
  padding: 4px 0;
  border-bottom: 1px solid #f3f4f6;
}

.info-row span { color: #9ca3af; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #9ca3af;
}

.empty-state i { font-size: 48px; display: block; margin-bottom: 12px; }
.empty-state p { margin: 0; font-size: 14px; }

/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */
.toast-container-custom {
  position: fixed; top: 20px; right: 20px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}

.toast-msg {
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  font-size: 13px; font-weight: 500;
  color: #fff;
  animation: slideIn .3s ease;
  min-width: 240px;
}

.toast-msg.success { background: var(--success); }
.toast-msg.error   { background: var(--danger); }
.toast-msg.info    { background: var(--info); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open { display: block; }

  .sidebar-toggle-btn { display: block; }

  .main-wrapper { margin-left: 0; }

  .page-content { padding: 16px; }

  .top-navbar { padding: 0 16px; }

  .stat-value { font-size: 18px; }

  .nav-referral { display: none; }

  .auth-card-body { padding: 20px; }

  .auth-wrapper { max-width: 100%; }
}

@media (max-width: 576px) {
  .stat-card { padding: 14px; gap: 10px; }
  .stat-icon { font-size: 24px; }
  .stat-value { font-size: 16px; }
}

/* ============================================================
   ADMIN-SPECIFIC
   ============================================================ */
.admin-sidebar .sidebar-logo i { color: #ef4444; }
.admin-navbar  { border-bottom-color: #fee2e2; }

.admin-auth-body {
  background: linear-gradient(135deg, #0f172a 0%, #3b0764 50%, #1e1b4b 100%);
}

.level-badge-lg {
  width: 56px; height: 56px;
  background: var(--gradient-primary);
  color: #fff; font-size: 14px; font-weight: 700;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto;
}

/* Level number in matrix table */
.level-num { color: var(--primary); font-size: 13px; }

/* Upgrade arrow */
.upgrade-arrow { margin: 8px 0; }
