/**
 * Apexmart MLM System – Frontend Styles
 * Version: 1.0.0
 *
 * Scoped under .apex-* to avoid conflicts with any theme or other plugin.
 * Compatible with Elementor, WooCommerce, and any standard WordPress theme.
 */

/* ── CSS Custom Properties ─────────────────────────────────────────────────── */
:root {
  --apex-primary:        #5a23c8;
  --apex-primary-dark:   #3f189a;
  --apex-primary-light:  #7c4de0;
  --apex-accent:         #ff6b35;
  --apex-success:        #22c55e;
  --apex-danger:         #ef4444;
  --apex-warning:        #f59e0b;
  --apex-info:           #3b82f6;

  --apex-bg:             #f4f6fb;
  --apex-card-bg:        #ffffff;
  --apex-border:         #e2e8f0;
  --apex-text:           #1e293b;
  --apex-text-muted:     #64748b;
  --apex-text-light:     #94a3b8;

  --apex-radius:         10px;
  --apex-radius-lg:      16px;
  --apex-shadow:         0 2px 12px rgba(0,0,0,.08);
  --apex-shadow-lg:      0 8px 32px rgba(0,0,0,.12);
  --apex-font:           -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --apex-transition:     .2s ease;
}

/* ── Reset / Base ──────────────────────────────────────────────────────────── */
.apex-dashboard,
.apex-card,
.apex-wallet-wrap,
.apex-register-card,
.apex-login-card {
  box-sizing: border-box;
  font-family: var(--apex-font);
  color: var(--apex-text);
}

/* ── Card ──────────────────────────────────────────────────────────────────── */
.apex-card {
  background: var(--apex-card-bg);
  border: 1px solid var(--apex-border);
  border-radius: var(--apex-radius-lg);
  padding: 28px 32px;
  box-shadow: var(--apex-shadow);
  margin-bottom: 24px;
}
.apex-card h3 {
  margin: 0 0 18px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--apex-text);
}
.apex-card-header {
  margin-bottom: 24px;
}
.apex-card-header h2 {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 700;
}
.apex-card-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.apex-card-head-row h3 {
  margin: 0;
}

/* ── Dashboard Layout ──────────────────────────────────────────────────────── */
.apex-dashboard {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  background: var(--apex-bg);
  border-radius: var(--apex-radius-lg);
}

/* Dashboard Header */
.apex-dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  background: var(--apex-primary);
  background: linear-gradient(135deg, var(--apex-primary-dark), var(--apex-primary-light));
  color: #fff;
  border-radius: var(--apex-radius-lg);
  padding: 24px 28px;
  margin-bottom: 28px;
  box-shadow: var(--apex-shadow-lg);
}
.apex-user-row {
  display: flex;
  align-items: center;
  gap: 16px;
}
.apex-avatar {
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.4);
}
.apex-user-meta .apex-greeting {
  margin: 0;
  font-size: .85rem;
  opacity: .8;
}
.apex-user-meta .apex-username {
  margin: 4px 0 6px;
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
}
.apex-user-meta .apex-member-id {
  margin: 0;
  font-size: .8rem;
  opacity: .8;
}
.apex-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ── KPI Stats Grid ────────────────────────────────────────────────────────── */
.apex-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}
.apex-stat-widget {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--apex-card-bg);
  border: 1px solid var(--apex-border);
  border-radius: var(--apex-radius-lg);
  padding: 20px 18px;
  box-shadow: var(--apex-shadow);
  transition: transform var(--apex-transition), box-shadow var(--apex-transition);
}
.apex-stat-widget:hover {
  transform: translateY(-2px);
  box-shadow: var(--apex-shadow-lg);
}
.apex-stat-icon {
  font-size: 1.8rem;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.apex-stat-earnings .apex-stat-icon  { background: #ede9fe; color: var(--apex-primary); }
.apex-stat-wallet   .apex-stat-icon  { background: #d1fae5; color: #059669; }
.apex-stat-package  .apex-stat-icon  { background: #fef3c7; color: #d97706; }
.apex-stat-team     .apex-stat-icon  { background: #dbeafe; color: #2563eb; }
.apex-stat-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.apex-stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--apex-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.apex-stat-label {
  font-size: .78rem;
  color: var(--apex-text-muted);
  margin-top: 3px;
}

/* ── Progress Bar ──────────────────────────────────────────────────────────── */
.apex-bonus-card .apex-progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: .82rem;
  color: var(--apex-text-muted);
  margin-bottom: 8px;
}
.apex-progress-track {
  background: #e2e8f0;
  border-radius: 99px;
  height: 10px;
  overflow: hidden;
}
.apex-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--apex-primary), var(--apex-primary-light));
  border-radius: 99px;
  transition: width .6s ease;
  min-width: 4px;
}
.apex-progress-pct {
  font-size: .82rem;
  color: var(--apex-text-muted);
  margin: 6px 0 0;
  text-align: right;
}

/* ── Referral Widget ───────────────────────────────────────────────────────── */
.apex-referral-hint { font-size: .85rem; color: var(--apex-text-muted); margin: 0 0 14px; }
.apex-referral-row {
  display: flex;
  gap: 8px;
}
.apex-ref-input {
  flex: 1;
  min-width: 0;
  border: 1.5px solid var(--apex-border);
  border-radius: var(--apex-radius);
  padding: 10px 14px;
  font-size: .9rem;
  color: var(--apex-text-muted);
  background: var(--apex-bg);
  font-family: var(--apex-font);
}

/* ── Upgrade CTA ───────────────────────────────────────────────────────────── */
.apex-upgrade-card {
  background: linear-gradient(135deg, var(--apex-primary-dark), var(--apex-primary-light));
  color: #fff;
  border: none;
}
.apex-upgrade-card h3 { color: #fff; margin-bottom: 8px; font-size: 1.3rem; }
.apex-upgrade-card p  { color: rgba(255,255,255,.85); margin: 0 0 8px; }
.apex-upgrade-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}

/* ── Balance Card ──────────────────────────────────────────────────────────── */
.apex-balance-card {
  background: linear-gradient(135deg, var(--apex-primary-dark), var(--apex-primary-light));
  color: #fff;
  border: none;
}
.apex-balance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.apex-balance-label {
  font-size: .85rem;
  opacity: .8;
  margin-bottom: 4px;
}
.apex-balance-amount {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.apex-balance-icon {
  font-size: 2.5rem;
  opacity: .3;
}

/* ── Table ─────────────────────────────────────────────────────────────────── */
.apex-table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.apex-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.apex-table th,
.apex-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--apex-border);
  white-space: nowrap;
}
.apex-table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--apex-text-muted);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.apex-table tbody tr:hover {
  background: #f8fafc;
}
.apex-credit { color: var(--apex-success); font-weight: 600; }
.apex-debit  { color: var(--apex-danger);  font-weight: 600; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.apex-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .03em;
}
.apex-badge-active,
.apex-badge-credit     { background: #d1fae5; color: #065f46; }
.apex-badge-inactive,
.apex-badge-debit      { background: #fee2e2; color: #991b1b; }
.apex-badge-pending    { background: #fef3c7; color: #92400e; }
.apex-badge-approved   { background: #d1fae5; color: #065f46; }
.apex-badge-rejected   { background: #fee2e2; color: #991b1b; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.apex-btn {
  display: inline-block;
  padding: 10px 22px;
  border-radius: var(--apex-radius);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--apex-transition), transform var(--apex-transition), box-shadow var(--apex-transition);
  text-decoration: none;
  border: none;
  font-family: var(--apex-font);
  line-height: 1.4;
}
.apex-btn:hover          { transform: translateY(-1px); box-shadow: var(--apex-shadow); }
.apex-btn-primary        { background: var(--apex-primary); color: #fff; }
.apex-btn-primary:hover  { background: var(--apex-primary-dark); color: #fff; }
.apex-btn-outline {
  background: transparent;
  border: 1.5px solid rgba(255,255,255,.6);
  color: #fff;
}
.apex-btn-outline:hover  { background: rgba(255,255,255,.15); color: #fff; }
.apex-btn-full           { width: 100%; text-align: center; }
.apex-btn-sm             { padding: 6px 14px; font-size: .8rem; }
.apex-btn-lg             { padding: 14px 32px; font-size: 1rem; }
.apex-btn:disabled       { opacity: .6; cursor: not-allowed; transform: none; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.apex-form { width: 100%; }
.apex-form-group {
  margin-bottom: 18px;
}
.apex-form-group label {
  display: block;
  font-size: .88rem;
  font-weight: 600;
  color: var(--apex-text);
  margin-bottom: 6px;
}
.apex-required { color: var(--apex-danger); }
.apex-form-group input,
.apex-form-group select,
.apex-form-group textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 14px;
  border: 1.5px solid var(--apex-border);
  border-radius: var(--apex-radius);
  font-size: .92rem;
  font-family: var(--apex-font);
  color: var(--apex-text);
  background: #fff;
  transition: border-color var(--apex-transition), box-shadow var(--apex-transition);
  outline: none;
}
.apex-form-group input:focus,
.apex-form-group select:focus,
.apex-form-group textarea:focus {
  border-color: var(--apex-primary);
  box-shadow: 0 0 0 3px rgba(90,35,200,.1);
}
.apex-form-group textarea { resize: vertical; min-height: 80px; }

.apex-input-group {
  position: relative;
  display: flex;
}
.apex-input-group input {
  flex: 1;
  padding-right: 44px;
}
.apex-toggle-pass {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
  color: var(--apex-text-muted);
}
.apex-form-links {
  text-align: center;
  font-size: .85rem;
  margin-top: 12px;
}
.apex-form-links a { color: var(--apex-primary); text-decoration: none; }
.apex-form-links a:hover { text-decoration: underline; }

/* ── Auth Card Wrappers ────────────────────────────────────────────────────── */
.apex-register-card,
.apex-login-card {
  max-width: 480px;
  margin: 32px auto;
}

/* ── Messages ──────────────────────────────────────────────────────────────── */
.apex-msg {
  padding: 12px 16px;
  border-radius: var(--apex-radius);
  font-size: .9rem;
  margin-bottom: 16px;
  line-height: 1.5;
}
.apex-msg-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.apex-msg-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* ── Disclaimer ────────────────────────────────────────────────────────────── */
.apex-disclaimer {
  font-size: .82rem;
  color: var(--apex-text-muted);
  background: #f8fafc;
  border-left: 3px solid var(--apex-primary);
  border-radius: 0 6px 6px 0;
  padding: 8px 12px;
  margin-bottom: 18px;
  line-height: 1.6;
}
.apex-site-disclaimer {
  font-size: .78rem;
  color: var(--apex-text-light);
  text-align: center;
  margin-top: 8px;
  line-height: 1.6;
  padding: 0 16px;
}

/* ── Empty States ──────────────────────────────────────────────────────────── */
.apex-empty {
  color: var(--apex-text-muted);
  font-style: italic;
  text-align: center;
  padding: 24px 0;
}

/* ── Text Links ────────────────────────────────────────────────────────────── */
.apex-text-link {
  color: var(--apex-primary);
  font-size: .85rem;
  text-decoration: none;
  font-weight: 500;
}
.apex-text-link:hover { text-decoration: underline; }

.apex-login-prompt { max-width: 400px; margin: 32px auto; text-align: center; }
.apex-info         { font-size: .9rem; color: var(--apex-text-muted); }

/* ── Wallet Wrap ───────────────────────────────────────────────────────────── */
.apex-wallet-wrap { max-width: 720px; margin: 0 auto; padding: 16px; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .apex-dashboard { padding: 16px 10px 40px; }
  .apex-card      { padding: 20px 16px; }
  .apex-stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .apex-stat-value { font-size: 1rem; }
  .apex-dashboard-header { flex-direction: column; align-items: flex-start; }
  .apex-header-actions   { width: 100%; }
  .apex-upgrade-inner    { flex-direction: column; }
  .apex-referral-row     { flex-direction: column; }
  .apex-btn-full         { display: block; }
  .apex-balance-amount   { font-size: 1.6rem; }
}
@media (max-width: 400px) {
  .apex-stats-grid { grid-template-columns: 1fr; }
}
