/* ============================================================
   Credit History — [custom_mycred_log]
   Summary strip, filter bar, ledger table, pagination.
   Extracted from mycred-frontend-log.php's old per-instance inline
   <style> block so styles are emitted once regardless of how many
   [custom_mycred_log] instances are on a page.
   ============================================================ */

.mycred-ajax-wrapper {
    position: relative;
    font-family: "Work Sans", sans-serif;
}

/* ---------------------------------------------------------------
   Summary strip
   --------------------------------------------------------------- */
/* auto-fit rather than a fixed 4 columns: the split tile is sometimes omitted
   (see Custom_MyCred_Frontend_Log::get_summary_html()) or replaced by a
   single-stat tile, so the tile count is 3 or 4 depending on live pricing —
   this also makes the two old fixed-breakpoint overrides below unnecessary,
   since minmax() already reflows continuously rather than snapping at 900px/
   480px regardless of how many tiles are actually present. */
.mycred-summary-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.mycred-summary-tile {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 18px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.mycred-summary-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 6px;
}

.mycred-summary-value {
    display: block;
    font-size: clamp(18px, 2vw, 24px);
    font-weight: 700;
    color: #1e293b;
}

.mycred-summary-value--spend {
    color: #b91c1c;
}

.mycred-summary-value--earn {
    color: var(--e-global-color-7355873, #16a34a);
}

.mycred-summary-value--split {
    font-size: clamp(16px, 1.8vw, 20px);
}

/* ---------------------------------------------------------------
   Top-up banner — reassurance that unused credits roll over rather
   than expire (Custom_MyCred_Frontend_Log::get_topup_banner_html()).
   Calm/informational tone, deliberately not the amber "warning" look
   used elsewhere (.dd-account-notice) since this isn't a problem.
   --------------------------------------------------------------- */
.mycred-topup-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 20px;
}

.mycred-topup-banner-icon {
    flex-shrink: 0;
    margin-top: 2px;
    color: #2563eb;
}

.mycred-topup-banner-text {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.55;
    color: #1e3a5f;
}

.mycred-topup-banner-text strong {
    font-weight: 700;
}

@media (max-width: 480px) {
    .mycred-topup-banner {
        flex-direction: column;
        gap: 6px;
    }
}

/* ---------------------------------------------------------------
   Filter bar
   --------------------------------------------------------------- */
.mycred-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.mycred-filter-pills {
    display: inline-flex;
    gap: 6px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 999px;
}

/* !important: same bare-<button>-vs-Elementor-Kit interference as dd-onboarding.css's
   .dd-ob-close/.dd-ob-btn — without it the Kit's own button background/border/padding/
   min-height can win and the pill group loses its shape. */
.mycred-pill.mycred-pill.mycred-pill {
    appearance: none !important;
    border: 1px solid transparent !important;
    background: transparent !important;
    color: #475569 !important;
    font-family: "Work Sans", sans-serif !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    min-height: 0 !important;
    height: auto !important;
    margin: 0 !important;
    padding: 7px 16px !important;
    border-radius: 999px !important;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.mycred-pill.mycred-pill.mycred-pill:hover {
    background: rgba(255, 255, 255, 0.6) !important;
}

.mycred-pill.is-active.is-active.is-active {
    background: #0d3b3e !important;
    border-color: #0d3b3e !important;
    color: #ffffff !important;
}

.mycred-filter-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1 1 auto;
}

/* !important throughout: Elementor's global Kit CSS styles bare <input>/<select>
   elements site-wide (often matching a large heading font-size/font-family), which
   otherwise overrides this — most visibly on <input type="date">, whose native
   "dd/mm/yyyy" hint renders using the input's own font and blows up to heading size
   without this. Same interference/fix documented for bare <button> in dd-onboarding.css. */
.mycred-log-filter,
.mycred-log-date,
.mycred-log-search,
.mycred-log-limit {
    background-color: var(--pmpro--color--base, #fff) !important;
    border: 1px solid var(--pmpro--color--border, #cbd5e1) !important;
    border-radius: var(--pmpro--base--border-radius, 8px) !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
    color: var(--pmpro--color--contrast, #334155) !important;
    font-family: "Work Sans", sans-serif !important;
    font-size: 14px !important;
    font-weight: 400 !important;
    height: 38px !important;
    margin: 0 !important;
    min-height: 0 !important;
    outline: none !important;
    padding: 8px 12px !important;
    line-height: 1.4 !important;
}

.mycred-log-search {
    min-width: 180px;
    flex: 1 1 180px;
}

.mycred-log-date {
    min-width: 140px;
    max-width: 170px;
}

.mycred-log-filter:focus,
.mycred-log-date:focus,
.mycred-log-search:focus,
.mycred-log-limit:focus {
    outline: none !important;
    border-color: #94a3b8 !important;
    box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.2) !important;
}

.mycred-export-form {
    margin: 0 0 0 auto;
}

.mycred-btn-export.mycred-btn-export.mycred-btn-export {
    background: #0d3b3e !important;
    border: 1px solid #0d3b3e !important;
    color: #ffffff !important;
    font-family: "Work Sans", sans-serif !important;
    padding: 9px 18px !important;
    min-height: 0 !important;
    margin: 0 !important;
    border-radius: 8px !important;
    cursor: pointer;
    font-weight: 600 !important;
    font-size: 0.85rem !important;
    white-space: nowrap;
    transition: background 0.2s ease;
}

.mycred-btn-export.mycred-btn-export.mycred-btn-export:hover {
    background: #114f53 !important;
}

/* ---------------------------------------------------------------
   Table
   --------------------------------------------------------------- */
.mycred-table-responsive-wrapper {
    overflow-x: auto;
    margin: 0 0 20px 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
}

.mycred-custom-log-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    background-color: #ffffff;
}

.mycred-custom-log-table th,
.mycred-custom-log-table td {
    padding: 14px 20px;
    border-bottom: 1px solid #eef2f6;
    vertical-align: middle;
}

.mycred-custom-log-table tbody tr:last-child td {
    border-bottom: none;
}

.mycred-custom-log-table td {
    font-size: clamp(13px, 0.9vw, 16px);
    color: #475569;
}

.mycred-custom-log-table th {
    background-color: #f8fafc;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

/* Right-align the amount/balance columns for a tidy ledger feel */
.mycred-custom-log-table th:nth-last-child(-n+2),
.mycred-custom-log-table td:nth-last-child(-n+2) {
    text-align: right;
    white-space: nowrap;
}

.mycred-custom-log-table tbody tr {
    transition: background-color 0.15s ease;
}

.mycred-custom-log-table tbody tr:hover {
    background-color: #f8fafc;
}

.positive-points.positive-points.positive-points {
    color: var(--e-global-color-7355873, #16a34a);
    font-weight: 700;
}

.negative-points.negative-points.negative-points {
    color: #b91c1c;
    font-weight: 700;
}

/* Type badge */
.mycred-type-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.mycred-type-badge--spend {
    background: #fee2e2;
    color: #b91c1c;
}

.mycred-type-badge--earn {
    background: #dcfce7;
    color: #15803d;
}

/* Creator chip inside the Details cell */
.mycred-log-creator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: inherit;
    text-decoration: none;
}

a.mycred-log-creator:hover .mycred-log-creator-name {
    text-decoration: underline;
}

.mycred-log-creator-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.mycred-log-creator--gone {
    color: #94a3b8;
}

.mycred-empty-log {
    text-align: center;
    padding: 40px 20px !important;
}

.mycred-empty-log-text {
    display: block;
    color: #64748b;
    margin-bottom: 10px;
}

.mycred-empty-log-cta {
    display: inline-block;
    color: #0d3b3e;
    font-weight: 600;
    text-decoration: underline;
}

/* ---------------------------------------------------------------
   Pagination & States
   --------------------------------------------------------------- */
.mycred-pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.mycred-pagination-pages {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.mycred-pagination-ellipsis {
    color: #94a3b8;
    padding: 0 4px;
}

.mycred-btn-paginate.mycred-btn-paginate.mycred-btn-paginate,
.mycred-btn-page.mycred-btn-page.mycred-btn-page {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #334155;
    padding: 9px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.875rem;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.mycred-btn-page.mycred-btn-page.mycred-btn-page {
    padding: 8px 13px;
    min-width: 38px;
    text-align: center;
}

.mycred-btn-paginate.mycred-btn-paginate.mycred-btn-paginate:hover:not(:disabled),
.mycred-btn-page.mycred-btn-page.mycred-btn-page:hover:not(.is-current) {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.mycred-btn-paginate.mycred-btn-paginate.mycred-btn-paginate:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.mycred-btn-page.is-current.is-current {
    background: #0d3b3e;
    border-color: #0d3b3e;
    color: #ffffff;
    cursor: default;
}

/* Loading Overlay */
.mycred-ajax-wrapper.is-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(2px);
    z-index: 10;
    border-radius: 12px;
}

/* ============================================================
   Mobile: collapse the table into stacked cards (no h-scroll)
   ============================================================ */
@media (max-width: 640px) {
    .mycred-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .mycred-filter-pills {
        justify-content: center;
    }

    .mycred-export-form {
        margin: 0;
    }

    .mycred-btn-export.mycred-btn-export.mycred-btn-export {
        width: 100%;
    }

    .mycred-table-responsive-wrapper {
        overflow-x: visible;
        border: none;
        box-shadow: none;
        border-radius: 0;
        background: transparent;
    }

    .mycred-custom-log-table,
    .mycred-custom-log-table tbody,
    .mycred-custom-log-table tr,
    .mycred-custom-log-table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    /* Visually hide the header row but keep it for screen readers */
    .mycred-custom-log-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .mycred-custom-log-table tbody tr {
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
        margin-bottom: 14px;
        padding: 6px 16px;
    }

    .mycred-custom-log-table tbody tr:hover {
        background: #ffffff;
    }

    .mycred-custom-log-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 16px;
        padding: 11px 0;
        border-bottom: 1px solid #f1f5f9;
        text-align: right;
        font-size: 15px;
    }

    .mycred-custom-log-table tr td:last-child {
        border-bottom: none;
    }

    /* Field label, taken from the data-label attribute */
    .mycred-custom-log-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #64748b;
        text-transform: uppercase;
        font-size: 0.7rem;
        letter-spacing: 0.04em;
        text-align: left;
        flex-shrink: 0;
    }

    /* Empty state spans the full card cleanly */
    .mycred-custom-log-table td.mycred-empty-log {
        display: block;
        text-align: center;
    }

    .mycred-custom-log-table td.mycred-empty-log::before {
        content: none;
    }

    .mycred-pagination-controls {
        justify-content: center;
    }

    .mycred-pagination-pages {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .mycred-btn-paginate.mycred-btn-paginate.mycred-btn-paginate {
        flex: 1 1 auto;
        text-align: center;
    }
}
