﻿/* ============================================
   Phoenix Activation System - Card Components
   Cards, Stats, Dashboard Widgets
   ============================================ */

/* ========== Base Card ========== */
.card {
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--color-border);
    overflow: hidden;
    transition: var(--transition-control);
}

/* Hover only on a device that can hover (T-20261030-03 D6): a phone kept the hover shadow after a tap. */
@media (hover: hover) {
    .card:hover {
        box-shadow: var(--shadow-raised);
    }
}

/* ========== Card Header ========== */
.card-header-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin: 0;
}

/* ========== Card Body ========== */
.card-body {
    padding: var(--space-lg);
}

.card-body-compact {
    padding: var(--space-md);
}

/* ========== Card Footer ========== */
.card-footer {
    padding: var(--space-lg);
    border-top: 1px solid var(--color-border);
    background-color: var(--bg-secondary);
}

.card-footer-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
}

/* ========== Stat Card ========== */
.stat-card {
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--color-border);
    transition: var(--transition-control);
}

@media (hover: hover) {
    .stat-card:hover {
        box-shadow: var(--shadow-raised);
        transform: translateY(-2px);
    }
}

.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.stat-card-title {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* T-20261124-01 C9 (the local check; the owner's yes D380): from 1025 to 1279 px a tile of the 4-column grid is 147 to
   210 px wide beside the sidebar, too narrow for a long title ("SUBSCRIPTIONS") and the 40 px icon: the icon pushed out of
   its card. The icon is decoration (the number says the same; Boss Fleet's alert icon colour too), so it hides there; the
   title and the number stay whole. Other tile grids (fin-tiles, dash-tile) keep it. The bounds hold a zoom width between
   1024 and 1025 px too (layout.css takes the 2-column form at 1024 px and less). Accepted limits: with the sidebar
   collapsed the icons hide although they would fit; at 1280 px about 6 px are left, so a larger browser font can push an
   icon out again (review C5 #2, #8). */
@media (min-width: 1024.02px) and (max-width: 1279.98px) {
    .grid-cols-4 .stat-card-icon {
        display: none;
    }
}

.stat-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xl);
    flex-shrink: 0; /* a long title must not squeeze the icon box */
}

.stat-card-icon-primary {
    background-color: var(--color-primary-light);
    color: var(--color-primary);
}

.stat-card-icon-success {
    background-color: var(--color-success-light);
    color: var(--color-success);
}

.stat-card-icon-warning {
    background-color: var(--color-warning-light);
    color: var(--color-warning);
}

.stat-card-icon-danger {
    background-color: var(--color-danger-light);
    color: var(--color-danger);
}

.stat-card-icon-info {
    background-color: var(--color-info-light);
    color: var(--color-info);
}

.stat-card-value {
    font-size: var(--font-size-3xl);
    font-weight: var(--font-weight-bold);
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: var(--space-sm);
}

/* A tile without a footer has no space under its value. */
.stat-card-value:last-child {
    margin-bottom: 0;
}

.stat-card-footer {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--font-size-sm);
}

/* ========== Finance tile grid (T-20261114-03 A8, D292) ==========
   The stat-card tiles of My finance, Expenses and Overdue: 2 columns at every width (a framework grid gives 1 column on a phone);
   .fin-tiles-three: 3 columns on the desktop, on a phone 2 with the first tile over the full row (My finance's "Money held").
   The compact phone rules reach only the tiles inside .fin-tiles: another page's stat-card keeps its look. */
.fin-tiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-md);
}

.fin-tiles.fin-tiles-three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 768px) {
    .fin-tiles {
        gap: var(--space-sm);
    }

    .fin-tiles.fin-tiles-three {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .fin-tiles.fin-tiles-three > :first-child {
        grid-column: 1 / -1;
    }

    /* A half tile has about 136 px inside at 375 px (the phone rules of Admin/ApproveUsers.razor.css) */
    .fin-tiles .stat-card {
        padding: var(--space-md);
    }

    .fin-tiles .stat-card-title {
        letter-spacing: 0;
        text-transform: none;
    }

    .fin-tiles .stat-card-icon {
        width: 32px;
        height: 32px;
        font-size: var(--font-size-base);
    }

    /* A money total like 290,800.35 must fit a half tile: a smaller value that can break (since T-20261114-03 E16 also on Overdue, the owner's yes) */
    .fin-tiles .stat-card-value {
        font-size: var(--font-size-xl);
        overflow-wrap: anywhere;
    }
}

/* ========== Finance rows (T-20261122-01 C1, C6, D341) ==========
   The money rows of the finance pages and their row components: before, a copy in each page file. A page rule that differs
   stays in the page's own file (the scoped rule weighs more). */
.fin-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--color-border);
}

.fin-row:last-child {
    border-bottom: none;
}

.fin-money {
    font-variant-numeric: tabular-nums;
}

/* A voided charge or an undone row stays visible, in grey */
.fin-voided {
    color: var(--text-secondary);
}

.fin-voided .fin-money {
    text-decoration: line-through;
}

.fin-warning {
    color: var(--color-warning);
}

/* ========== Dashboard tile (T-20261114-03 A8, D292) ==========
   The tile of the Dashboard and of the Finance dashboard: a tile with one target is one link (a.dash-tile, with the hover); a tile with
   several targets or a list is a div with no hover, and each row is its own link: never a link inside a link. Inside: the stat-card-header,
   -title, -icon and -value classes above. A framework class has no scoped attribute, so the link colour is held here against a:hover of base.css. */
.dash-tile {
    display: block;
    min-height: 44px;
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--color-border);
    color: inherit;
    text-decoration: none;
    transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

a.dash-tile,
a.dash-tile:hover {
    color: inherit;
}

.dash-tile:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* A phone keeps :hover after a tap; only a link tile shows it */
@media (hover: hover) {
    a.dash-tile:hover {
        box-shadow: var(--shadow-raised);
        border-color: var(--color-primary);
    }
}

@media (max-width: 768px) {
    .dash-tile {
        padding: var(--space-md);
    }

    .dash-tile .stat-card-title {
        letter-spacing: 0;
        text-transform: none;
    }
}

/* ========== Client Card ========== */
.client-card-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--gradient-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--text-inverse);
}

/* The smaller avatars of the list rows (T-20261122-01 C1): -sm in a table row, -md on a phone card (an avatar letter keeps its raw size) */
.client-card-avatar-sm {
    width: 36px;
    height: 36px;
    min-width: 36px;
    font-size: 14px;
}

.client-card-avatar-md {
    width: 40px;
    height: 40px;
    min-width: 40px;
    font-size: 14px;
}

/* ========== Activation Card ========== */
.activation-card {
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--color-border);
    transition: var(--transition-control);
}
