/* ========================================================================
   Component: Cards — hero, section, stat, efficiency, info
   ======================================================================== */

/* ── Generic Card ── */
.card {
    background: color-mix(in srgb, var(--bg-primary) 92%, transparent);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card + .card { margin-top: var(--space-4); }
.card-header {
    padding: var(--space-4) var(--space-5);
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
    border-bottom: 1px solid var(--border-light);
}
.card-title { margin: 0; font-size: var(--text-md); font-weight: var(--weight-semibold); letter-spacing: -0.01em; }
.card-body { padding: var(--space-5); }

/* ── Page Hero ── */
.page-hero {
    background: linear-gradient(135deg, var(--brand-soft), transparent 60%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem 2rem;
    margin-bottom: var(--space-6);
    position: relative;
    overflow: hidden;
}
.page-hero::before {
    content: '';
    position: absolute;
    right: -60px; top: -60px;
    width: 200px; height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--brand-soft) 0%, transparent 70%);
    opacity: 0.4;
}
.page-hero-inner {
    display: flex; align-items: center; justify-content: space-between;
    position: relative; z-index: var(--z-base);
}
.page-hero-text { flex: 1; }
.page-hero-title {
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.02em;
}
.page-hero-sub {
    color: var(--text-secondary);
    margin-top: var(--space-1);
    font-size: var(--text-md);
}
.page-hero-actions { display: flex; gap: var(--space-2); align-items: center; }
.page-hero-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px; border-radius: var(--radius-full);
    font-size: var(--text-sm); font-weight: var(--weight-semibold);
    border: 1px solid var(--border); background: var(--surface);
}
.page-hero-badge--success { border-color: var(--success); color: var(--success); }
.page-hero-badge--warning { border-color: var(--warning); color: var(--warning); }
.page-hero-badge--info { border-color: var(--info); color: var(--info); }

/* ── Section Card ── */
.section-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--space-5);
    overflow: hidden;
}
.section-card-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--border);
}
.section-card-head h2,
.section-card-head h3 {
    margin: 0; font-size: var(--text-md); font-weight: var(--weight-semibold);
    display: flex; align-items: center; gap: var(--space-2);
}
.section-card-head .section-icon {
    width: 28px; height: 28px; border-radius: var(--radius-sm);
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.section-icon--teal { background: var(--brand-soft); color: var(--brand); }
.section-icon--green { background: var(--success-soft); color: var(--success); }
.section-icon--blue { background: var(--info-soft); color: var(--info); }
.section-icon--purple { background: rgba(167,139,250,0.12); color: #a78bfa; }
.section-icon--amber { background: var(--warning-soft); color: var(--warning); }
.section-icon--red { background: var(--danger-soft); color: var(--danger); }

.section-card-body { padding: var(--space-5) var(--space-6); }
.section-card.collapsed > .section-card-body { display: none; }
.section-chevron {
    transition: transform var(--duration-normal); color: var(--text-muted);
    flex-shrink: 0; margin-left: auto;
}
.section-card.collapsed .section-chevron { transform: rotate(-90deg); }

/* ── Hero Metric Cards ── */
.hero-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.hero-metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-5) var(--space-6);
    position: relative; overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}
.hero-metric-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.hero-metric-card::before {
    content: ''; position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px; border-radius: 4px 0 0 4px;
}
.hero-metric-card--teal::before { background: var(--brand); }
.hero-metric-card--green::before { background: var(--success); }
.hero-metric-card--blue::before { background: var(--info); }
.hero-metric-card--purple::before { background: #a78bfa; }
.hero-metric-card--amber::before { background: var(--warning); }
.hero-metric-card--red::before { background: var(--danger); }
.hero-metric-card--orange::before { background: #fb923c; }
.hero-metric-card--cyan::before { background: #22d3ee; }

.hero-metric-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.75rem; }
.hero-metric-icon {
    width: 36px; height: 36px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.hero-metric-icon--teal { background: var(--brand-soft); color: var(--brand); }
.hero-metric-icon--green { background: var(--success-soft); color: var(--success); }
.hero-metric-icon--blue { background: var(--info-soft); color: var(--info); }
.hero-metric-icon--purple { background: rgba(167,139,250,0.12); color: #a78bfa; }
.hero-metric-icon--amber { background: var(--warning-soft); color: var(--warning); }
.hero-metric-icon--red { background: var(--danger-soft); color: var(--danger); }
.hero-metric-icon--orange { background: rgba(251,146,60,0.12); color: #fb923c; }

.hero-metric-label {
    font-size: var(--text-sm); color: var(--text-secondary);
    font-weight: var(--weight-medium); text-transform: uppercase; letter-spacing: 0.04em;
}
.hero-metric-value {
    font-size: var(--text-2xl); font-weight: var(--weight-bold);
    color: var(--text-primary); letter-spacing: -0.02em; line-height: 1.2;
}
.hero-metric-sub { font-size: var(--text-sm); color: var(--text-secondary); margin-top: var(--space-1); }

/* ── Stat Cards ── */
.stats-grid {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-3); margin-bottom: var(--space-4);
}
@media (max-width: 1100px) { .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .stats-grid { grid-template-columns: 1fr; } }

.stat-card {
    background: color-mix(in srgb, var(--bg-primary) 92%, transparent);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4); box-shadow: var(--shadow-sm);
}
.stat-label { color: var(--text-muted); font-weight: var(--weight-bold); font-size: var(--text-sm); }
.stat-value { margin-top: var(--space-2); font-weight: 900; font-size: var(--text-2xl); letter-spacing: -0.02em; color: var(--brand); }
.stat-change { font-size: var(--text-base); font-weight: var(--weight-semibold); margin-top: var(--space-1); }
.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--danger); }
.stat-trend { display: flex; align-items: center; gap: var(--space-1); font-size: var(--text-sm); margin-top: var(--space-1); }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }
.stat-trend.neutral { color: var(--text-muted); }

/* ── Efficiency Cards ── */
.efficiency-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: var(--space-6);
}
.efficiency-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-4) var(--space-5);
    text-align: center;
    transition: transform 0.2s;
}
.efficiency-card:hover { transform: translateY(-2px); }
.efficiency-card-value { font-size: 1.5rem; font-weight: var(--weight-bold); color: var(--brand); }
.efficiency-card-label { font-size: var(--text-sm); color: var(--text-secondary); margin-top: var(--space-1); }

/* ── Status Grid ── */
.section-status-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-4);
}
.section-status-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem; border-radius: var(--radius-sm);
    background: var(--bg-secondary); border: 1px solid var(--border);
}
.section-status-icon {
    width: 32px; height: 32px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: var(--text-md);
}
.section-status-label { font-size: var(--text-sm); color: var(--text-secondary); }
.section-status-value { font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--text-primary); }

/* ── Empty State ── */
.empty-state {
    border: 1px dashed var(--border);
    background: color-mix(in srgb, var(--bg-primary) 86%, transparent);
    border-radius: var(--radius-lg);
    padding: var(--space-12) var(--space-8);
    text-align: center;
}
.empty-icon, .empty-state-icon { font-size: 3.5rem; opacity: 0.6; }
.empty-title { margin: var(--space-2) 0 var(--space-2); font-size: var(--text-xl); font-weight: var(--weight-semibold); }
.empty-text { margin: 0 0 var(--space-3); color: var(--text-secondary); }

/* ── Loading ── */
.spinner {
    display: inline-block; width: 24px; height: 24px;
    border: 3px solid rgba(255,255,255,0.25);
    border-radius: 50%; border-top-color: currentColor;
    animation: spin 0.6s linear infinite;
}
.loading-overlay {
    position: fixed; inset: 0; display: none;
    align-items: center; justify-content: center;
    background: rgba(2,6,23,0.45);
    z-index: var(--z-toast);
}

/* ── Loading Skeleton ── */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}
.skeleton-text { height: 14px; margin-bottom: var(--space-2); }
.skeleton-title { height: 24px; width: 60%; margin-bottom: var(--space-3); }
.skeleton-card { height: 120px; border-radius: var(--radius); }
@keyframes skeleton-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Info Row ── */
.info-row {
    display: flex; justify-content: space-between; gap: 0.75rem;
    padding: var(--space-2) 0;
    border-bottom: 1px dashed var(--border);
    color: var(--text-secondary);
}
.info-row:last-child { border-bottom: none; }

/* ── Page header (simple) ── */
.page-header { margin: var(--space-1) 0 var(--space-5); }
.page-title { font-size: var(--text-3xl); font-weight: var(--weight-extrabold); letter-spacing: -0.02em; margin: 0; }
.page-subtitle { margin: 6px 0 0; color: var(--text-secondary); }

/* ── Responsive ── */
@media (max-width: 768px) {
    .page-hero { padding: var(--space-5); }
    .page-hero-inner { flex-direction: column; gap: 0.75rem; align-items: flex-start; }
    .page-hero-title { font-size: var(--text-xl); }
    .hero-metrics-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
    .hero-metric-value { font-size: var(--text-xl); }
    .section-status-grid { grid-template-columns: 1fr; }
    .efficiency-cards { grid-template-columns: repeat(2, 1fr); }
    .card-header { flex-direction: column; align-items: flex-start; gap: var(--space-2); }
    .stats-grid { grid-template-columns: 1fr; }
}
