/* ============================================================
   AFFILIATE — pages/affiliate.php
   ============================================================ */
.aff-page .alert { margin-bottom: 16px; }

/* ── Intro (ยังไม่ได้เป็นผู้แนะนำ) ── */
.aff-intro { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.aff-perk {
    display: flex; flex-direction: column; gap: 4px; padding: 22px; border-radius: 22px;
    background: var(--white); border: 1px solid var(--border); box-shadow: var(--shadow-xs);
}
.aff-perk-ic {
    width: 42px; height: 42px; border-radius: 13px; margin-bottom: 8px;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary-light); color: var(--primary); font-size: 1.1rem;
}
.aff-perk-ic i { display: flex; }
.aff-perk b { font-size: 1.05rem; color: var(--dark); line-height: 1.35; }
.aff-perk small { font-size: 0.82rem; color: var(--text-muted); }

.aff-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.aff-steps > div {
    display: grid; grid-template-columns: 32px 1fr; column-gap: 12px; align-items: center;
    padding: 14px 18px; border-radius: 16px; background: var(--white); border: 1px dashed var(--border);
}
.aff-steps span {
    grid-row: span 2; width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--dark); color: #fff; font-weight: 800; font-size: 0.9rem;
}
.aff-steps b { font-size: 0.92rem; color: var(--dark); }
.aff-steps small { font-size: 0.78rem; color: var(--text-muted); }

.aff-cta, .aff-status { display: flex; align-items: center; gap: 18px; }
.aff-cta { justify-content: space-between; flex-wrap: wrap; }
.aff-cta h2, .aff-status h2 { font-size: 1.15rem; color: var(--dark); margin-bottom: 4px; }
.aff-cta p, .aff-status p { color: var(--text-muted); font-size: 0.9rem; }
.aff-cta-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.aff-status-ic {
    width: 52px; height: 52px; flex-shrink: 0; border-radius: 16px;
    display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
}
.aff-status-ic i { display: flex; }
.aff-status-ic.is-warn { background: #fffbeb; color: #d97706; }
.aff-status-ic.is-bad  { background: #fef2f2; color: var(--danger); }

.aff-apply { max-width: 760px; }
.aff-terms {
    max-height: 220px; overflow: auto; padding: 14px 18px; margin-bottom: 14px; border-radius: 14px;
    background: var(--bg); font-size: 0.86rem; color: var(--text); line-height: 1.7;
}
.aff-terms ul { padding-left: 18px; margin: 0; }
.aff-check { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; font-weight: 600; cursor: pointer; }
.aff-check input { width: 18px; height: 18px; accent-color: var(--primary); }

/* ── Payout method radio ── */
.aff-pm { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.aff-pm-opt {
    display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 12px; cursor: pointer;
    border: 1.5px solid var(--border); font-size: 0.88rem; font-weight: 600; color: var(--text);
    transition: all var(--transition);
}
.aff-pm-opt i { display: flex; color: var(--text-muted); }
.aff-pm-opt { position: relative; }
.aff-pm-opt input { position: absolute; opacity: 0; pointer-events: none; }
.aff-pm-opt:has(input:focus-visible) { box-shadow: var(--glow); }
.aff-pm-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.aff-pm-opt:has(input:checked) i { color: var(--primary); }

/* ── Dashboard ── */
.aff-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.aff-stat {
    display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; border-radius: 18px; min-width: 0;
    background: var(--white); border: 1px solid var(--border); box-shadow: var(--shadow-xs);
}
.aff-stat small { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; }
.aff-stat b { font-size: 1.35rem; color: var(--dark); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aff-stat span { font-size: 0.75rem; color: var(--text-muted); }
.aff-stat.is-main { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); border-color: transparent; }
.aff-stat.is-main small, .aff-stat.is-main span { color: rgba(255,255,255,.75); }
.aff-stat.is-main b { color: #fff; }

.aff-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.aff-main, .aff-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.aff-side { scroll-margin-top: 90px; }
#commissions { scroll-margin-top: 90px; }

.aff-link-box { display: flex; gap: 8px; }
.aff-link-box .form-control { flex: 1; min-width: 0; font-size: 0.86rem; background: var(--bg); }
.aff-link-box .btn-primary, .aff-link-box .btn-outline { flex-shrink: 0; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; }
.aff-link-box i { display: flex; }
.aff-page code { font-size: 0.82em; padding: 1px 6px; border-radius: 6px; background: var(--primary-light); color: var(--primary); }
.aff-gen { margin-top: 18px; padding-top: 18px; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 8px; }
.aff-gen .form-label { margin-bottom: 0; }

.aff-table-wrap { overflow-x: auto; margin: 0 -6px; }
.aff-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.aff-table th { text-align: left; font-size: 0.75rem; font-weight: 700; color: var(--text-muted); padding: 8px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.aff-table td { padding: 11px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.aff-table tr:last-child td { border-bottom: 0; }
.aff-table td b { color: var(--dark); display: block; }
.aff-table td small { display: block; font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.aff-table .num { text-align: right; white-space: nowrap; }
.aff-table .badge { white-space: nowrap; }
.aff-table .nowrap { white-space: nowrap; color: var(--text-muted); }

.aff-wallet-bal { display: flex; flex-direction: column; padding: 16px; border-radius: 16px; background: var(--bg); margin-bottom: 14px; }
.aff-wallet-bal small { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; }
.aff-wallet-bal b { font-size: 1.7rem; color: var(--primary); line-height: 1.3; }
.aff-rules { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 6px; font-size: 0.84rem; color: var(--text); }
.aff-rules li { display: flex; align-items: center; gap: 8px; }
.aff-rules i { display: flex; color: var(--text-muted); }
.aff-btn-full { width: 100%; justify-content: center; display: inline-flex; align-items: center; gap: 6px; }
.aff-btn-full i { display: flex; }
.aff-btn-full:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }

.aff-payouts { display: flex; flex-direction: column; gap: 8px; }
.aff-payout { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--bg); }
.aff-payout b { color: var(--dark); }
.aff-payout small { display: block; font-size: 0.74rem; color: var(--text-muted); }
.aff-payout small.is-bad { color: var(--danger); }

@media (max-width: 1100px) {
    .aff-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
    .aff-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
    .aff-intro, .aff-steps { grid-template-columns: minmax(0, 1fr); }
    .aff-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .aff-stat.is-main { grid-column: span 2; order: -1; }
    .aff-link-box { flex-direction: column; }
    .aff-table th:nth-child(1), .aff-table td:nth-child(1),
    .aff-table th:nth-child(3), .aff-table td:nth-child(3) { display: none; }
    .aff-table td:nth-child(2) { word-break: break-word; }
}
.aff-m-only { display: none; }
@media (max-width: 720px) { .aff-m-only { display: inline; } }
