/* ========== PAY & ACTIVITY TAB ========== */
/* Reusable card system for the Pay & Activity tab on the Account page.
   Replaces the inline-styled blocks in account.js loadActivityContent
   and its sub-loaders (loadFinancialSummary, loadActivityPayoutStatus,
   loadMonthlyStatements). */

/* --- Section wrapper --- */
.activity-section {
    background: var(--bg-alt);
    padding: 22px 22px 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 20px;
}
.activity-section:last-child {
    margin-bottom: 0;
}

/* Section header banner — overrides the global `header` rule by using
   a div, but kept here as a class so a div carries the same look. */
.activity-section-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 18px;
    padding: 16px 22px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: var(--radius);
    color: #fff;
    box-shadow: var(--shadow-sm);
    /* defensive resets in case the global `header` selector still touches it */
    position: static;
    grid-template-columns: none;
    grid-template-rows: none;
    z-index: auto;
    text-align: left;
}
.activity-section-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.3px;
    line-height: 1.2;
    text-shadow: 0 1px 2px rgba(0,0,0,0.18);
}
.activity-section-header p {
    margin: 2px 0 0 0;
    font-size: 13px;
    color: rgba(255,255,255,0.92);
    font-weight: 500;
    line-height: 1.4;
    text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

/* --- Stat tile grid ---
   Flex (not grid) lets tiles share available space when there are
   many (so 4 owner tiles auto-fit per row) but caps each tile at
   280px so a 2-tile renter row doesn't stretch comically wide. */
.stat-tile-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}
.stat-tile-grid > .stat-tile {
    flex: 1 1 200px;
    min-width: 200px;
}

.stat-tile {
    padding: 22px 18px;
    border-radius: var(--radius);
    text-align: center;
    min-height: 104px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    border: none;
    color: #fff;
    background: var(--text-light);
    user-select: none;
}
.stat-tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.stat-tile--static {
    cursor: default;
}
.stat-tile--static:hover {
    transform: none;
    box-shadow: none;
}

.stat-tile__number {
    margin: 0;
    font-size: 32px;
    font-weight: 900;
    color: #fff;
    line-height: 1.1;
    text-shadow: 0 1px 2px rgba(0,0,0,0.18);
}
.stat-tile__label {
    margin: 8px 0 0 0;
    font-size: 12px;
    font-weight: 700;
    color: rgba(255,255,255,0.96);
    letter-spacing: 0.6px;
    text-transform: uppercase;
    text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

/* Stat tile color variants — brand-aligned, consistent across the tab */
.stat-tile--brand {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}
.stat-tile--accent {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
}
.stat-tile--alert {
    /* Pending-action / attention tile */
    background: linear-gradient(135deg, #f5704a 0%, #f5a623 100%);
}
.stat-tile--success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}
.stat-tile--danger {
    background: linear-gradient(135deg, #c0392b 0%, #e74c3c 100%);
}
.stat-tile--neutral {
    background: linear-gradient(135deg, #4b5d6f 0%, #6c7a89 100%);
}

/* --- Info card (ratings, account info, payout setup) --- */
.info-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 14px;
}
.info-card {
    background: var(--bg);
    padding: 18px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.info-card--clickable {
    cursor: pointer;
}
.info-card--clickable:hover {
    box-shadow: var(--shadow);
    border-color: var(--accent);
    transform: translateY(-1px);
}
.info-card__title {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.2px;
}
.info-card__body {
    margin: 0;
    font-size: 13px;
    color: #495057; /* darker than --text-light for better contrast on white cards */
    line-height: 1.6;
}
.info-card__body + .info-card__body {
    margin-top: 4px;
}
.info-card__cta {
    margin: 8px 0 0 0;
    font-size: 13px;
    color: var(--accent);
    font-weight: 600;
}
.info-card__stars {
    color: #f5a623;
    font-size: 17px;
    letter-spacing: 2px;
}
.info-card__stars-empty {
    color: #d8dde3;
}

/* --- Period pills (date-range selector for Financial Overview) --- */
.period-pill-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.period-pill {
    padding: 8px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.period-pill:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.period-pill--active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.period-pill--active:hover {
    color: #fff;
}
.period-custom-range {
    display: none;
    align-items: center;
    gap: 6px;
    margin-left: 4px;
    flex-wrap: wrap;
}
.period-custom-range input[type="date"] {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    background: var(--bg);
}
.period-custom-range button {
    padding: 6px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

/* --- Financial summary cards (4-up tiles inside Financial Overview) --- */
.financial-tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 240px));
    gap: 12px;
    margin-bottom: 20px;
}

/* --- Spending / Earnings breakdown cards --- */
.breakdown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.breakdown-card {
    padding: 16px 18px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    box-shadow: var(--shadow-sm);
}
.breakdown-card--spending {
    border-left-color: #f5576c;
}
.breakdown-card__title {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}
.breakdown-card__row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #495057;
    line-height: 2;
}
.breakdown-card__row--value {
    font-weight: 600;
    color: var(--text);
}
.breakdown-card__row--neg {
    color: var(--danger);
}
.breakdown-card__row--pos {
    color: var(--success);
}
.breakdown-card__row--total {
    border-top: 1px solid var(--border);
    padding-top: 6px;
    margin-top: 6px;
    font-weight: 700;
}
.breakdown-card__row--total.is-positive { color: var(--success); }
.breakdown-card__row--total.is-negative { color: var(--danger); }

/* --- Transactions table --- */
.txn-table-wrap {
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
}
.txn-table {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
    font-size: 14px;
}
.txn-table thead tr {
    background: var(--bg-alt);
    text-align: left;
}
.txn-table th {
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    font-weight: 700;
    font-size: 12px;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.txn-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--bg-alt);
    color: var(--text);
}
.txn-table tr:last-child td {
    border-bottom: none;
}
.txn-table .txn-cell--right { text-align: right; }
.txn-table .txn-cell--ellipsis {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.txn-table .txn-cell--muted { color: var(--text-light); }
.txn-table .txn-cell--neg { color: var(--danger); }
.txn-table .txn-cell--net-pos { font-weight: 700; color: var(--success); }
.txn-table .txn-cell--net-neg { font-weight: 700; color: var(--danger); }
.txn-table .txn-cell--net-info { font-weight: 700; color: #004085; }
.txn-table .txn-cell--net-warn { font-weight: 700; color: #c05621; }

.txn-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    line-height: 1.3;
}
.txn-badge--earned { background: #d4edda; color: #155724; }
.txn-badge--spent { background: #f8d7da; color: #721c24; }
.txn-badge--purchase { background: #cce5ff; color: #004085; }
.txn-badge--credit { background: #fff3cd; color: #856404; }
.txn-badge--info { background: #ffecd2; color: #c05621; }

.txn-empty {
    background: var(--bg);
    padding: 26px 20px;
    border-radius: var(--radius);
    border: 1px dashed var(--border);
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
}

/* --- Statements list --- */
.statements-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.statement-row {
    padding: 12px 16px 12px 18px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.statement-row__label {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}
.statement-row__net {
    margin-left: 12px;
    font-size: 13px;
    font-weight: 700;
}
.statement-row__net.is-positive { color: var(--success); }
.statement-row__net.is-negative { color: var(--danger); }
.statement-row__detail {
    margin-left: 8px;
    font-size: 12px;
    color: var(--text-light);
}
.statement-row__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.statement-btn {
    padding: 6px 14px;
    border-radius: var(--radius);
    background: transparent;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.statement-btn--primary {
    border: 1px solid var(--accent);
    color: var(--accent);
}
.statement-btn--primary:hover {
    background: var(--accent);
    color: #fff;
}
.statement-btn--secondary {
    border: 1px solid var(--text-light);
    color: var(--text-light);
}
.statement-btn--secondary:hover {
    background: var(--text-light);
    color: #fff;
}
.statement-empty {
    background: var(--bg);
    padding: 22px;
    border-radius: var(--radius);
    border: 1px dashed var(--border);
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
}

/* --- Payout status pill --- */
.payout-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.payout-status__label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
}
.payout-pill {
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}
.payout-pill--active { background: #d4edda; color: #155724; }
.payout-pill--incomplete { background: #fff3cd; color: #856404; }
.payout-pill--missing { background: #f8d7da; color: #721c24; }

.payout-help {
    color: var(--text-light);
    font-size: 13px;
    margin: 0 0 14px 0;
    line-height: 1.5;
}

/* --- Sales / purchases inline disclosure --- */
.activity-disclosure {
    margin-top: 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
}
.activity-disclosure[open] {
    padding-bottom: 16px;
}
.activity-disclosure summary {
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
    list-style: none;
}
.activity-disclosure summary::-webkit-details-marker { display: none; }
.activity-disclosure summary::before {
    content: "\25B8";
    color: var(--text-light);
    transition: transform 0.15s;
    display: inline-block;
}
.activity-disclosure[open] summary::before {
    transform: rotate(90deg);
}
.activity-disclosure summary .activity-disclosure__count {
    background: var(--bg-alt);
    color: var(--text-light);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
}
/* Red action-needed pill — surfaces "Needs Attention: N" inline with the
   total-count pill on disclosure summaries. Only shown when count > 0. */
.activity-disclosure summary .activity-disclosure__attention {
    background: #dc3545;
    color: #fff;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.2px;
}
.activity-disclosure__hint {
    color: var(--text-light);
    font-size: 13px;
    margin: 8px 0 12px;
}
.activity-disclosure__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

/* --- Compact rental/listing cards (inline disclosure content) --- */
.compact-card {
    display: flex;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
}
.compact-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--accent);
}
/* Gold outline + soft glow on action-needed bookings so they pop visually.
   Always visible (overrides hover) — the whole point is to draw the eye. */
.compact-card--attention {
    border-color: #c9a84c;
    box-shadow: 0 0 0 1px #c9a84c, 0 4px 10px rgba(201, 168, 76, 0.22);
}
.compact-card--attention:hover {
    box-shadow: 0 0 0 2px #c9a84c, 0 6px 14px rgba(201, 168, 76, 0.3);
    border-color: #c9a84c;
}
.compact-card__thumb {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    background: var(--bg-alt);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-lighter);
    font-size: 22px;
}
.compact-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.compact-card__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}
.compact-card__title {
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.compact-card__meta {
    font-size: 12px;
    color: var(--text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.compact-card__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.compact-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    flex-shrink: 0;
}
.compact-status--available { background: #d4edda; color: #155724; }
.compact-status--rented { background: #cce5ff; color: #004085; }
.compact-status--inactive { background: #f0f0f0; color: #6c757d; }
.compact-status--pending { background: #fff3cd; color: #856404; }
.compact-status--approved { background: #d1ecf1; color: #0c5460; }
.compact-status--active { background: #d4edda; color: #155724; }
.compact-status--completed { background: #e2e3e5; color: #383d41; }
.compact-status--cancelled { background: #f8d7da; color: #721c24; }
/* Sale-specific compact status pills (matches the colors used by the larger
   sale cards in renderSalesInto / Manage Sale modal so the seller sees the
   same color cue everywhere). */
.compact-status--awaitinghandoff { background: #fff3cd; color: #856404; }
.compact-status--awaitingshipment { background: #fff3cd; color: #856404; }
.compact-status--labelready { background: #d1ecf1; color: #0c5460; }
.compact-status--refunded { background: #e2e3e5; color: #383d41; }

.activity-disclosure__view-all {
    display: inline-block;
    margin-top: 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
}
.activity-disclosure__view-all:hover {
    text-decoration: underline;
}

.activity-disclosure__empty {
    padding: 18px;
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
    background: var(--bg-alt);
    border-radius: var(--radius);
}

.activity-disclosure__list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* --- Mobile tweaks --- */
@media (max-width: 540px) {
    .activity-section {
        padding: 18px 16px 20px;
    }
    /* Stretch the financial overview cards to the full container width on
       mobile. The desktop rule caps each card at 240px which leaves a big
       empty gutter on the right when only one card fits per row. */
    .financial-tile-grid {
        grid-template-columns: 1fr;
    }
    .stat-tile {
        padding: 18px 14px;
        min-height: 92px;
    }
    .stat-tile__number {
        font-size: 28px;
    }
    .period-pill {
        padding: 7px 13px;
        font-size: 12px;
    }
    .txn-table th,
    .txn-table td {
        padding: 8px 10px;
    }
}
