/* ==========================================================================
   AffiliateHub — Affiliate Portal (frontend) Design System
   Same tokens as admin, but standalone (portal runs inside the theme, not
   wp-admin) with a mobile-first nav that collapses to a bottom bar —
   prioritizing balance, referral link, and payout request on small screens.
   ========================================================================== */

:root {
    --ah-primary: #3323CD;
    --ah-primary-dark: #271AA0;
    --ah-primary-light: #EEF0FF;
    --ah-bg: #F8F9FF;
    --ah-surface: #FFFFFF;
    --ah-border: #E7E8F5;
    --ah-text: #1F2333;
    --ah-text-muted: #6B7080;
    --ah-text-faint: #9498A8;
    --ah-success: #17A366;
    --ah-success-bg: #E9FBF3;
    --ah-warning: #C6820B;
    --ah-warning-bg: #FFF6E4;
    --ah-danger: #DC3545;
    --ah-danger-bg: #FDEEEF;
    --ah-info: #2563EB;
    --ah-info-bg: #EAF1FE;
    --ah-radius-sm: 8px;
    --ah-radius: 12px;
    --ah-radius-lg: 16px;
    --ah-shadow: 0 1px 2px rgba(16,24,40,.04), 0 2px 8px rgba(16,24,40,.05);
}

.ah-portal * { box-sizing: border-box; }
.ah-portal {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
    color: var(--ah-text);
    max-width: 1080px;
    margin: 0 auto;
    padding-bottom: 32px;
}

/* ==========================================================================
   Theme reset layer
   WordPress themes routinely set global styles for headings, links, buttons,
   and form fields with high specificity (Elementor Global Fonts/Colors,
   Astra/GeneratePress typography settings, etc). Those rules leak into any
   plugin markup on the page and override ours unless we out-specify them.
   Everything below is scoped to .ah-portal only — it never touches the rest
   of the site — but uses !important because that's what it takes to reliably
   win against theme-level global styles.
   ========================================================================== */
.ah-portal,
.ah-portal h1, .ah-portal h2, .ah-portal h3, .ah-portal h4, .ah-portal h5, .ah-portal h6,
.ah-portal p, .ah-portal span, .ah-portal div, .ah-portal label, .ah-portal input,
.ah-portal select, .ah-portal textarea, .ah-portal button, .ah-portal a {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif !important;
    letter-spacing: normal !important;
    text-transform: none !important;
    line-height: 1.4;
}
.ah-portal h1, .ah-portal h2, .ah-portal h3, .ah-portal h4, .ah-portal h5, .ah-portal h6 {
    font-weight: 700 !important;
    color: var(--ah-text) !important;
    margin: 0 0 4px !important;
}
/* The reset above forces our font-family onto every span, but dashicons
   render their glyph via the "dashicons" icon font on exactly that kind of
   span — restore it here with higher specificity or the icons show as
   blank/wrong characters. */
.ah-portal .dashicons, .ah-portal .dashicons-before:before {
    font-family: dashicons !important;
    letter-spacing: normal !important;
}
.ah-portal a {
    text-decoration: none !important;
    color: inherit;
    box-shadow: none !important;
    border-bottom: none !important;
}
.ah-portal input, .ah-portal select, .ah-portal textarea, .ah-portal button {
    -webkit-appearance: none;
    appearance: none;
    border-radius: var(--ah-radius-sm) !important;
    box-shadow: none !important;
}
.ah-portal button { cursor: pointer; }
.ah-portal table { border-collapse: collapse !important; }
.ah-portal ul, .ah-portal ol { margin: 0; padding: 0; list-style: none; }


/* ---------- Top nav (desktop) ---------- */
.ah-portal-topnav {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--ah-surface); border: 1px solid var(--ah-border); border-radius: var(--ah-radius);
    padding: 10px 18px; margin-bottom: 20px; position: sticky; top: 10px; z-index: 20;
    box-shadow: var(--ah-shadow);
}
.ah-portal-brand { font-weight: 700 !important; font-size: 15px; color: var(--ah-primary) !important; flex-shrink: 0; }
.ah-portal-tabs { display: flex; gap: 4px; }
.ah-portal-tabs a {
    display: flex; align-items: center; gap: 5px; flex-shrink: 0;
    padding: 8px 14px; border-radius: 999px !important; font-size: 13px; font-weight: 600 !important;
    color: var(--ah-text-muted) !important; text-decoration: none !important; background: transparent;
    white-space: nowrap;
}
.ah-portal-tabs a .dashicons {
    font-size: 16px; width: 16px; height: 16px; line-height: 1;
    display: none; align-items: center; justify-content: center; flex-shrink: 0;
}
.ah-portal-tabs a .dashicons:before { font-size: 16px; line-height: 1; width: 16px; height: 16px; }
.ah-portal-tabs a .ah-tab-label { line-height: 1; }
.ah-portal-tabs a.active { background: var(--ah-primary-light) !important; color: var(--ah-primary) !important; }
.ah-portal-tabs a:hover:not(.active) { background: var(--ah-bg) !important; }

/* ---------- Banner ---------- */
.ah-banner {
    background: var(--ah-primary);
    color: var(--ah-on-primary, #fff); border-radius: var(--ah-radius-lg);
    padding: 22px 24px; margin-bottom: 18px;
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px;
}
/* Higher specificity than the .ah-portal h1..h6 reset rule, which would
   otherwise force these back to the dark body-text color. */
.ah-portal .ah-banner h1, .ah-portal .ah-banner h2, .ah-portal .ah-banner h3,
.ah-portal .ah-banner h4, .ah-portal .ah-banner h5, .ah-portal .ah-banner h6 {
    color: var(--ah-on-primary, #fff) !important;
}
.ah-banner h2 { margin: 0 0 4px; font-size: 19px; }
.ah-banner p { margin: 0; opacity: .85; font-size: 13px; color: var(--ah-on-primary, #fff); }
.ah-banner .ah-referral-box {
    background: rgba(255,255,255,.15) !important; border-radius: var(--ah-radius-sm) !important;
    padding: 10px 14px; display: flex; align-items: center; gap: 10px; min-width: 280px;
}
.ah-banner .ah-referral-box input {
    background: transparent !important; border: 0 !important; color: var(--ah-on-primary, #fff) !important; font-size: 13px;
    flex: 1; outline: none !important; padding: 4px 2px !important; box-shadow: none !important;
}
.ah-banner .ah-referral-box input::placeholder { color: rgba(255,255,255,.7) !important; }
.ah-banner .ah-copy-btn {
    background: #fff !important; color: var(--ah-primary) !important; border: 0 !important;
    border-radius: 6px !important; padding: 8px 16px !important; font-weight: 700 !important;
    font-size: 12.5px !important; cursor: pointer; white-space: nowrap; text-transform: none !important;
}
.ah-banner .ah-copy-btn:hover { background: #f0f0ff !important; }

/* ---------- Referral link card ---------- */
.ah-referral-card {
    background: var(--ah-surface); border: 1px solid var(--ah-border); border-radius: var(--ah-radius);
    box-shadow: var(--ah-shadow); padding: 18px 20px; margin-bottom: 18px;
}
.ah-referral-card .ah-label { font-size: 12px; color: var(--ah-text-muted); font-weight: 600; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .03em; }
.ah-referral-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ah-referral-row input {
    flex: 1; min-width: 200px; padding: 10px 14px; border: 1px solid var(--ah-border);
    border-radius: var(--ah-radius-sm); font-size: 13px; background: var(--ah-bg); color: var(--ah-text);
}
.ah-referral-row .ah-btn { flex-shrink: 0; }

/* ---------- Stat cards ---------- */
.ah-cards { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 20px; }
.ah-card {
    background: var(--ah-surface) !important; border: 1px solid var(--ah-border) !important; border-radius: var(--ah-radius) !important;
    box-shadow: var(--ah-shadow) !important; padding: 16px 18px;
}
.ah-stat-card { flex: 1 1 160px; min-width: 150px; }
.ah-stat-card.highlight { background: var(--ah-primary) !important; border-color: transparent !important; color: var(--ah-on-primary, #fff) !important; }
.ah-stat-card.highlight .ah-stat-label { color: var(--ah-on-primary, #fff) !important; opacity: .75; }
.ah-stat-card.highlight .ah-stat-value { color: var(--ah-on-primary, #fff) !important; }
.ah-stat-label { font-size: 11.5px !important; color: var(--ah-text-muted) !important; font-weight: 600 !important; text-transform: uppercase !important; letter-spacing: .02em; margin-bottom: 6px; }
.ah-stat-value { font-size: 22px !important; font-weight: 700 !important; color: var(--ah-text); }
.ah-stat-sub { font-size: 11.5px; color: var(--ah-text-faint); margin-top: 4px; }

/* ---------- Panels / tables ---------- */
.ah-panel { background: var(--ah-surface) !important; border: 1px solid var(--ah-border) !important; border-radius: var(--ah-radius) !important; box-shadow: var(--ah-shadow) !important; padding: 20px; margin-bottom: 20px; }
.ah-panel h3 { margin: 0 0 14px !important; font-size: 15px !important; font-weight: 700 !important; }
table.ah-table { width: 100%; border-collapse: collapse !important; font-size: 13px; }
table.ah-table th { text-align: left !important; font-size: 11px !important; text-transform: uppercase !important; letter-spacing: .03em; color: var(--ah-text-faint) !important; font-weight: 600 !important; padding: 9px 12px; border-bottom: 1px solid var(--ah-border) !important; white-space: nowrap; background: transparent !important; }
table.ah-table td { padding: 12px; border-bottom: 1px solid var(--ah-border) !important; background: transparent !important; }
table.ah-table tr:last-child td { border-bottom: none !important; }

.ah-badge {
    display: inline-flex; align-items: center; gap: 4px; font-size: 11px !important; font-weight: 600 !important;
    padding: 3px 9px !important; border-radius: 999px !important; white-space: nowrap;
}
.ah-badge.success, .ah-badge.active, .ah-badge.paid, .ah-badge.approved, .ah-badge.converted { color: var(--ah-success) !important; background: var(--ah-success-bg) !important; }
.ah-badge.pending, .ah-badge.clicked { color: var(--ah-warning) !important; background: var(--ah-warning-bg) !important; }
.ah-badge.rejected, .ah-badge.failed, .ah-badge.cancelled, .ah-badge.reversed { color: var(--ah-danger) !important; background: var(--ah-danger-bg) !important; }
.ah-badge.processing, .ah-badge.registered { color: var(--ah-info) !important; background: var(--ah-info-bg) !important; }

.ah-btn {
    display: inline-flex; align-items: center; gap: 6px; justify-content: center;
    font-size: 13px !important; font-weight: 600 !important; padding: 10px 16px !important; border-radius: var(--ah-radius-sm) !important;
    border: 1px solid var(--ah-border) !important; background: var(--ah-surface) !important; color: var(--ah-text) !important;
    cursor: pointer; text-decoration: none !important; line-height: 1.2;
}
.ah-btn.primary { background: var(--ah-primary) !important; border-color: var(--ah-primary) !important; color: var(--ah-on-primary, #fff) !important; }
.ah-btn.primary:hover { background: var(--ah-primary-dark) !important; }
.ah-btn:hover { color: var(--ah-text); }
.ah-btn.block { width: 100%; }
.ah-btn.sm { padding: 6px 12px !important; font-size: 12px !important; }
.ah-btn:disabled { opacity: .5; cursor: not-allowed; }

.ah-form-row { margin-bottom: 16px; }
.ah-form-row label { display: block !important; font-size: 12.5px !important; font-weight: 600 !important; color: var(--ah-text-muted) !important; margin-bottom: 6px !important; }
.ah-form-row input, .ah-form-row select, .ah-form-row textarea {
    width: 100%; padding: 10px 12px !important; border: 1px solid var(--ah-border) !important; border-radius: var(--ah-radius-sm) !important;
    font-size: 13.5px !important; background: var(--ah-surface) !important; color: var(--ah-text) !important;
}
.ah-form-row input:focus, .ah-form-row select:focus, .ah-form-row textarea:focus { outline: none !important; border-color: var(--ah-primary) !important; }
.ah-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

.ah-notice { background: var(--ah-primary-light) !important; border: 1px solid #D9DCFA !important; color: var(--ah-primary-dark) !important; padding: 10px 14px; border-radius: var(--ah-radius-sm) !important; margin-bottom: 16px; font-size: 13px; }
.ah-notice.warn { background: var(--ah-warning-bg) !important; border-color: #F0DCA8 !important; color: var(--ah-warning) !important; }

.ah-empty { text-align: center; padding: 40px 16px; color: var(--ah-text-muted); font-size: 13.5px; }

.ah-payout-balance { font-size: 30px; font-weight: 700; margin: 6px 0 14px; }

.ah-masked { letter-spacing: 2px; }

/* ==========================================================================
   Mobile — cards instead of tables, scrollable top nav, balance-first layout
   ========================================================================== */
@media (max-width: 720px) {
    .ah-portal { padding: 0 12px 24px; }

    /* Keep the same nav bar at all sizes (no position:fixed swap — fixed
       elements can get trapped by a parent with transform/overflow set,
       which is extremely common in Elementor sections, and silently
       disappear). Instead, let the tab row scroll horizontally. */
    .ah-portal-topnav { position: relative; padding: 10px 12px; flex-wrap: nowrap; overflow: hidden; }
    .ah-portal-brand { display: none; } /* saves space; tabs are the priority on small screens */
    .ah-portal-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; width: 100%; }
    .ah-portal-tabs::-webkit-scrollbar { display: none; }

    /* Visual cue that the tab row scrolls: a fade-out edge with a chevron,
       since a plain scrollable row with no visible cut-off tab isn't an
       obvious "swipe me" signal on its own. */
    .ah-portal-topnav::after {
        content: '\203A'; /* › */
        position: absolute; top: 0; right: 0; bottom: 0; width: 34px;
        display: flex; align-items: center; justify-content: flex-end;
        padding-right: 6px; font-size: 18px; font-weight: 700; color: var(--ah-primary);
        background: linear-gradient(to right, transparent, var(--ah-surface) 55%);
        pointer-events: none; transition: opacity .2s ease;
    }
    .ah-portal-topnav.ah-scrolled-end::after { opacity: 0; }
    .ah-portal-tabs a { padding: 8px 12px; font-size: 12.5px; }
    .ah-portal-tabs a .dashicons { display: inline-flex; }

    .ah-banner { padding: 18px; flex-direction: column; align-items: flex-start; }
    .ah-banner .ah-referral-box { width: 100%; }

    .ah-cards { gap: 10px; }
    .ah-stat-card { flex: 1 1 calc(50% - 5px); min-width: 0; padding: 12px 14px; }
    .ah-stat-value { font-size: 18px; }

    /* Tables become stacked cards */
    table.ah-table, table.ah-table thead, table.ah-table tbody, table.ah-table th, table.ah-table td, table.ah-table tr { display: block; width: 100%; }
    table.ah-table thead { display: none; }
    table.ah-table tr {
        border: 1px solid var(--ah-border); border-radius: var(--ah-radius); margin-bottom: 10px;
        padding: 10px 4px; background: var(--ah-surface);
    }
    table.ah-table td {
        border: none; display: flex; justify-content: space-between; align-items: center; gap: 10px;
        padding: 6px 12px;
    }
    table.ah-table td::before {
        content: attr(data-label); font-weight: 600; color: var(--ah-text-faint); font-size: 11px;
        text-transform: uppercase; letter-spacing: .02em;
    }

    .ah-form-grid { grid-template-columns: 1fr; }
}

/* ---- v1.0: promoter / club mode ---- */
.ah-badge.upcoming, .ah-badge.settled { color: var(--ah-success); background: var(--ah-success-bg, #E7F6EC); }
.ah-badge.awaiting { color: var(--ah-warning); background: var(--ah-warning-bg, #FFF4E0); }
.ah-event-card { background: var(--ah-surface); border: 1px solid var(--ah-border); border-radius: var(--ah-radius); padding: 16px 18px; margin-bottom: 12px; }
.ah-event-card h3 { margin: 0 0 4px; font-size: 15px; }
.ah-event-meta { font-size: 12.5px; color: var(--ah-text-muted); margin-bottom: 10px; }
.ah-event-stats { display: flex; flex-wrap: wrap; gap: 18px; }
.ah-event-stats div { min-width: 90px; }
.ah-event-stats b { display: block; font-size: 16px; }
.ah-event-stats span { font-size: 11px; text-transform: uppercase; letter-spacing: .02em; color: var(--ah-text-muted); }
