/* ==========================================================================
   components/cards.css — cards, panels and stat tiles
   --------------------------------------------------------------------------
   Used by: dashboards, landing, settings pages, developers portal.
   FLAT: a card is a white surface with a 1px border — nothing else.
   ========================================================================== */

/* ----- Card — the basic content panel --------------------------------------- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-5);
}

/* Card with separated header row (title + optional action button) —
   wraps on narrow screens so buttons/badges never overflow. */
.card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--color-border);
}

.card-header .badge {
    flex-shrink: 0;                       /* a long title must not crush it */
}

.card-header h2,
.card-header h3 {
    margin: 0;
}

/* ----- Clickable card (e.g. User / Admin choice on the landing page) --------- */
.card-link {
    display: block;
    color: var(--color-text);
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.card-link:hover {
    border-color: var(--color-primary);
    color: var(--color-text);
}

/* ----- Stat tile — uppercase label + big value + faded corner icon -----------
   A "kučica": white flat card with a large, faded Phosphor icon tucked in
   the bottom-right corner (decorative). Used on user & admin dashboards. */
.stat {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;              /* balanced top/bottom whitespace */
    min-width: 0;                         /* never force the grid to overflow */
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 14px;                   /* rounder corners */
    padding: var(--space-4) var(--space-5);
    min-height: 88px;
}

.stat .stat-label {
    position: relative;
    z-index: 1;
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-muted);
    line-height: 1.3;
    /* Reserve two lines so a one- or two-line title takes the same space on
       every tile — keeps all labels and values aligned across the row. */
    min-height: 2.6em;
}

.stat .stat-value {
    position: relative;
    z-index: 1;
    font-size: var(--font-size-lg);        /* a touch smaller than before */
    font-weight: var(--font-weight-bold);
    color: var(--color-text);              /* always black, incl. accent */
    margin-top: var(--space-2);
    line-height: 1.2;
}

/* Accent stat — highlights the headline finance figure (commission) with a
   subtle tint + primary border. The number itself stays black. */
.stat.stat-accent {
    border-color: var(--color-primary);
    background: var(--color-primary-soft, rgba(6, 63, 71, 0.06));
}

/* Clickable stat tile (dashboards) — whole card is a link on desktop.
   Keeps the same flex layout as a plain .stat (only display was overridden). */
a.stat {
    color: inherit;
    transition: border-color var(--transition-fast);
}

a.stat:hover {
    border-color: var(--color-primary);
    color: inherit;
}

/* The big faded corner icon — large and pushed mostly OUT of the box */
.stat .stat-bg-icon {
    position: absolute;
    right: -34px;
    bottom: -44px;
    font-size: 150px;
    line-height: 1;
    opacity: 0.08;
    color: var(--color-primary);
    transform: rotate(-15deg);
    pointer-events: none;
    z-index: 0;
}

/* Alert state — the corner icon blinks in a warning colour when the tile
   has unprocessed items (pending approvals, payments/payouts in review). */
@keyframes stat-blink {
    0%, 100% { opacity: 0.30; }
    50% { opacity: 0.05; }
}

.stat.is-alert .stat-bg-icon {
    color: var(--color-warning);
    opacity: 0.30;
    animation: stat-blink 1.1s ease-in-out infinite;
}

/* Negative balance — the whole tile pulses red so the deficit is unmissable. */
@keyframes stat-negative-blink {
    0%, 100% { border-color: var(--color-danger); background: var(--color-surface); }
    50% { border-color: var(--color-danger); background: var(--color-danger-bg); }
}

.stat.stat-negative {
    border-color: var(--color-danger);
    animation: stat-negative-blink 1.1s ease-in-out infinite;
}

.stat.stat-negative .stat-bg-icon {
    color: var(--color-danger);
    opacity: 0.16;
}

/* Respect users who ask for less motion — show the state without blinking. */
@media (prefers-reduced-motion: reduce) {
    .stat.stat-negative {
        animation: none;
        background: var(--color-danger-bg);
    }
    .stat.is-alert .stat-bg-icon {
        animation: none;
    }
}

/* ----- Card grid — responsive grid of cards/stats ------------------------------ */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: var(--space-4);
}
