/* ==========================================================================
   Afflyin Affiliate Dashboard v2.5.0 — Top-nav layout
   ========================================================================== */

/* Reset / scope */
.aff-wrap *, .aff-wrap *::before, .aff-wrap *::after { box-sizing: border-box; margin: 0; padding: 0; }
.aff-wrap {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  font-size: 14px; color: #0f172a; background: #f8fafc; min-height: 600px;
}
.aff-wrap a { text-decoration: none; }
.aff-wrap button { cursor: pointer; font-family: inherit; }

/* ── Top nav ────────────────────────────────────────────────────────────── */
.aff-topnav {
  display: flex; align-items: center; gap: 0;
  background: #fff; border-bottom: 1px solid #e2e8f0;
  padding: 0 24px; height: 58px; position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.aff-topnav-brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 16px; color: #0f172a;
  margin-right: 28px; flex-shrink: 0;
}
.aff-topnav-brand svg { color: #6366f1; }
.aff-topnav-nav { display: flex; align-items: center; gap: 2px; flex: 1; }
.aff-nav-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px;
  color: #64748b; font-weight: 500; font-size: 13.5px;
  transition: background .15s, color .15s; white-space: nowrap;
}
.aff-nav-link:hover { background: #f1f5f9; color: #0f172a; }
.aff-nav-link.aff-nav-active { background: #ede9fe; color: #6366f1; }
.aff-topnav-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }

/* Quick copy in topnav */
.aff-quick-link-wrap {
  display: flex; align-items: center; background: #f8fafc;
  border-radius: 8px; overflow: hidden; border: 1px solid #e2e8f0;
}
.aff-quick-link-input {
  border: none; background: transparent; padding: 6px 10px;
  font-size: 12px; color: #475569; width: 190px; outline: none;
}
.aff-quick-copy-btn {
  background: transparent; border: none; padding: 6px 10px;
  color: #64748b; display: flex; align-items: center; transition: color .15s;
}
.aff-quick-copy-btn:hover { color: #6366f1; }

/* User avatar */
.aff-user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; user-select: none;
}

/* Mobile menu button */
.aff-mobile-menu-btn {
  display: none; background: none; border: none;
  color: #64748b; padding: 4px; align-items: center;
}

/* Mobile drawer */
.aff-mobile-drawer {
  display: none; flex-direction: column; gap: 2px;
  background: #fff; border-bottom: 1px solid #e2e8f0;
  padding: 8px 16px 12px;
}
.aff-mobile-drawer.aff-drawer-open { display: flex; }
.aff-mobile-drawer .aff-nav-link { padding: 10px 12px; }

/* ── Main content ───────────────────────────────────────────────────────── */
.aff-main { padding: 28px 28px 60px; max-width: 1100px; margin: 0 auto; }

/* ── Sections ───────────────────────────────────────────────────────────── */
.aff-section { display: none; }
.aff-section.aff-section-active { display: block; }

/* ── Page header ────────────────────────────────────────────────────────── */
.aff-page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.aff-page-header h1 { font-size: 22px; font-weight: 700; color: #0f172a; line-height: 1.2; }
.aff-page-header p { font-size: 13.5px; color: #64748b; margin-top: 3px; }

/* ── Stats grid ─────────────────────────────────────────────────────────── */
.aff-stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.aff-stat-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 20px; transition: box-shadow .2s;
}
.aff-stat-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.aff-stat-label { font-size: 11.5px; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: .05em; }
.aff-stat-value { font-size: 28px; font-weight: 800; color: #0f172a; margin: 8px 0 4px; line-height: 1; }
.aff-stat-sub { font-size: 12px; color: #94a3b8; }
.aff-stat-icon {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 12px;
}
.aff-stat-icon-blue   { background: #eff6ff; color: #3b82f6; }
.aff-stat-icon-green  { background: #f0fdf4; color: #22c55e; }
.aff-stat-icon-purple { background: #faf5ff; color: #a855f7; }
.aff-stat-icon-amber  { background: #fffbeb; color: #f59e0b; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.aff-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 20px; margin-bottom: 20px;
}
.aff-card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.aff-card-title { font-size: 15px; font-weight: 700; color: #0f172a; }
.aff-card-sub { font-size: 12.5px; color: #64748b; margin-top: 2px; }

/* ── Referral link card ─────────────────────────────────────────────────── */
.aff-link-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.aff-link-input {
  flex: 1; min-width: 200px; padding: 9px 12px;
  border: 1px solid #e2e8f0; border-radius: 8px;
  font-size: 13px; color: #475569; background: #f8fafc; outline: none;
}
.aff-link-code-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.aff-label { font-size: 12px; color: #94a3b8; font-weight: 500; }
.aff-code {
  background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 6px;
  padding: 3px 10px; font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px; color: #6366f1; letter-spacing: .04em;
}
.aff-tip {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: #94a3b8; margin-top: 14px;
  padding-top: 14px; border-top: 1px solid #f1f5f9;
}

/* ── Chart ──────────────────────────────────────────────────────────────── */
.aff-chart-wrap { height: 220px; position: relative; }
.aff-chart-wrap canvas { width: 100% !important; height: 100% !important; }

/* ── Tabs ───────────────────────────────────────────────────────────────── */
.aff-tabs { display: flex; background: #f1f5f9; border-radius: 8px; padding: 3px; gap: 2px; }
.aff-tab {
  padding: 5px 14px; border: none; background: transparent;
  border-radius: 6px; font-size: 12.5px; font-weight: 600;
  color: #64748b; transition: background .15s, color .15s;
}
.aff-tab.aff-tab-active { background: #fff; color: #6366f1; box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.aff-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600;
}
.aff-badge-green  { background: #f0fdf4; color: #16a34a; }
.aff-badge-blue   { background: #eff6ff; color: #2563eb; }
.aff-badge-amber  { background: #fffbeb; color: #d97706; }
.aff-badge-red    { background: #fef2f2; color: #dc2626; }
.aff-badge-gray   { background: #f1f5f9; color: #64748b; }
.aff-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── Summary chips ──────────────────────────────────────────────────────── */
.aff-summary-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.aff-summary-chip {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px 18px;
}
.aff-summary-chip-label { font-size: 11px; color: #94a3b8; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.aff-summary-chip-value { font-size: 20px; font-weight: 800; color: #0f172a; margin-top: 2px; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.aff-table-wrap { overflow-x: auto; }
.aff-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.aff-table thead th {
  padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 700;
  color: #94a3b8; text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid #f1f5f9; white-space: nowrap;
}
.aff-table tbody td { padding: 12px 14px; border-bottom: 1px solid #f8fafc; color: #334155; vertical-align: middle; }
.aff-table tbody tr:last-child td { border-bottom: none; }
.aff-table tbody tr:hover td { background: #fafbff; }
.aff-table-loading { text-align: center; color: #94a3b8; padding: 40px 0 !important; font-size: 13px; }
.aff-table-empty  { text-align: center; color: #94a3b8; padding: 48px 0 !important; }

/* ── Pagination ─────────────────────────────────────────────────────────── */
.aff-pagination {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 6px; padding-top: 16px; flex-wrap: wrap;
}
.aff-page-btn {
  padding: 6px 12px; border: 1px solid #e2e8f0; border-radius: 7px;
  background: #fff; color: #475569; font-size: 12.5px; font-weight: 500; transition: all .15s;
}
.aff-page-btn:hover:not(:disabled) { border-color: #6366f1; color: #6366f1; }
.aff-page-btn.aff-page-active { background: #6366f1; border-color: #6366f1; color: #fff; }
.aff-page-btn:disabled { opacity: .4; cursor: not-allowed; }
.aff-page-info { font-size: 12px; color: #94a3b8; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.aff-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
  border: none; transition: all .15s; line-height: 1.4;
}
.aff-btn-primary { background: #6366f1; color: #fff; }
.aff-btn-primary:hover { background: #4f46e5; }
.aff-btn-outline { background: #fff; color: #475569; border: 1px solid #e2e8f0; }
.aff-btn-outline:hover { border-color: #6366f1; color: #6366f1; }
.aff-btn-ghost { background: none; border: none; color: #6366f1; font-size: 13px; font-weight: 600; padding: 4px 0; }
.aff-btn-ghost:hover { text-decoration: underline; }

/* ── Skeleton loaders ───────────────────────────────────────────────────── */
.aff-skeleton-card { pointer-events: none; }
.aff-skel {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: aff-shimmer 1.4s infinite; border-radius: 6px;
}
.aff-skel-sm { height: 12px; width: 80%; margin-bottom: 6px; }
.aff-skel-xl { height: 32px; width: 60%; margin-bottom: 6px; }
@keyframes aff-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Modal ──────────────────────────────────────────────────────────────── */
.aff-modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 9999;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.aff-modal-overlay.aff-modal-open { opacity: 1; pointer-events: all; }
.aff-modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  transform: translateY(12px); transition: transform .2s;
}
.aff-modal-overlay.aff-modal-open .aff-modal { transform: translateY(0); }
.aff-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0;
}
.aff-modal-head h3 { font-size: 16px; font-weight: 700; color: #0f172a; }
.aff-modal-close {
  background: none; border: none; color: #94a3b8;
  padding: 4px; border-radius: 6px; transition: color .15s;
}
.aff-modal-close:hover { color: #0f172a; }
.aff-modal form { padding: 20px 24px 24px; }
.aff-form-group { margin-bottom: 18px; }
.aff-form-label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.aff-required { color: #ef4444; }
.aff-form-input {
  width: 100%; padding: 9px 12px; border: 1px solid #e2e8f0;
  border-radius: 8px; font-size: 13.5px; color: #0f172a; outline: none; transition: border-color .15s;
}
.aff-form-input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.aff-form-hint { font-size: 12px; color: #94a3b8; margin-top: 5px; }
.aff-modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }
.aff-modal-error { color: #dc2626; font-size: 12.5px; margin-top: 10px; }

/* ── Toast ──────────────────────────────────────────────────────────────── */
.aff-toast {
  position: fixed; bottom: 24px; right: 24px; background: #0f172a; color: #fff;
  padding: 10px 18px; border-radius: 10px; font-size: 13px; font-weight: 500;
  z-index: 99999; opacity: 0; transform: translateY(8px);
  transition: opacity .25s, transform .25s; pointer-events: none; max-width: 320px;
}
.aff-toast.aff-toast-show { opacity: 1; transform: translateY(0); }
.aff-toast.aff-toast-success { background: #16a34a; }
.aff-toast.aff-toast-error   { background: #dc2626; }

/* ── Become affiliate / join form ───────────────────────────────────────── */
.aff-join-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 14px;
  padding: 32px; max-width: 520px;
}
.aff-join-card h2 { font-size: 18px; font-weight: 700; color: #0f172a; margin-bottom: 6px; }
.aff-join-card > p { font-size: 13.5px; color: #64748b; margin-bottom: 24px; }
.aff-join-form .aff-form-group { margin-bottom: 16px; }
.aff-join-form select.aff-form-input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.aff-form-error { color: #dc2626; font-size: 12.5px; margin-top: 8px; }
.aff-join-form .aff-btn-primary { width: 100%; justify-content: center; padding: 11px; font-size: 14px; margin-top: 8px; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .aff-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .aff-quick-link-wrap { display: none; }
}
@media (max-width: 680px) {
  .aff-topnav-nav { display: none; }
  .aff-mobile-menu-btn { display: flex; }
  .aff-main { padding: 20px 16px 48px; }
  .aff-topnav { padding: 0 16px; }
  .aff-topnav-brand span { display: none; }
}
@media (max-width: 420px) {
  .aff-stats-grid { grid-template-columns: 1fr; }
  .aff-stat-value { font-size: 22px; }
}
