/**
 * Frontend styles for the Gamification tab on the MemberCore account page.
 *
 * @package membercore\gamification
 */

/* Outer wrapper */
.mcgf-gamification-wrap {
    max-width: 800px;
}

/* Sub-tab nav strip */
.mcgf-gamification-wrap .mcgf-subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    list-style: none;
    list-style-type: none;
    margin: 0 0 24px;
    padding: 0;
    border-bottom: 2px solid #e2e8f0;
}

.mcgf-gamification-wrap .mcgf-subnav-item {
    list-style: none;
    list-style-type: none;
    display: block;
    margin: 0;
    padding: 0;
}

.mcgf-gamification-wrap .mcgf-subnav-item::before,
.mcgf-gamification-wrap .mcgf-subnav-item::marker {
    content: none;
    display: none;
}

.mcgf-subnav-item > a {
    display: inline-block;
    padding: 10px 16px;
    text-decoration: none;
    color: #64748b;
    font-size: 14px;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.mcgf-subnav-item > a:hover,
.mcgf-subnav-item > a:focus {
    color: #1e293b;
}

.mcgf-subnav-active > a {
    color: #6366f1;
    border-bottom-color: #6366f1;
}

/* Header: Points + Rank.
   Items center on the cross-axis so the points column doesn't read
   like an orphan in the corner when the rank column is short. */
.mcgf-rewards-header {
    display: flex;
    gap: 32px;
    align-items: center;
    padding: 28px 24px;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.mcgf-points-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
    flex: 0 0 auto;
}

.mcgf-points-value {
    font-size: 42px;
    font-weight: 800;
    line-height: 1;
    color: #1d2327;
    font-variant-numeric: tabular-nums;
}

.mcgf-points-label {
    font-size: 13px;
    color: #64748b;
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

.mcgf-rank-display {
    flex: 1 1 280px;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mcgf-rank-badge {
    width: 52px;
    height: 52px;
    object-fit: contain;
}

.mcgf-rank-label {
    font-size: 18px;
    font-weight: 700;
    color: #1d2327;
}

.mcgf-no-rank {
    color: #94a3b8;
    font-style: italic;
}

.mcgf-rank-max {
    color: #059669;
    font-weight: 600;
    font-size: 13px;
}

/* Progress bar */
.mcgf-rank-progress {
    width: 100%;
}

.mcgf-progress-bar {
    width: 100%;
    height: 10px;
    background: #e2e8f0;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 6px;
}

.mcgf-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #818cf8, #a78bfa);
    border-radius: 5px;
    transition: width 0.4s ease;
    min-width: 2px;
}

.mcgf-progress-text {
    font-size: 13px;
    color: #64748b;
}

/* Sections */
.mcgf-rewards-section {
    margin-bottom: 28px;
}

.mcgf-rewards-section h3 {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
    color: #1e293b;
}

.mcgf-locked-heading {
    font-size: 14px;
    color: #64748b;
    font-weight: 600;
}

/* Badge grid */
.mcgf-badge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 14px;
}

.mcgf-badge-grid-recent {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.mcgf-badge-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    text-align: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mcgf-badge-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.mcgf-badge-img {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.mcgf-badge-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.mcgf-badge-locked {
    border-style: dashed;
    border-color: #cbd5e1;
}

.mcgf-badge-locked .mcgf-badge-locked-img {
    opacity: 0.35;
    filter: grayscale(100%);
}

.mcgf-mystery-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
    border-radius: 50%;
    font-size: 28px;
    font-weight: 700;
    color: #94a3b8;
}

.mcgf-badge-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.mcgf-badge-title {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}

.mcgf-hidden-title {
    color: #94a3b8;
}

.mcgf-badge-date {
    font-size: 11px;
    color: #94a3b8;
}

.mcgf-badge-progress {
    font-size: 12px;
    color: #6366f1;
    font-weight: 600;
    margin-top: 2px;
}

/* Activity feed (Overview recent activity mini-list) */
.mcgf-gamification-wrap .mcgf-activity-feed {
    list-style: none;
    list-style-type: none;
    margin: 0;
    padding: 0;
}

.mcgf-gamification-wrap .mcgf-activity-feed-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
    list-style: none;
    list-style-type: none;
}

.mcgf-gamification-wrap .mcgf-activity-feed-item .mcgf-action-badge {
    flex: 0 0 auto;
}

.mcgf-gamification-wrap .mcgf-activity-feed-item .mcgf-activity-feed-desc {
    flex: 1 1 auto;
    min-width: 0;
}

.mcgf-gamification-wrap .mcgf-activity-feed-item::before,
.mcgf-gamification-wrap .mcgf-activity-feed-item::marker {
    content: none;
    display: none;
}

.mcgf-activity-feed-item:last-child {
    border-bottom: none;
}

.mcgf-activity-feed-desc {
    color: #1e293b;
    flex: 1;
}

.mcgf-activity-feed-date {
    color: #94a3b8;
    font-size: 12px;
    white-space: nowrap;
}

/* History tables (Points + Activity) */
.mcgf-history-table {
    width: 100%;
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.mcgf-history-table thead th {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 2px solid #e2e8f0;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #f8fafc;
}

.mcgf-history-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
    color: #334155;
}

.mcgf-history-table tbody tr:hover {
    background: #f8fafc;
}

.mcgf-history-table tbody tr:last-child td {
    border-bottom: none;
}

.mcgf-history-amount {
    text-align: right;
    width: 80px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.mcgf-positive {
    color: #059669;
}

.mcgf-negative {
    color: #dc2626;
}

/* Filter bar (Points + Activity).
   All filter controls sit on a single row. The bar wraps to new rows
   on narrow viewports via flex-wrap. */
.mcgf-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
    align-items: flex-end;
    margin-bottom: 16px;
    padding: 14px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

/* Override MemberCore's `.mc_wrapper label { width: 100% !important }`
   that would otherwise stretch each filter field across the whole row.
   The parent rule uses !important so we have to match it. */
.mcgf-gamification-wrap label.mcgf-filter-field {
    width: auto !important;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    min-width: 0;
    flex: 0 0 auto;
}

/* Date range pair: From and To always sit immediately next to each
   other; they only wrap as a unit when the bar wraps. */
.mcgf-filter-daterange {
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    align-items: flex-end;
    flex: 0 0 auto;
}

/* Pin explicit widths on the form controls so MemberCore's broad
   `.mc_wrapper input` / `.mc_wrapper select` rules don't stretch them
   to 100%. Sizes chosen so a full Activity-tab filter bar (FROM, TO,
   action select, Apply, optional Clear link) fits in narrower hosts
   like the [mcgf_gamification] shortcode container. */
.mcgf-gamification-wrap .mcgf-filter-bar input[type="date"] {
    width: 150px;
    max-width: 100%;
    padding: 7px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    box-sizing: border-box;
}

.mcgf-gamification-wrap .mcgf-filter-bar select {
    width: 180px;
    max-width: 100%;
    padding: 7px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    box-sizing: border-box;
}

.mcgf-filter-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
}

.mcgf-filter-label {
    font-size: 12px;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.mcgf-button {
    padding: 8px 16px;
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.mcgf-button:hover,
.mcgf-button:focus {
    background: #4f46e5;
}

.mcgf-button-link {
    font-size: 13px;
    color: #64748b;
    text-decoration: underline;
    align-self: center;
}

.mcgf-button-link:hover,
.mcgf-button-link:focus {
    color: #1e293b;
}

/* Pagination */
.mcgf-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    font-size: 13px;
}

.mcgf-pagination-link {
    padding: 6px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    color: #1e293b;
    text-decoration: none;
    font-weight: 600;
    background: #fff;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.mcgf-pagination-link:hover,
.mcgf-pagination-link:focus {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.mcgf-pagination-status {
    color: #64748b;
}

/* Rank ladder */
.mcgf-gamification-wrap .mcgf-rank-ladder {
    list-style: none;
    list-style-type: none;
    margin: 16px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mcgf-gamification-wrap .mcgf-rank-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    list-style: none;
    list-style-type: none;
}

.mcgf-gamification-wrap .mcgf-rank-row::before,
.mcgf-gamification-wrap .mcgf-rank-row::marker {
    content: none;
    display: none;
}

.mcgf-rank-row-current {
    border-color: #6366f1;
    background: linear-gradient(135deg, #f5f3ff, #eef2ff);
}

.mcgf-rank-row-locked {
    opacity: 0.7;
}

.mcgf-rank-row-locked .mcgf-rank-row-img {
    filter: grayscale(80%);
}

.mcgf-rank-row-img {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mcgf-rank-row-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.mcgf-rank-row-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mcgf-rank-row-title {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
}

.mcgf-rank-row-required {
    font-size: 12px;
    color: #64748b;
}

.mcgf-rank-row-state {
    flex-shrink: 0;
}

.mcgf-rank-pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mcgf-rank-pill-current {
    background: #6366f1;
    color: #fff;
}

.mcgf-rank-pill-earned {
    background: #d1fae5;
    color: #065f46;
}

.mcgf-rank-pill-locked {
    background: #f1f5f9;
    color: #64748b;
}

/* Settings (leaderboard toggle on Overview) */
.mcgf-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.mcgf-setting-desc {
    margin-top: 4px;
    font-size: 12px;
    color: #64748b;
}

/* Action badges (Activity tab + Recent activity feed)
   Colors mirror the admin Activity Log so member and admin views stay
   visually consistent. */
.mcgf-action-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.mcgf-action-points_awarded {
    background: #e6f7e6;
    color: #00700e;
}

.mcgf-action-points_deducted {
    background: #fce8e8;
    color: #b91c1c;
}

.mcgf-action-manual_adjustment {
    background: #e8f0fe;
    color: #1a56db;
}

.mcgf-action-achievement_unlocked {
    background: #fef3c7;
    color: #92400e;
}

.mcgf-action-achievement_revoked {
    background: #fce8e8;
    color: #b91c1c;
}

.mcgf-action-rank_promoted {
    background: #ede9fe;
    color: #5b21b6;
}

/* Sidebar active state for the Gamification nav item.
   CoreLaunch's account nav adds `meco-active-nav-tab` to the active
   <li>; we mirror the visual treatment used for Home/Payments/etc. so
   the item reads "selected" while the user is anywhere inside the
   Gamification tab (any sub-tab). */
.meco-nav .meco-nav-item.meco-active-nav-tab > a,
#meco-account-nav .meco-nav-item.meco-active-nav-tab > a {
    color: #fff;
    font-weight: 700;
}

/* JS-strategy section visibility.
   When tab_strategy='js', sections are stacked but only the active one
   is shown. The inline style="display:none" set by render() is
   defense-in-depth in case CSS has not loaded yet. */
.mcgf-gamification-wrap[data-tab-strategy="js"] .mcgf-section {
    display: none;
}

.mcgf-gamification-wrap[data-tab-strategy="js"] .mcgf-section.mcgf-tab-active {
    display: block;
}

/* Shortcode surface: full-width within its host, no extra outer chrome. */
.mcgf-surface-shortcode {
    width: 100%;
}

/* User-profile surface: outer block separates the gamification section
   from the rest of the WP profile/edit page with top + bottom dividers
   so admins can tell at a glance where it begins and ends. */
.mcgf-user-profile-block {
    margin: 32px 0;
    padding: 24px 0;
    border-top: 1px solid #c3c4c7;
    border-bottom: 1px solid #c3c4c7;
}

.mcgf-user-profile-heading {
    font-size: 1.3em;
    margin: 0 0 16px;
    padding: 0;
}

.mcgf-surface-user-profile {
    margin-top: 12px;
}

.mcgf-surface-user-profile .mcgf-subnav {
    margin-top: 0;
}

/* The WP user-edit screen wraps everything in a top-level <form>, so
   the parser drops our inner <form class="mcgf-filter-form"> and the
   filter children become orphans. The flex layout still works because
   we render an inner <div class="mcgf-filter-bar"> that survives the
   form drop, and gamification-panel-tabs.js intercepts Apply clicks
   to build a `mcgf_*`-prefixed URL instead of posting to the outer
   profile form. No surface-specific overrides needed here. */

/* Admin actions tab body on the user-profile surface.
   Lives inside the shared GamificationPanel section wrapper, so no
   outer border/spacing is needed. The .mcgf-profile-section children
   provide their own internal spacing. */
.mcgf-user-profile-actions > .description {
    margin: 0 0 12px;
}

/* Logged-out shortcode message. */
.mcgf-shortcode-login {
    padding: 12px 16px;
    background: #f5f7fa;
    border: 1px solid #dcdcde;
    border-radius: 6px;
    color: #4a5568;
}

/* Revoke-by-select row in the admin actions panel. */
.mcgf-revoke-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}

/* Empty states */
.mcgf-empty-state {
    color: #94a3b8;
    font-style: italic;
    font-size: 14px;
    padding: 16px 0;
}

/* Responsive */
@media (max-width: 600px) {
    .mcgf-rewards-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 24px 20px;
    }

    .mcgf-badge-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 10px;
    }

    .mcgf-badge-card {
        padding: 12px 8px;
    }

    .mcgf-rank-row {
        flex-wrap: wrap;
    }

    .mcgf-pagination {
        flex-direction: column;
        gap: 8px;
    }

    .mcgf-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .mcgf-filter-daterange {
        flex-wrap: wrap;
    }

    .mcgf-gamification-wrap .mcgf-filter-bar input[type="date"],
    .mcgf-gamification-wrap .mcgf-filter-bar select {
        width: 100%;
    }

    .mcgf-gamification-wrap label.mcgf-filter-field {
        width: 100% !important;
    }

    .mcgf-button-link {
        align-self: flex-start;
    }
}
