/* ==========================================================================
   AFFILIATE PORTAL — Base Styles
   Loaded on every affiliate page via base_affiliate.html
   ========================================================================== */

/* ── Reset / Global ─────────────────────────────────────────────────────── */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* ── Navigation ─────────────────────────────────────────────────────────── */
.affiliate-nav {
    background: #2c3e50;
    padding: 0 20px;
    display: flex;
    align-items: stretch;
}
.affiliate-nav ul {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex;
    gap: 0;
    align-items: stretch;
    width: 100%;
}
.affiliate-nav ul li {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    display: flex;
    align-items: stretch;
}
.affiliate-nav ul li a {
    color: #fff !important;
    text-decoration: none;
    padding: 16px 20px;
    border-radius: 0;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    background: transparent;
}
.affiliate-nav ul li a:hover,
.affiliate-nav ul li a.active {
    background: #2a7c6c !important;
}
.affiliate-nav .nav-right {
    margin-left: auto;
}

/* ── Stat Cards ─────────────────────────────────────────────────────────── */
.stat-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    text-align: center;
}
.stat-card.purple { background: linear-gradient(135deg, #f3e5f5, #e1bee7); }
.stat-card.purple .value { color: #7b1fa2; }
.stat-card.blue { background: linear-gradient(135deg, #e3f2fd, #bbdefb); }
.stat-card.blue .value { color: #1565c0; }
.stat-card.green { background: linear-gradient(135deg, #e8f5e9, #c8e6c9); }
.stat-card.green .value { color: #2e7d32; }
.stat-card.gold { background: linear-gradient(135deg, #fff3e0, #ffe0b2); }
.stat-card.gold .value { color: #e65100; }
.stat-card.red { background: linear-gradient(135deg, #fce4ec, #f8bbd9); }
.stat-card.red .value { color: #c2185b; }
.stat-card h3 {
    margin: 0 0 12px;
    color: #555;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}
.stat-card .value {
    font-size: 42px;
    font-weight: bold;
}
.stat-card .sub {
    font-size: 16px;
    color: #666;
    margin-top: 8px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* ── Affiliate Link Box ─────────────────────────────────────────────────── */
.affiliate-link-box {
    background: #e8f4f8;
    border: 1px solid #b8daed;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
    overflow: hidden;
    max-width: 100%;
}
.affiliate-link-box .input-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    max-width: 100%;
}
.affiliate-link-box input {
    flex: 1;
    min-width: 0;
    padding: 12px 15px;
    font-size: 18px;
    border: 1px solid #ccc;
    border-radius: 4px;
    margin-bottom: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.affiliate-link-box .main-button {
    display: inline-block;
    white-space: nowrap;
}

/* ── Info Grid ──────────────────────────────────────────────────────────── */
.affiliate-info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

/* ── Copy Button ────────────────────────────────────────────────────────── */
.copy-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
}
.copy-btn:hover {
    background: #2980b9;
}

/* ── Data Tables ────────────────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.data-table th,
.data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}
.data-table th {
    background: #f8f9fa;
    font-weight: 500;
    color: #333;
}
.data-table tr:hover {
    background: #f5f5f5;
}

/* ── Status Badges ──────────────────────────────────────────────────────── */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}
.status-pending   { background: #fff3cd; color: #856404; }
.status-approved  { background: #d4edda; color: #155724; }
.status-paid      { background: #cce5ff; color: #004085; }
.status-rejected  { background: #f8d7da; color: #721c24; }
.status-new       { background: #e2e3e5; color: #383d41; }
.status-active    { background: #d4edda; color: #155724; }
.status-suspended { background: #f8d7da; color: #721c24; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.content-section {
    padding: 30px;
    max-width: 1200px;
    margin: 0 auto;
}
.section-title {
    margin-bottom: 20px;
    color: #2c3e50;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;
    border: none;
    font-size: 14px;
}
.btn-primary {
    background: #3498db;
    color: white;
}
.btn-primary:hover {
    background: #2980b9;
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.form-group label {
    display: block !important;
    margin-bottom: 8px;
    font-weight: 500;
}
.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    display: block;
}

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
}
.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}
.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

/* ── Top Menu ────────────────────────────────────────────────────────────── */
.top-menu {
    margin-left: auto;
    position: relative;
}
.top-menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 20px;
    align-items: center;
}
.top-menu-list li a {
    color: #333;
    text-decoration: none;
    font-size: 14px;
}
.top-menu-list li a:hover {
    color: #3498db;
}
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: #333;
    cursor: pointer;
    padding: 5px 10px;
}
.mobile-menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 180px;
    z-index: 1000;
    padding: 10px 0;
}
.mobile-menu-dropdown.show {
    display: block;
}
.mobile-menu-dropdown a {
    display: block;
    padding: 12px 20px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
}
.mobile-menu-dropdown a:hover {
    background: #f5f5f5;
}
.mobile-menu-dropdown a i {
    width: 20px;
    margin-right: 10px;
}

/* ── Shared helpers ──────────────────────────────────────────────────────── */
.nowrap          { white-space: nowrap; }
.text-right      { text-align: right; }
.text-center     { text-align: center; }
.text-muted      { color: #666; }
.text-small      { font-size: 13px; }
.text-xs         { font-size: 12px; }
.font-mono       { font-family: monospace; }
.font-bold       { font-weight: 600; }
.mt-0            { margin-top: 0; }
.mt-1            { margin-top: 10px; }
.mt-2            { margin-top: 20px; }
.mt-3            { margin-top: 30px; }
.mb-0            { margin-bottom: 0; }
.mb-1            { margin-bottom: 10px; }
.mb-2            { margin-bottom: 20px; }
.mb-3            { margin-bottom: 30px; }
.gap-row         { display: flex; gap: 15px; }
.spacer          { height: 20px; }
.required-star   { color: red; }

/* ── White Card ──────────────────────────────────────────────────────────── */
.card {
    background: #fff;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.card.narrow {
    max-width: 500px;
}
.card-divider {
    border: none;
    border-top: 1px solid #eee;
    margin: 20px 0;
}

/* ── Email validation badge ──────────────────────────────────────────────── */
.email-status-validated {
    color: #28a745;
    font-size: 14px;
    margin-left: 20px;
}
.email-status-not-validated {
    color: #dc3545;
    font-size: 14px;
    margin-left: 20px;
}

/* ── Inline status labels (clicks, referrals, payouts) ───────────────── */
.status-text-unique    { color: #28a745; font-weight: 500; }
.status-text-repeat    { color: #888; }
.status-text-conflict  { color: #fd7e14; }
.status-text-pending   { color: #fd7e14; font-weight: 500; }
.status-text-approved  { color: #28a745; font-weight: 500; }
.status-text-payout-requested { color: #6f42c1; font-weight: 500; }
.status-text-paid      { color: #17a2b8; font-weight: 600; }
.status-text-cancelled { color: #dc3545; font-weight: 600; }
.status-text-rejected  { color: #dc3545; font-weight: 500; }
.total-green           { color: #28a745; }

/* ── Mono code box (affiliate info) ──────────────────────────────────── */
.mono-box {
    font-family: monospace;
    background: #f5f5f5;
    padding: 8px;
    border-radius: 4px;
}

/* ── Commission grid ─────────────────────────────────────────────────── */
.commission-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ── Account header ──────────────────────────────────────────────────── */
.account-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 30px;
}
.account-header h4 {
    margin: 0;
}
.account-header .email-line {
    color: #666;
    margin: 5px 0;
}

/* ── Filter row (shared by clicks + referrals) ───────────────────────── */
.filter-row {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.filter-row select {
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 14px;
}
.filter-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.filter-group label {
    font-size: 12px;
    color: #666;
}
.filter-group input[type="date"] {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}
.filter-buttons {
    flex-direction: row !important;
    gap: 10px;
}
.filter-buttons button {
    margin-bottom: 0;
}
.filter-flex {
    display: flex;
    gap: 10px;
}
.filter-flex-wrap {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.filter-btn-apply {
    margin-bottom: 14px !important;
}

/* ── Table helpers ───────────────────────────────────────────────────── */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -15px;
    padding: 0 15px;
}
.truncate-cell {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.info-text {
    margin-top: 15px;
    font-size: 13px;
    color: #666;
}
.totals-row {
    background: #f8f9fa;
    border-top: 2px solid #dee2e6;
}
.totals-row td {
    font-weight: 500;
}

/* ── Empty state ─────────────────────────────────────────────────────── */
.empty-state {
    background: #fff;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.empty-state i {
    font-size: 48px;
    color: #ccc;
    margin-bottom: 20px;
    display: block;
}
.empty-state .btn {
    margin-top: 15px;
}

/* ── Payout page ─────────────────────────────────────────────────────── */
.payout-summary-box {
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 25px;
    text-align: center;
}
.payout-summary-box .label {
    font-size: 14px;
    color: #2e7d32;
    margin-bottom: 5px;
}
.payout-summary-box .amount {
    font-size: 42px;
    font-weight: bold;
    color: #1b5e20;
}
.payout-summary-box .count {
    font-size: 13px;
    color: #666;
    margin-top: 5px;
}
.payout-table {
    font-size: 13px;
}
.payout-confirm-box {
    margin-top: 25px;
    padding: 20px;
    background: #fff8e1;
    border-radius: 8px;
    border: 1px solid #ffe082;
}
.payout-confirm-box p {
    margin: 0 0 15px 0;
    font-size: 14px;
}
.payout-tfoot {
    background: #f5f5f5;
    border-top: 2px solid #ddd;
}
.payout-tfoot td.total-label {
    text-align: right;
    font-weight: 600;
}
.payout-tfoot td.total-amount {
    text-align: right;
    font-weight: 700;
    font-size: 15px;
    color: #1b5e20;
}

/* ── Index / Landing page ────────────────────────────────────────────── */
.landing-hero {
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
    padding: 60px 20px;
}
.landing-hero .subtitle {
    font-size: 18px;
    color: #666;
    margin-bottom: 40px;
}
.landing-features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin-bottom: 50px;
}
.landing-features .stat-card i {
    font-size: 36px;
    color: #3498db;
    margin-bottom: 15px;
}
.landing-cta {
    display: flex;
    gap: 20px;
    justify-content: center;
}
.landing-cta .btn {
    font-size: 18px;
    padding: 15px 40px;
}
.landing-cta .btn-secondary {
    background: #eee;
    color: #333;
}

/* ── Auth pages (login, register, password forms) ────────────────────── */
.auth-wrapper {
    align-content: center;
    display: flex;
    justify-content: center;
    padding: 50px 20px;
}
.auth-wrapper .login-container {
    max-width: 500px;
}
.form-section-title {
    margin-top: 30px;
    margin-bottom: 10px;
}
.name-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}
.address-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 15px;
}
.form-hint {
    color: #666;
    font-size: 13px;
}
.form-actions {
    margin-top: 20px;
    display: flex;
    gap: 15px;
}
.form-actions-mt {
    margin-top: 30px;
    display: flex;
    gap: 15px;
}
.attempts-text {
    font-size: 0.8em;
    text-align: center;
}

/* ── Payouts legacy heading ──────────────────────────────────────────── */
.legacy-heading {
    margin-top: 30px;
    font-size: 16px;
    color: #555;
}

/* ── Dashboard request-payout link ───────────────────────────────────── */
.request-payout-link {
    display: inline-block;
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #28a745;
    text-decoration: none;
}

/* ── Stats grid overrides (4-col) ────────────────────────────────────── */
.clicks-stats-grid,
.referrals-stats-grid {
    grid-template-columns: repeat(4, 1fr);
}
.payout-stats-grid {
    grid-template-columns: 1fr;
}

/* ── Clicks / Referrals table ────────────────────────────────────────── */
.clicks-table,
.referrals-table {
    font-size: 13px;
    width: 100%;
}
.clicks-table th,
.clicks-table td,
.referrals-table th,
.referrals-table td {
    padding: 10px 8px;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
    /* Nav */
    .affiliate-nav {
        padding: 0;
        min-height: auto;
    }
    .affiliate-nav ul {
        flex-wrap: wrap;
        justify-content: space-around;
        gap: 0;
        width: 100%;
    }
    .affiliate-nav ul li { flex: 1; }
    .affiliate-nav ul li a {
        padding: 10px 5px;
        font-size: 12px;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        width: 100%;
        justify-content: center;
    }
    .affiliate-nav ul li a i { font-size: 14px; }
    .affiliate-nav .nav-right { margin-left: 0; }

    /* Top menu */
    .top-menu-list { display: none; }
    .mobile-menu-toggle { display: block; }

    /* Link box */
    .affiliate-link-box .input-row { flex-direction: column; }
    .affiliate-link-box input { width: 100%; }
    .affiliate-link-box .main-button {
        display: block;
        width: 100%;
        text-align: center;
    }
    .affiliate-link-box #copy-feedback.show {
        display: block !important;
        margin-left: 0 !important;
        margin-top: 10px;
        text-align: center;
    }
    .affiliate-link-box h5,
    .affiliate-link-box p { text-align: center; }
    .welcome-message { text-align: center; }

    /* Stats */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
    }
    .clicks-stats-grid,
    .referrals-stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }

    /* Filters */
    .filter-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .filter-row select { width: 100%; }
    .filter-form {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-group { width: 100%; }
    .filter-group select,
    .filter-group input[type="date"] { width: 100%; }
    .filter-group:last-child {
        flex-direction: row;
        gap: 10px;
    }
    .filter-group:last-child .btn,
    .filter-group:last-child button { flex: 1; }

    /* Tables */
    .hide-mobile { display: none !important; }
    .clicks-table,
    .referrals-table { font-size: 12px; }
    .clicks-table th, .clicks-table td,
    .referrals-table th, .referrals-table td {
        padding: 8px 6px;
    }
    .info-text { font-size: 12px; }

    /* Empty state */
    .empty-state { padding: 30px 15px; }
    .empty-state i { font-size: 36px; }

    /* Landing */
    .landing-features {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .landing-cta {
        flex-direction: column;
        align-items: center;
    }

    /* Dashboard recent activity */
    .recent-activity-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .recent-activity-grid .table-responsive {
        max-height: none;
        overflow-y: visible;
    }
    .section-header {
        flex-wrap: wrap;
        gap: 10px;
    }
    .main-button.small {
        padding: 5px 10px;
        font-size: 11px;
    }
    .link-row { flex-wrap: wrap; }
    .link-url { font-size: 13px; }
    .link-input-row {
        flex-direction: column;
        gap: 10px;
    }
    .link-input-row input {
        width: 100%;
        font-size: 14px;
    }
    .link-input-row button {
        width: 100%;
        justify-content: center;
    }

    /* UTM */
    .utm-params-list ul {
        padding-left: 15px;
        line-height: 2;
    }
    .utm-params-list li { margin-bottom: 8px; }
    .param-desc {
        display: block;
        margin-left: 0;
        margin-top: 2px;
        font-size: 12px;
    }
    .example-link-box { padding: 12px; }
    .example-code {
        font-size: 11px;
        padding: 8px;
    }
    .section-title { font-size: 18px; }
    .stat-card .value { font-size: 24px; }
    .stat-card h3 { font-size: 12px; }
    .stat-card .sub { font-size: 11px; }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    .stat-card { padding: 15px 10px; }
    .stat-card h3 { font-size: 10px; margin-bottom: 8px; }
    .stat-card .value { font-size: 22px; }
    .stat-card .sub { font-size: 10px; }

    .clicks-stats-grid,
    .referrals-stats-grid { gap: 8px; }
    .clicks-stats-grid .stat-card,
    .referrals-stats-grid .stat-card { padding: 12px 8px; }
    .clicks-stats-grid .stat-card h3,
    .referrals-stats-grid .stat-card h3 { font-size: 10px; }
    .clicks-stats-grid .stat-card .value,
    .referrals-stats-grid .stat-card .value { font-size: 20px; }
    .clicks-table,
    .referrals-table { font-size: 11px; }

    .utm-params-list { font-size: 12px; }
    .utm-tip { font-size: 12px; }
    .data-table { font-size: 13px; }
    .data-table th,
    .data-table td { padding: 8px 6px; }
    .link-input-row .btn-text { display: none; }
    .alert { font-size: 13px; padding: 12px; }
    .affiliate-link-box { padding: 15px; }
    .affiliate-link-box h5 { font-size: 16px; }
}
