/* ═══════════════════════════════════════════════════════════════
   PUBDAY AFFILIATION — Design system mobile-first
   Cohérent avec la PWA Pubday (orange / ink / cards arrondies)
   ═══════════════════════════════════════════════════════════════ */

:root {
  --brand: #F26E22;
  --brand-dark: #BF470C;
  --brand-light: #FFE7CC;
  --brand-soft: #FFF8F2;
  --brand-glow: rgba(242, 110, 34, 0.18);

  --ink: #0C0D10;
  --ink-2: #2C2F38;
  --muted: #6B7280;
  --muted-2: #9CA3AF;
  --line: #E8EAEE;

  --bg: #FBFAF7;
  --bg-card: #FFFFFF;

  --green: #22C55E;
  --blue: #3B82F6;
  --gold: #F59E0B;

  --radius: 14px;
  --radius-lg: 22px;
  --radius-xl: 28px;

  --shadow: 0 1px 3px rgba(12, 13, 16, 0.04), 0 4px 12px rgba(12, 13, 16, 0.06);
  --shadow-lg: 0 12px 36px rgba(12, 13, 16, 0.10);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
}
.screen.active {
  display: block;
}

a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}
.link {
  color: var(--brand);
  font-weight: 600;
  word-break: break-all;
}

/* ─── BUTTONS ────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 22px;
  border-radius: 12px;
  border: 0;
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  box-shadow: 0 4px 14px var(--brand-glow);
}
.btn-light {
  background: #fff;
  color: var(--ink);
  border: 1.5px solid var(--line);
}
.btn-full { width: 100%; }

.btn-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 22px;
  cursor: pointer;
  border-radius: 10px;
}
.btn-icon:active { background: var(--line); }

/* Bouton texte dans le header — clair et visible */
.btn-text-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--line);
  color: var(--ink);
  border: 0;
  border-radius: 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-text-header:hover { background: var(--brand-soft); color: var(--brand-dark); }
.btn-text-header:active { transform: scale(0.97); }

/* ─── LOGIN / SIGNUP screens ─────────────────────────────────── */

.login-wrap {
  max-width: 440px;
  margin: 0 auto;
  padding: calc(40px + env(safe-area-inset-top, 0)) 24px 40px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-block {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 36px;
}

.logo-p {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 32px;
  line-height: 1;
  letter-spacing: -1px;
}
.logo-p-small {
  width: 36px;
  height: 36px;
  font-size: 22px;
  border-radius: 10px;
}
.logo-dot {
  color: var(--ink);
}

.brand-name {
  font-weight: 800;
  font-size: 22px;
  color: var(--ink);
  letter-spacing: -0.3px;
}
.brand-sub {
  color: var(--brand);
  font-weight: 600;
  font-size: 16px;
}

.screen-title {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--ink);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}
.screen-sub {
  color: var(--muted);
  font-size: 15px;
  margin-bottom: 28px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.field-hint {
  font-size: 11px;
  color: var(--muted-2);
  margin-top: 2px;
}
.field input {
  height: 52px;
  padding: 0 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-size: 16px;       /* 16px évite zoom auto iOS */
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-glow);
}

/* Wrapper input mot de passe avec bouton œil */
.password-wrap {
  position: relative;
  display: block;
}
.password-wrap input {
  padding-right: 56px;
  width: 100%;
}
.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 22px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}
.password-toggle:active {
  background: var(--line);
}

/* 🆕 Encart code parrainage très voyant en haut du signup */
.referrer-highlight {
  background: linear-gradient(135deg, #FFF8F2 0%, #FFE7CC 100%);
  border: 2px dashed var(--brand);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 6px;
}
.referrer-highlight-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--brand-dark);
  margin-bottom: 4px;
}
.referrer-highlight-sub {
  font-size: 13px;
  color: #5a3010;
  margin-bottom: 12px;
  line-height: 1.4;
}
.referrer-highlight-input {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 1.5px solid var(--brand);
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  background: #fff;
  color: var(--ink);
  font-family: 'SF Mono', Menlo, Consolas, monospace;
}
.referrer-highlight-input:focus {
  outline: none;
  border-color: var(--brand-dark);
  box-shadow: 0 0 0 4px var(--brand-glow);
}

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

/* ─── DASHBOARD ───────────────────────────────────────────────── */

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top, 0)) 16px 12px;
  background: rgba(251, 250, 247, 0.95);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand-block-small {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-title {
  font-weight: 800;
  font-size: 17px;
  color: var(--ink);
}

.dashboard {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 100px;
}

/* HERO card */
.hero-card {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  padding: 28px 24px;
  border-radius: var(--radius-xl);
  box-shadow: 0 12px 32px var(--brand-glow);
  text-align: center;
}
.hero-grade {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.hero-grade-label::before {
  content: '★';
  margin-right: 4px;
  color: #FFD96B;
}
.hero-points {
  opacity: 0.85;
}
.hero-balance-amount {
  font-size: 56px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -2px;
  margin: 8px 0 4px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
.hero-balance-label {
  font-size: 14px;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 12px;
}
.hero-meta {
  font-size: 13px;
  opacity: 0.85;
  margin-bottom: 20px;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 14px;
  letter-spacing: -0.2px;
}
.card-info {
  background: var(--brand-soft);
  border: 1.5px dashed var(--brand);
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 13px;
}

/* Code parrainage */
.referral-code-block {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}
.referral-code {
  flex: 1;
  background: var(--brand-soft);
  border: 1.5px dashed var(--brand);
  border-radius: 12px;
  padding: 16px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 22px;
  font-weight: 800;
  color: var(--brand-dark);
  letter-spacing: 1px;
  text-align: center;
}
.btn-copy {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #fff;
  font-size: 22px;
  cursor: pointer;
}
.btn-copy:active {
  background: var(--brand-soft);
}
.referral-share-url {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
  word-break: break-all;
}

/* Boutons partage */
.share-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.share-btn {
  padding: 14px 12px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s;
}
.share-btn:active { transform: scale(0.97); }
.share-btn.whatsapp { background: #25D366; }
.share-btn.sms { background: #5E7EFF; }
.share-btn.email { background: #888; }
.share-btn.copy { background: var(--ink); }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.stat {
  text-align: center;
  background: var(--brand-soft);
  border-radius: 12px;
  padding: 14px 6px;
}
.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--brand);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* Progress */
.progress-block {
  background: var(--brand-soft);
  border-radius: 12px;
  padding: 14px;
}
.progress-label {
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 10px;
  text-align: center;
}
.progress-bar {
  height: 10px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-dark));
  border-radius: 999px;
  transition: width 0.5s ease-out;
}

/* Listes */
.filleuls-list, .payouts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.filleul-item, .payout-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.filleul-info, .payout-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.filleul-name, .payout-date {
  font-weight: 700;
  font-size: 14px;
}
.filleul-meta, .payout-status {
  font-size: 12px;
  color: var(--muted);
}
.filleul-grade-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.payout-amount {
  font-weight: 800;
  color: var(--brand);
  font-size: 16px;
}
.payout-status-pending { color: var(--gold); }
.payout-status-paid { color: var(--green); }

/* Info list */
.info-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.info-list li {
  padding-left: 24px;
  position: relative;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
}
.info-list li::before {
  content: '•';
  position: absolute;
  left: 8px;
  color: var(--brand);
  font-weight: 800;
}

/* Footer */
.app-footer {
  background: var(--ink);
  color: rgba(255, 255, 255, 0.7);
  padding: 18px;
  text-align: center;
  font-size: 12px;
}

/* ─── ARBRE GÉNÉALOGIQUE (vue branches) ──────────────────────── */
.tree-view {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tree-node {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.tree-node-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  position: relative;
}
.tree-node-row.is-me {
  background: linear-gradient(135deg, var(--brand-soft), #fff);
  border-color: var(--brand);
}

.tree-medal {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}
.tree-medal.starter { background: #60A5FA; }
.tree-medal.partner { background: #34D399; }
.tree-medal.leader { background: #F0AF1E; color: var(--ink); }
.tree-medal.senior_leader { background: #A055DC; }
.tree-medal.top_leader { background: #DC3232; }

.tree-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.tree-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tree-meta {
  font-size: 11px;
  color: var(--muted);
}

.tree-stats {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  font-size: 11px;
}
.tree-stat {
  padding: 4px 8px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-radius: 6px;
  font-weight: 700;
  white-space: nowrap;
}
.tree-stat.subs { background: #ECFDF5; color: var(--green); }

.tree-children {
  margin-left: 24px;
  padding-left: 12px;
  border-left: 2px solid var(--line);
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tree-children::before {
  content: '';
  position: absolute;
}
.tree-empty {
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
  padding: 10px 14px;
}

/* Toast / alerte simple */
.toast {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0));
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 22px;
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-6px);
}
