/* ═══════════════════════════════════════════════════════════════════════
   ProjectHelix Statistics card — mirrors ProjectHelix's own "Statistics" tab
   look (KPI tiles, completion bars, medication summary, assigned-employee
   table with avatars). Used by: Pages/ServiceUsers/Details.razor
   ═══════════════════════════════════════════════════════════════════════ */

.stats-section-card {
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.stats-section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.stats-section-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-text);
}

.stats-section-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted, #6b7280);
}

/* ── Filter bar ─────────────────────────────────────────────────────── */
.stats-filter-bar {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.stats-filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 180px;
}

.stats-filter-field label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-muted, #6b7280);
}

.stats-filter-field select {
    flex: none;
    height: 2.1rem;
    min-height: 0;
    padding: 0.3rem 0.6rem;
    line-height: 1.4;
    font-size: 0.85rem;
}

.stats-export-btn {
    margin-left: auto;
}

.stats-loading {
    color: var(--text-muted, #6b7280);
    margin: 0;
}

/* ── KPI tiles ──────────────────────────────────────────────────────── */
.stats-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.stats-kpi-card {
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 8px;
    padding: 0.9rem 1rem;
    background: var(--color-surface-alt, #fafafa);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.stats-kpi-card-header {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.stats-card-title {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-text);
}

.stats-kpi-caption {
    font-size: 0.72rem;
    color: var(--text-muted, #6b7280);
}

.stats-kpi-figures {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1rem;
}

.stats-kpi-figures > div {
    display: flex;
    flex-direction: column;
}

.stats-kpi-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.1;
}

.stats-kpi-label {
    font-size: 0.72rem;
    color: var(--text-muted, #6b7280);
}

.stats-completion-rate {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.stats-completion-bar {
    display: flex;
    width: 100%;
    height: 7px;
    border-radius: 4px;
    overflow: hidden;
    background: #e5e7eb;
}

.stats-completion-segment--complete {
    background: #22a369;
}

.stats-completion-segment--draft {
    background: #f2b544;
}

.stats-completion-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted, #6b7280);
}

.stats-delta {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.15rem;
}

.stats-delta--up {
    color: #22a369;
}

.stats-delta--down {
    color: #d14343;
}

/* ── Medication card ────────────────────────────────────────────────── */
.stats-medication-card {
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 8px;
    padding: 0.9rem 1rem;
    margin-bottom: 1.25rem;
}

.stats-medication-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.stats-medication-grid > div {
    display: flex;
    flex-direction: column;
}

.stats-medication-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-text);
}

.stats-medication-value--given {
    color: #22a369;
}

.stats-medication-value--refused {
    color: #d14343;
}

.stats-medication-label {
    font-size: 0.72rem;
    color: var(--text-muted, #6b7280);
}

.stats-medication-footnote {
    margin: 0.6rem 0 0;
    font-size: 0.75rem;
    color: var(--text-muted, #6b7280);
}

/* ── Assigned employees ─────────────────────────────────────────────── */
.stats-employees-card {
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 8px;
    padding: 0.9rem 1rem;
}

.stats-employees-summary {
    display: flex;
    gap: 2rem;
    margin-bottom: 0.75rem;
}

.stats-employees-summary > div {
    display: flex;
    flex-direction: column;
}

.stats-employees-summary-label {
    font-size: 0.72rem;
    color: var(--text-muted, #6b7280);
}

.stats-employees-summary-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
}

.stats-employees-table th,
.stats-employees-table td {
    vertical-align: middle;
}

.stats-employee-cell {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.stats-employee-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
}

.stats-employee-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.stats-employee-name {
    font-weight: 600;
    color: var(--color-text);
}

@media (prefers-color-scheme: dark) {
    .stats-section-card,
    .stats-kpi-card,
    .stats-medication-card,
    .stats-employees-card {
        background: var(--color-surface, #1e1e1e);
        border-color: var(--color-border, #333);
    }
}
