/* =====================================================================
   Monika Growth Hub — Premium Design System
   FinTech + Corporate style: light theme, navy text, blue/purple accent,
   gold accent for rewards/ranks, soft shadows, rounded cards.
   ===================================================================== */

:root {
  /* Core palette */
  --navy: #0f172a;
  --navy-soft: #334155;
  --bg: #f6f7fb;
  --card-bg: #ffffff;
  --border: #e6e9f2;
  --muted: #64748b;

  /* Primary accent — blue/purple gradient */
  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --primary-dark: #4338ca;
  --primary-soft: #eef0ff;
  --gradient-primary: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);

  /* Gold accent — rewards, ranks, achievements */
  --gold: #d4af37;
  --gold-soft: #fdf6e3;
  --gradient-gold: linear-gradient(135deg, #f0c14b 0%, #d4af37 100%);

  /* Status colors */
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning: #d97706;
  --warning-soft: #fffbeb;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
  --nav-height: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--navy);
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Inter', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.55;
}

h1, h2, h3, h4 { color: var(--navy); letter-spacing: -0.01em; }

a { color: var(--primary); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--primary-dark); text-decoration: none; }

/* ===== App Shell / Navigation ===== */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--nav-height);
  background: #ffffff;
  color: var(--navy);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}

.topbar .brand {
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--navy);
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}

.topbar nav a {
  color: var(--navy-soft);
  opacity: 0.9;
  font-size: 0.92rem;
  font-weight: 500;
  padding: 6px 2px;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}
.topbar nav a.active,
.topbar nav a:hover {
  opacity: 1;
  color: var(--primary);
  text-decoration: none;
  border-bottom: 2px solid var(--primary);
}

.page-content {
  flex: 1;
  padding: 28px 24px 90px 24px;
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
}

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 66px;
  background: #ffffff;
  border-top: 1px solid var(--border);
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 30;
  box-shadow: 0 -2px 12px rgba(15, 23, 42, 0.05);
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.72rem;
  color: var(--muted);
  gap: 3px;
  font-weight: 500;
}
.bottom-nav a.active { color: var(--primary); }
.bottom-nav .icon { font-size: 1.3rem; }

@media (max-width: 680px) {
  .topbar nav { display: none; }
  .bottom-nav { display: flex; }
  .page-content { padding: 18px 14px 88px 14px; }
}

/* ===== Cards ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 22px;
  margin-bottom: 18px;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.card:hover { box-shadow: var(--shadow); }
.card h3 { margin-top: 0; }

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

.stat-card {
  text-align: left;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gradient-primary);
}
.stat-card .value {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.1;
}
.stat-card .label {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 4px;
  font-weight: 500;
}

/* ===== Badges (rank / status pills) ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}
.badge-gold { background: var(--gradient-gold); color: #5a4300; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-primary { background: var(--primary-soft); color: var(--primary-dark); }

/* ===== Forms ===== */
.login-card, .form-card {
  max-width: 420px;
  margin: 40px auto;
  padding: 34px;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.login-card h3, .form-card h3 { margin-bottom: 22px; text-align:center; }

.form-group { margin-bottom: 15px; }
.form-group label {
  display: block;
  font-size: 0.82rem;
  color: var(--navy-soft);
  font-weight: 600;
  margin-bottom: 5px;
}

input[type="text"], input[type="password"], input[type="email"] {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--navy);
  background: #fbfcfe;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  background: #fff;
}
input:disabled { background: #f1f2f6; color: var(--muted); }

button, .btn {
  width: 100%;
  padding: 12px;
  background: var(--gradient-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.98rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.15s ease;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.25);
}
button:hover, .btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(79, 70, 229, 0.32); }
button:active, .btn:active { transform: translateY(0); }
button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary {
  background: #fff;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  box-shadow: none;
}
.btn-secondary:hover { background: var(--primary-soft); box-shadow: none; }

.btn-gold {
  background: var(--gradient-gold);
  color: #5a4300;
  box-shadow: 0 4px 14px rgba(212, 175, 55, 0.3);
}

.error-msg {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 12px;
  border: 1px solid #fecaca;
}
.success-msg {
  background: var(--success-soft);
  color: var(--success);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 12px;
  border: 1px solid #bbf7d0;
}

/* ===== Referral code chip ===== */
.code-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  padding: 9px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-family: 'Consolas', monospace;
  border: 1px solid #dfe2ff;
}

/* ===== Genealogy tree ===== */
.tree-view { overflow-x: auto; }
.tree-node { display: inline-block; vertical-align: top; text-align: center; padding: 10px; }
.tree-node .node-box {
  display: inline-block;
  background: #fff;
  border: 2px solid var(--primary);
  border-radius: 10px;
  padding: 9px 15px;
  font-size: 0.85rem;
  font-weight: 700;
  min-width: 90px;
  box-shadow: var(--shadow-sm);
}
.tree-node .node-box.empty {
  border-style: dashed;
  color: var(--muted);
  border-color: var(--border);
  font-weight: 400;
  box-shadow: none;
}
.tree-children { display: flex; justify-content: center; gap: 8px; margin-top: 8px; }

@media (max-width: 680px) {
  .tree-node .node-box { min-width: 70px; font-size: 0.75rem; padding: 6px 8px; }
}

/* ===== PWA Install Button ===== */
.install-pwa-btn {
  width: auto;
  padding: 7px 14px;
  font-size: 0.85rem;
  background: var(--gradient-gold);
  color: #5a4300;
  box-shadow: 0 3px 10px rgba(212, 175, 55, 0.3);
  white-space: nowrap;
  margin-left: auto; /* pushes it to the right edge of the topbar on all screen sizes */
}
.install-pwa-hint {
  font-size: 0.72rem;
  color: var(--muted);
  max-width: 180px;
  margin: 0 0 0 auto;
  text-align: right;
}
@media (max-width: 680px) {
  .install-pwa-btn { padding: 6px 10px; font-size: 0.78rem; }
  .install-pwa-btn .btn-label { display: none; } /* icon-only on very small screens */
}

/* ===== Member Sidebar (icon-based, opens via ☰ toggle after login) ===== */
.sidebar-toggle {
  width: auto;
  padding: 8px 10px;
  background: transparent;
  color: var(--navy);
  box-shadow: none;
  font-size: 1.2rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-right: 8px;
}
.sidebar-toggle:hover { background: var(--primary-soft); box-shadow: none; transform: none; }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 40;
}

.member-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 260px;
  background: #fff;
  box-shadow: var(--shadow-lg);
  z-index: 41;
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.member-sidebar.open { transform: translateX(0); }

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  color: var(--navy);
}
.sidebar-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--gradient-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.sidebar-close {
  width: auto;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-size: 1rem;
  padding: 4px 8px;
}
.sidebar-close:hover { background: var(--bg); box-shadow: none; transform: none; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 10px 0;
  overflow-y: auto;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--navy-soft);
  font-size: 0.92rem;
  font-weight: 500;
  border-left: 3px solid transparent;
}
.sidebar-nav a .icon { font-size: 1.1rem; width: 22px; text-align: center; }
.sidebar-nav a:hover { background: var(--primary-soft); text-decoration: none; color: var(--primary); }
.sidebar-nav a.active { background: var(--primary-soft); color: var(--primary); border-left-color: var(--primary); font-weight: 700; }

@media (min-width: 681px) {
  /* On desktop, keep the sidebar as an overlay panel too (per request: hidden by default, opens via icon) */
  .member-sidebar { width: 280px; }
}
.hero {
  background: var(--gradient-primary);
  border-radius: var(--radius-lg);
  padding: 48px 28px;
  text-align: center;
  color: #fff;
  box-shadow: var(--shadow-lg);
  margin-bottom: 20px;
}
.hero h1 { color: #fff; margin-bottom: 8px; }
.hero p { color: rgba(255,255,255,0.9); }

/* Rank progress bar */
.progress-track {
  width: 100%;
  height: 10px;
  background: #eef0f5;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--gradient-gold);
  border-radius: 999px;
}
