/* === IK Affiliates Portal === */
.ik-aff-portal { max-width: 520px; margin: 0 auto; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding: 0 16px 40px; }

/* Auth card */
.ik-aff-auth { background: #fff; border-radius: 12px; box-shadow: 0 4px 24px rgba(0,0,0,.1); overflow: hidden; }

/* Tabs */
.ik-aff-tabs { display: flex; border-bottom: 2px solid #f0f0f0; background: #fafafa; }
.ik-aff-tab { flex: 1; background: transparent !important; border: none !important; border-bottom: 3px solid transparent !important; border-radius: 0 !important; padding: 14px 18px !important; cursor: pointer !important; font-size: 15px !important; color: #888 !important; margin-bottom: -2px; transition: all .2s; font-weight: 500 !important; box-shadow: none !important; }
.ik-aff-tab:hover { color: #555 !important; background: #f5f5f5 !important; }
.ik-aff-tab.active { color: #e87722 !important; border-bottom-color: #e87722 !important; font-weight: 700 !important; background: #fff !important; }
.ik-aff-tab-content { display: none; padding: 24px !important; }
.ik-aff-tab-content.active { display: block; }

/* Form fields — override <p> default margins */
.ik-aff-tab-content p,
.ik-aff-apply p,
.ik-aff-dashboard p { margin: 0 0 14px; }

.ik-aff-tab-content label,
.ik-aff-apply label { display: block; font-size: 13px; font-weight: 600; color: #444; margin-bottom: 4px; }

/* Inputs */
.ik-aff-input { width: 100%; padding: 10px 13px; border: 1.5px solid #e0e0e0; border-radius: 8px; font-size: 14px; box-sizing: border-box; margin-top: 0; transition: border-color .2s, box-shadow .2s; background: #fff; color: #222; }
.ik-aff-input:focus { border-color: #e87722; outline: none; box-shadow: 0 0 0 3px rgba(232,119,34,.12); }
textarea.ik-aff-input { resize: vertical; min-height: 80px; }

/* File input */
input[type="file"].ik-aff-input { padding: 7px 10px; background: #f9f9f9; font-size: 13px; cursor: pointer; }

/* Buttons */
.ik-aff-btn { background: #e87722 !important; color: #fff !important; border: none !important; padding: 11px 24px !important; border-radius: 8px !important; cursor: pointer !important; font-size: 15px !important; font-weight: 600 !important; transition: background .2s, transform .1s; display: inline-block; text-decoration: none; width: 100%; text-align: center; box-sizing: border-box; margin-top: 4px; box-shadow: none !important; }
.ik-aff-btn:hover { background: #c96518 !important; color: #fff !important; transform: translateY(-1px); }
.ik-aff-btn:active { transform: translateY(0); }
.ik-aff-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* Forgot password link */
.ik-aff-tab-content a[href*="lost-password"] { font-size: 13px; color: #888; text-decoration: none; display: block; text-align: center; margin-top: 10px; }
.ik-aff-tab-content a[href*="lost-password"]:hover { color: #e87722; }

/* reCAPTCHA */
.ik-aff-tab-content .g-recaptcha { margin: 12px 0; }

/* Dashboard tabs (logged-in view) */
.ik-aff-dashboard .ik-aff-tabs { border-radius: 8px 8px 0 0; }
.ik-aff-dashboard .ik-aff-tab-content { padding: 20px 0; }

/* Stats */
.ik-aff-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 20px; }
.ik-aff-stat-card { background: #fff; border: 1.5px solid #f0f0f0; border-radius: 10px; padding: 16px 12px; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.ik-aff-stat-label { display: block; font-size: 11px; color: #999; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.ik-aff-stat-value { display: block; font-size: 22px; font-weight: 700; color: #222; }

/* Tables */
.ik-aff-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ik-aff-table th { background: #f8f9fa; text-align: left; padding: 10px 12px; border-bottom: 2px solid #e8e8e8; font-size: 11px; text-transform: uppercase; color: #888; letter-spacing: .4px; }
.ik-aff-table td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; }
.ik-aff-table tr:hover td { background: #fafafa; }

/* Badges */
.ik-aff-badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.ik-aff-badge-unpaid, .ik-aff-badge-pending { background: #fff3cd; color: #856404; }
.ik-aff-badge-approved, .ik-aff-badge-active, .ik-aff-badge-completed { background: #d4edda; color: #155724; }
.ik-aff-badge-paid { background: #cce5ff; color: #004085; }
.ik-aff-badge-rejected, .ik-aff-badge-failed { background: #f8d7da; color: #721c24; }
.ik-aff-badge-processing { background: #e2e3e5; color: #383d41; }
.ik-aff-badge-suspended { background: #f8d7da; color: #721c24; }

/* Notices */
.ik-aff-notice { padding: 16px 20px; border-radius: 10px; margin-bottom: 16px; line-height: 1.5; }
.ik-aff-notice-info { background: #e8f4fd; border: 1px solid #b8daff; color: #004085; }
.ik-aff-notice-error { background: #f8d7da; border: 1px solid #f5c6cb; color: #721c24; }
.ik-aff-notice-success { background: #d4edda; border: 1px solid #c3e6cb; color: #155724; }

/* Messages */
.ik-aff-message { margin-top: 12px; padding: 10px 14px; border-radius: 8px; font-size: 14px; display: none; text-align: center; }
.ik-aff-message.ik-aff-msg-success { display: block; background: #d4edda; color: #155724; }
.ik-aff-message.ik-aff-msg-error { display: block; background: #f8d7da; color: #721c24; }

/* Referral link box */
.ik-aff-link-box { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.ik-aff-link-input { flex: 1; background: #f8f9fa; font-family: monospace; font-size: 13px; }
.ik-aff-muted { color: #999; font-size: 13px; line-height: 1.6; }

/* Referral field autocomplete */
.ik-aff-referral-field { position: relative; }
.ik-aff-referral-suggestions { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid #e0e0e0; border-top: none; border-radius: 0 0 8px 8px; z-index: 100; max-height: 200px; overflow-y: auto; box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.ik-aff-referral-suggestion { padding: 9px 13px; cursor: pointer; font-size: 14px; }
.ik-aff-referral-suggestion:hover { background: #f5f5f5; }

/* T&C checkbox */
.ik-aff-tab-content label:has(input[type="checkbox"]) { display: flex; align-items: center; gap: 8px; font-weight: 400; color: #555; font-size: 13px; cursor: pointer; }

/* Pending section divider */
.ik-aff-tab-content h3 { font-size: 16px; color: #333; margin: 0 0 16px; padding-bottom: 10px; border-bottom: 1px solid #f0f0f0; }

/* Apply form (logged in, not yet affiliate) */
.ik-aff-apply { background: #fff; border-radius: 12px; box-shadow: 0 4px 24px rgba(0,0,0,.1); padding: 28px 24px; }
.ik-aff-apply h3 { margin: 0 0 8px; font-size: 20px; color: #222; }
.ik-aff-apply > p:first-of-type { color: #666; margin-bottom: 20px; }

/* === Responsive === */

/* -- Admin table (wp-list-table): horizontal scroll on smaller screens -- */
@media (max-width: 1200px) {
    .wrap > table.wp-list-table.widefat { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .wrap > table.wp-list-table.widefat thead,
    .wrap > table.wp-list-table.widefat tbody,
    .wrap > table.wp-list-table.widefat tr { display: table; width: 100%; table-layout: auto; }
    .wrap > table.wp-list-table.widefat th,
    .wrap > table.wp-list-table.widefat td { white-space: nowrap; }
    .wrap > table.wp-list-table.widefat td:last-child { white-space: normal; min-width: 160px; }
}

/* -- Admin: stack action buttons on narrow screens -- */
@media (max-width: 900px) {
    .wrap > table.wp-list-table.widefat td:last-child { min-width: 130px; }
    .wrap > table.wp-list-table.widefat td:last-child .button { display: block; width: 100%; margin: 0 0 4px; box-sizing: border-box; text-align: center; }
    .wrap > table.wp-list-table.widefat td:last-child .button:last-child { margin-bottom: 0; }

    /* Create form fields full width */
    #ik-aff-create-form .regular-text { width: 100%; box-sizing: border-box; }
    #ik-aff-create-form { padding: 12px 14px; }

    /* Search bar stack */
    #ik-aff-search-input { width: 100%; box-sizing: border-box; margin-bottom: 8px; margin-right: 0 !important; }
}

/* -- Admin payout modal responsive -- */
@media (max-width: 600px) {
    #ik-aff-payout-modal > div { padding: 20px 16px !important; max-width: 100% !important; width: 96% !important; margin: 8px; box-sizing: border-box; }
    #ik-aff-payout-modal > div h3 { font-size: 16px !important; }
    #ik-aff-payout-modal > div p { font-size: 14px; word-break: break-word; }
    #ik-pp-modal-actions { flex-direction: column !important; gap: 8px !important; }
    #ik-pp-modal-actions .button { width: 100%; text-align: center; box-sizing: border-box; height: auto !important; padding: 10px 16px !important; }

    /* Admin detail rows wrap better */
    .wrap > table.wp-list-table.widefat td[colspan] div[style*="display:flex"] { flex-direction: column; gap: 8px !important; }
}

/* -- Frontend portal responsive -- */
@media (max-width: 600px) {
    .ik-aff-portal { padding: 0 8px 32px; }

    /* Tabs: horizontally scrollable when many tabs */
    .ik-aff-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .ik-aff-tabs::-webkit-scrollbar { display: none; }
    .ik-aff-tab { font-size: 13px !important; padding: 11px 10px !important; white-space: nowrap; flex-shrink: 0; min-width: auto; }

    .ik-aff-tab-content { padding: 18px 14px !important; }

    /* Stats: 2 columns on mobile */
    .ik-aff-stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .ik-aff-stat-card { padding: 12px 8px; }
    .ik-aff-stat-label { font-size: 10px; }
    .ik-aff-stat-value { font-size: 18px; }

    /* Referral link box stack */
    .ik-aff-link-box { flex-direction: column; }
    .ik-aff-link-box .ik-aff-btn { width: 100%; }
    .ik-aff-link-input { font-size: 12px; }

    /* Frontend tables: horizontal scroll */
    .ik-aff-table { font-size: 12px; display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .ik-aff-table thead, .ik-aff-table tbody { display: table; width: 100%; table-layout: auto; }
    .ik-aff-table th, .ik-aff-table td { padding: 8px 6px; white-space: nowrap; }

    /* Auth card */
    .ik-aff-auth { border-radius: 8px; }
    .ik-aff-apply { padding: 20px 16px; border-radius: 8px; }

    /* Notices */
    .ik-aff-notice { padding: 14px 14px; font-size: 14px; }
}

@media (max-width: 380px) {
    .ik-aff-stats { grid-template-columns: 1fr; }
    .ik-aff-tab { font-size: 12px !important; padding: 10px 8px !important; }
    .ik-aff-stat-value { font-size: 16px; }
}
