/* ============================================================
   KOOPLE PARTNERS — DASHBOARD
   ============================================================ */

:root {
  --sidebar-w: 240px;
  --accent: #e94e77;
  --accent-dark: #c73d62;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --border: #e8e8ec;
  --text: #1a1a2e;
  --muted: #6b7280;
  --green: #10b981;
  --yellow: #f59e0b;
  --red: #ef4444;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --orange: #f97316;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

/* ---- Reset basics ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Instrument Sans', system-ui, sans-serif; color: var(--text); }

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px 16px;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px;
  width: 100%;
  max-width: 440px;
  border: 1px solid var(--border);
}

.auth-card--success { text-align: center; }

.auth-card__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 32px;
}
.auth-card__brand em { color: var(--accent); font-style: normal; }

.auth-card__title { font-size: 1.5rem; font-weight: 700; margin-bottom: 6px; }
.auth-card__sub { color: var(--muted); font-size: .95rem; margin-bottom: 28px; }
.auth-card__footer { text-align: center; font-size: .875rem; color: var(--muted); margin-top: 20px; }
.auth-card__footer a { color: var(--accent); text-decoration: none; font-weight: 600; }

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: .875rem; font-weight: 600; }

.form-input {
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .95rem;
  font-family: inherit;
  color: var(--text);
  transition: border-color .15s;
}
.form-input:focus { outline: none; border-color: var(--accent); }

.btn--full { width: 100%; justify-content: center; }

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: .875rem;
  margin-bottom: 16px;
}
.alert--error { background: #fef2f2; color: #b91c1c; border: 1px solid #fca5a5; }

.success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-size: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.dash-body { display: flex; min-height: 100vh; background: var(--bg); }

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 20px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1rem;
  border-bottom: 1px solid var(--border);
}
.sidebar__brand em { color: var(--accent); font-style: normal; }

.sidebar__nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.sidebar__link:hover { background: var(--bg); color: var(--text); }
.sidebar__link.active { background: #fdf0f4; color: var(--accent); font-weight: 600; }

.sidebar__footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar__user { font-size: .85rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__logout { font-size: .8rem; color: var(--muted); text-decoration: none; transition: color .15s; }
.sidebar__logout:hover { color: var(--red); }

/* ---- Main ---- */
.dash-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px;
  max-width: 1200px;
}

/* ============================================================
   COMPONENTS
   ============================================================ */

/* Header */
.dash-header { margin-bottom: 28px; }
.dash-title { font-size: 1.6rem; font-weight: 700; }
.dash-subtitle { color: var(--muted); margin-top: 4px; }

/* Partner link */
.partner-link-card__inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.partner-link-card__label { font-size: .8rem; opacity: .7; margin-bottom: 4px; }
.partner-link-card__url { font-weight: 600; font-size: .95rem; word-break: break-all; }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.stats-grid--3 { grid-template-columns: repeat(3, 1fr); }
.stats-grid--6 { grid-template-columns: repeat(3, 1fr); }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
}
.stat-card--highlight { border-color: var(--accent); }

.stat-card__icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-card__icon--blue   { background: #eff6ff; color: var(--blue); }
.stat-card__icon--green  { background: #f0fdf4; color: var(--green); }
.stat-card__icon--yellow { background: #fffbeb; color: var(--yellow); }
.stat-card__icon--purple { background: #f5f3ff; color: var(--purple); }
.stat-card__icon--orange { background: #fff7ed; color: var(--orange); }

.stat-card__label { font-size: .8rem; color: var(--muted); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.stat-card__value { font-size: 1.5rem; font-weight: 700; }
.stat-card__value.accent { color: var(--accent); }
.stat-card__value--green  { color: var(--green); }
.stat-card__value--yellow { color: var(--yellow); }
.stat-card__value--purple { color: var(--purple); }
.stat-card__value--muted  { color: var(--muted); }
.stat-card__value--sm     { font-size: 1.1rem; }
.stat-card__sub { font-size: .75rem; color: var(--muted); margin-top: 2px; }

/* Info trigger button (?) */
.info-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: .65rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
}
.info-trigger:hover { background: var(--accent-dark); }

/* Section */
.dash-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; box-shadow: var(--shadow); }
.dash-section__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.dash-section__title { font-size: 1rem; font-weight: 700; }

/* Table */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th { text-align: left; padding: 10px 12px; border-bottom: 2px solid var(--border); font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.data-table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafafa; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge--green  { background: #dcfce7; color: #166534; }
.badge--yellow { background: #fef9c3; color: #92400e; }
.badge--red    { background: #fee2e2; color: #991b1b; }
.badge--orange { background: #ffedd5; color: #c2410c; }
.badge--blue   { background: #dbeafe; color: #1e40af; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 20px; }
.pagination__btn { text-decoration: none; color: var(--accent); font-weight: 600; font-size: .875rem; }
.pagination__info { font-size: .875rem; color: var(--muted); }

/* Empty state */
.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state__sub { font-size: .875rem; margin-top: 6px; }

/* Text helpers */
.text-muted { color: var(--muted); }
.text-sm { font-size: .8rem; }

/* Profile */
.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.profile-card__avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.profile-card__name { font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; }
.profile-card__email { color: var(--muted); font-size: .9rem; margin-bottom: 8px; }

.info-list { display: flex; flex-direction: column; gap: 0; }
.info-item { display: flex; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.info-item:last-child { border-bottom: none; }
.info-item__label { color: var(--muted); }
.info-item__value { font-weight: 600; }
.info-note { margin-top: 16px; background: var(--bg); border-radius: 8px; padding: 14px; font-size: .875rem; color: var(--muted); }
.info-note a { color: var(--accent); }

/* Flash messages */
.flash {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: .875rem;
  margin-bottom: 16px;
  border-width: 1px;
  border-style: solid;
}
.flash--success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.flash--info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.flash--warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.flash--error   { background: #fef2f2; color: #991b1b; border-color: #fca5a5; }

/* Partnership status banner */
.partnership-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: .875rem;
  margin-bottom: 20px;
  border-width: 1px;
  border-style: solid;
}
.partnership-status--active  { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.partnership-status--paused  { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.partnership-status__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.partnership-status--active  .partnership-status__dot { background: var(--green); }
.partnership-status--paused  .partnership-status__dot { background: var(--yellow); }

/* Active-user info panel */
.active-user-info {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.active-user-info__inner {
  padding: 20px 24px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: .9rem;
  line-height: 1.6;
}
.active-user-info__close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--muted);
}
.active-user-info__close:hover { color: var(--text); }
.active-user-info__title { font-size: 1rem; font-weight: 700; margin: 0; }
.active-user-info__inner p { margin: 0; }
.active-user-info__tip {
  background: #f0fdf4;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .875rem;
  color: #166534;
}

/* Payout section */
.payout-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.payout-section__title { font-size: 1rem; font-weight: 700; margin-bottom: 14px; }
.payout-section__desc { font-size: .9rem; color: var(--muted); margin-bottom: 14px; }

.payout-request {
  background: var(--bg);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.payout-request__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .875rem;
  gap: 12px;
}
.payout-request__row--note { align-items: flex-start; }
.payout-request__label { color: var(--muted); flex-shrink: 0; }
.payout-request__value { font-weight: 600; text-align: right; }

.payout-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.payout-badge--pending    { background: #fef9c3; color: #92400e; }
.payout-badge--processing { background: #dbeafe; color: #1e40af; }
.payout-badge--completed  { background: #dcfce7; color: #166534; }
.payout-badge--rejected   { background: #fee2e2; color: #991b1b; }

.payout-form { margin-top: 6px; }

/* Gains bloqués en attente d'activation des filleuls */
.payout-locked {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 16px;
}
.payout-locked__icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.payout-locked__title { font-weight: 700; font-size: .9rem; color: #92400e; margin-bottom: 3px; }
.payout-locked__sub { font-size: .82rem; color: #92400e; line-height: 1.5; margin: 0; }

/* Active-user callout (always-visible inline note) */
.active-user-callout {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
}
.active-user-callout__icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 1px; }
.active-user-callout__title { font-weight: 700; font-size: .9rem; margin-bottom: 4px; color: #166534; }
.active-user-callout__body  { font-size: .875rem; color: #166534; line-height: 1.55; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid--3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar__brand { padding: 16px; border-bottom: none; }
  .sidebar__nav { flex-direction: row; padding: 8px 12px; flex: 1; overflow-x: auto; }
  .sidebar__footer { display: none; }
  .dash-main { margin-left: 0; padding: 20px 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .dash-body { flex-direction: column; }
  .auth-card { padding: 28px 20px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stats-grid--3 { grid-template-columns: 1fr; }
  .partner-link-card__inner { flex-direction: column; align-items: flex-start; }
  .profile-card { flex-direction: column; text-align: center; }
}

/* ---------- Code card ---------- */
.partner-link-card {
    background: #1a1a2e;
    border-radius: var(--radius);
    padding: 20px 24px;
    color: white;
    margin-bottom: 24px;
}
.partner-link-card__code {
    font-family: 'Courier New', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #ffffff;
}
.partner-link-card__hint {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 4px;
}
.partner-link-card .btn--ghost {
    border-color: rgba(255, 255, 255, 0.35);
    color: rgba(255, 255, 255, 0.85);
    background: transparent;
}
.partner-link-card .btn--ghost:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.6);
    color: #fff;
}
.partner-link-card .share-btn--whatsapp { color: #4ade80; border-color: rgba(74,222,128,0.4); }
.partner-link-card .share-btn--whatsapp:hover { background: rgba(74,222,128,0.15); border-color: #4ade80; color: #4ade80; }
.partner-link-card .share-btn--sms { color: #93c5fd; border-color: rgba(147,197,253,0.4); }
.partner-link-card .share-btn--sms:hover { background: rgba(147,197,253,0.15); border-color: #93c5fd; color: #93c5fd; }
.partner-link-card .share-btn--email { color: rgba(255,255,255,0.7); }
.partner-link-card .share-btn--native { color: #f9a8d4; }

/* ---------- Pause section ---------- */
.pause-section {
    margin-top: 32px;
    border-top: 1px solid var(--border, #e5e7eb);
    padding-top: 20px;
}
.pause-details > summary {
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--muted, #6b7280);
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.pause-details > summary::before { content: '▶'; font-size: 0.65em; }
.pause-details[open] > summary::before { content: '▼'; }
.pause-details__toggle { user-select: none; }
.pause-details__body {
    margin-top: 14px;
    background: #fff8f8;
    border: 1px solid #fecdd3;
    border-radius: 10px;
    padding: 16px 20px;
    font-size: 0.88rem;
    color: var(--muted, #6b7280);
    line-height: 1.6;
}
.pause-details__body p { margin: 0 0 10px; }
.pause-details__body p:last-of-type { margin-bottom: 14px; }
.pause-details__body a { color: var(--rose, #e94e77); }

/* ---------- Danger button ---------- */
.btn--danger {
    background: #dc2626;
    color: #fff;
    border: none;
}
.btn--danger:hover { background: #b91c1c; }

/* ---------- Navigation loader (top progress bar) ---------- */
#nav-loader {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    z-index: 9999;
    pointer-events: none;
    background: linear-gradient(90deg, var(--accent) 0%, #f472b6 100%);
    border-radius: 0 2px 2px 0;
    transition: opacity 0.3s;
    opacity: 0;
}
@keyframes nav-progress {
    0%   { width: 0%;  opacity: 1; }
    20%  { width: 40%; }
    50%  { width: 65%; }
    80%  { width: 82%; }
    100% { width: 92%; } /* stalls just before 100 % — page load finishes it */
}
#nav-loader.nav-loader--running {
    opacity: 1;
    animation: nav-progress 8s cubic-bezier(0.1, 0.05, 0, 1) forwards;
}

/* Lien en cours de chargement : curseur + légère atténuation */
.sidebar__link.nav-loading,
a.nav-loading {
    opacity: 0.55;
    pointer-events: none;
    cursor: wait;
}

/* ---------- Loading spinner ---------- */
@keyframes koople-spin { to { transform: rotate(360deg); } }
.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: koople-spin 0.65s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
    flex-shrink: 0;
}
.btn--ghost .btn-spinner,
.btn--outline .btn-spinner {
    border-color: rgba(0, 0, 0, 0.15);
    border-top-color: currentColor;
}
.btn--danger .btn-spinner {
    border-color: rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
}
