/* Admin Platform Statistics dashboard.
   Namespaced with .ps- to avoid collisions; loaded globally via App.razor.

   Design intent: clear hierarchy (featured hero cards, then charts, then a quiet metric grid),
   calm surfaces (hairline border + soft shadow), and color reserved for meaning (trend up/down). */

/* ---- Section header (labeled divider) ---- */
.ps-section {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 28px 0 12px;
}

.ps-section:first-of-type {
    margin-top: 8px;
}

.ps-section__dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.ps-section__dot--neutral {
    background: var(--mud-palette-text-secondary);
    opacity: 0.45;
}

.ps-section__title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
}

.ps-section__rule {
    height: 1px;
    flex: 1 1 auto;
    background: var(--mud-palette-lines-default);
}

/* ---- Shared surface: cards (hero + chart panels) ---- */
.ps-card {
    height: 100%;
    box-sizing: border-box;
    padding: 16px 18px;
    border-radius: 16px;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
}

.ps-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

.ps-card__title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--mud-palette-text-primary);
}

.ps-card__sub {
    font-size: 0.78rem;
    line-height: 1.3;
    color: var(--mud-palette-text-secondary);
    margin-top: 2px;
}

/* ---- Featured hero card ---- */
.ps-hero {
    display: flex;
    flex-direction: column;
    min-height: 188px;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.ps-hero:hover {
    border-color: var(--mud-palette-lines-inputs);
    box-shadow: 0 4px 14px rgba(16, 24, 40, 0.10);
}

.ps-hero__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ps-hero__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 11px;
    color: var(--mud-palette-tertiary);
    background: var(--mud-palette-action-default-hover); /* fallback if color-mix unsupported */
    background: color-mix(in srgb, var(--mud-palette-tertiary) 12%, transparent);
}

.ps-hero__eyebrow {
    margin-top: 12px;
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary);
}

.ps-hero__value {
    font-size: 2.1rem;
    font-weight: 700;
    line-height: 1.05;
    margin-top: 2px;
    color: var(--mud-palette-text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.ps-hero__label {
    font-size: 0.82rem;
    line-height: 1.2;
    margin-top: 2px;
    color: var(--mud-palette-text-secondary);
}

.ps-hero__spark {
    margin-top: auto;
    padding-top: 12px;
}

.ps-hero__foot {
    font-size: 0.72rem;
    line-height: 1.2;
    margin-top: 6px;
    color: var(--mud-palette-text-secondary);
    min-height: 0.9rem;
}

/* ---- Inline SVG sparkline ---- */
.ps-spark {
    position: relative;
    width: 100%;
    display: block;
}

.ps-spark__svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.ps-spark__line {
    fill: none;
    stroke: currentColor;
    stroke-width: 2px;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.ps-spark__area {
    stroke: none;
    fill: currentColor;
    opacity: 0.14;
}

.ps-spark__dot {
    position: absolute;
    right: 0;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    transform: translate(0, -50%);
    box-shadow: 0 0 0 2px var(--mud-palette-surface);
}

/* ---- Secondary KPI tile (calmer: neutral surface, color only on the trend pill) ---- */
.ps-tile {
    height: 100%;
    min-height: 96px;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.ps-tile:hover {
    border-color: var(--mud-palette-lines-inputs);
    box-shadow: 0 3px 10px rgba(16, 24, 40, 0.07);
}

.ps-tile__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 32px;
}

.ps-tile__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    color: var(--mud-palette-text-secondary);
    background: var(--mud-palette-action-default-hover);
}

.ps-tile__value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.05;
    color: var(--mud-palette-text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ps-tile__label {
    font-size: 0.78rem;
    line-height: 1.2;
    color: var(--mud-palette-text-secondary);
}

/* ---- Trend pill (color = meaning) ---- */
.ps-trend {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

.ps-trend__arrow {
    font-size: 0.6rem;
    line-height: 1;
}

.ps-trend--up {
    color: var(--mud-palette-success);
    background: var(--mud-palette-action-default-hover); /* fallback */
    background: color-mix(in srgb, var(--mud-palette-success) 14%, transparent);
}

.ps-trend--down {
    color: var(--mud-palette-error);
    background: var(--mud-palette-action-default-hover); /* fallback */
    background: color-mix(in srgb, var(--mud-palette-error) 14%, transparent);
}

.ps-trend--flat {
    color: var(--mud-palette-text-secondary);
    background: var(--mud-palette-action-default-hover);
}

.ps-trend--all {
    color: var(--mud-palette-text-disabled);
    background: var(--mud-palette-action-default-hover);
    font-weight: 500;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
    .ps-section {
        margin: 22px 0 10px;
    }

    .ps-hero {
        min-height: 0;
    }

    .ps-hero__value {
        font-size: 1.85rem;
    }

    .ps-tile {
        min-height: 84px;
        padding: 12px 13px;
    }

    .ps-tile__value {
        font-size: 1.4rem;
    }
}
