/* ═══════════════════════════════════════════════════════════════════
   KPI CARDS — globaler Layer (seit 2026-04)
   ───────────────────────────────────────────────────────────────────
   Zentrale Styles für die Standard-KPI-Karten-Komponente.
   Gehört zu den Includes:
     - templates/includes/kpi_card.html
     - templates/includes/kpi_cards.html
     - templates/includes/kpi_help_modal.html
   Wird in templates/includes/base.html global geladen.
   ═══════════════════════════════════════════════════════════════════ */

/* Help-Button (oben rechts in der KPI-Karte)
   Sieht identisch aus wie der Card-Header-Help-Button (.cfg-help-btn),
   ist nur kleiner und nur bei Karten-Hover sichtbar. */
.crawl-kpi-card .kpi-help {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 2;
    width: 1.25rem;
    height: 1.25rem;
    font-size: 0.625rem;
    opacity: 0;
}
.crawl-kpi-card .kpi-help i { font-size: 0.625rem; }
.crawl-kpi-card:hover .kpi-help,
.crawl-kpi-card .kpi-help:focus-visible { opacity: 1; }

/* Help-Modal (optional via includes/kpi_help_modal.html) */
.op-help-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.op-help-modal.active { display: flex; }

.op-help-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}

.op-help-content {
    position: relative;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) + 4px);
    padding: 1.5rem;
    max-width: 440px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.op-help-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    border: none;
    background: hsl(var(--muted) / 0.5);
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.op-help-close:hover { background: hsl(var(--destructive) / 0.15); color: hsl(var(--destructive)); }

.op-help-htitle { font-size: 1rem; font-weight: 700; margin-bottom: 0.625rem; }

.op-help-text {
    font-size: 0.8125rem;
    line-height: 1.6;
    color: hsl(var(--muted-foreground));
}

.op-help-text code {
    font-size: 0.75rem;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    background: hsl(var(--muted) / 0.5);
    font-family: monospace;
}

.op-help-text b { color: hsl(var(--foreground)); font-weight: 600; }


/* KPI Row (4-Spalten-Grid, responsive) */
.op-kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

@media (max-width: 1200px) {
    .op-kpi-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .op-kpi-row { grid-template-columns: 1fr; }
}

/* KPI Card */
.crawl-kpi-card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    transition: box-shadow 0.15s;
    position: relative;
}

.crawl-kpi-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.crawl-kpi-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.crawl-kpi-icon--pages    { background: hsl(var(--primary) / 0.1); color: hsl(var(--primary)); }
.crawl-kpi-icon--index    { background: hsl(217 91% 60% / 0.1); color: hsl(217 91% 60%); }
.crawl-kpi-icon--speed    { background: hsl(280 60% 55% / 0.1); color: hsl(280 60% 55%); }
.crawl-kpi-icon--score    { background: hsl(50 80% 50% / 0.1); color: hsl(50 80% 50%); }
.crawl-kpi-icon--issues   { background: hsl(0 84% 60% / 0.1); color: hsl(0 84% 60%); }
.crawl-kpi-icon--clean    { background: hsl(142 71% 45% / 0.1); color: hsl(142 71% 45%); }
.crawl-kpi-icon--words    { background: hsl(217 91% 60% / 0.1); color: hsl(217 91% 60%); }
.crawl-kpi-icon--schema   { background: hsl(var(--primary) / 0.1); color: hsl(var(--primary)); }
.crawl-kpi-icon--images   { background: hsl(280 60% 55% / 0.1); color: hsl(280 60% 55%); }
.crawl-kpi-icon--alt      { background: hsl(38 92% 50% / 0.1); color: hsl(38 92% 50%); }
.crawl-kpi-icon--lazy     { background: hsl(217 91% 60% / 0.1); color: hsl(217 91% 60%); }
.crawl-kpi-icon--links    { background: hsl(142 71% 45% / 0.1); color: hsl(142 71% 45%); }
.crawl-kpi-icon--ext      { background: hsl(38 92% 50% / 0.1); color: hsl(38 92% 50%); }
.crawl-kpi-icon--orphan   { background: hsl(0 84% 60% / 0.1); color: hsl(0 84% 60%); }
.crawl-kpi-icon--nofollow { background: hsl(215 20% 55% / 0.1); color: hsl(215 20% 55%); }
.crawl-kpi-icon--ok       { background: hsl(142 71% 45% / 0.1); color: hsl(142 71% 45%); }
.crawl-kpi-icon--redir    { background: hsl(217 91% 60% / 0.1); color: hsl(217 91% 60%); }
.crawl-kpi-icon--warn     { background: hsl(var(--warning) / 0.1); color: hsl(var(--warning)); }
.crawl-kpi-icon--error    { background: hsl(var(--destructive) / 0.1); color: hsl(var(--destructive)); }
.crawl-kpi-icon--time     { background: hsl(var(--muted-foreground) / 0.12); color: hsl(var(--muted-foreground)); }

.crawl-kpi-info { min-width: 0; flex: 1; }

.crawl-kpi-value {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
    color: hsl(var(--foreground));
    font-variant-numeric: tabular-nums;
}

.crawl-kpi-label {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    margin-top: 0.125rem;
}

.crawl-kpi-sub {
    font-size: 0.6875rem;
    color: hsl(var(--muted-foreground));
    margin-top: 0.125rem;
}

/* KPI Trend Badge */
.kpi-trend {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.625rem;
    font-weight: 600;
    margin-top: 0.25rem;
    padding: 0.125rem 0.375rem;
    border-radius: 9999px;
    font-variant-numeric: tabular-nums;
}

.kpi-trend i { font-size: 0.5rem; }
.kpi-trend--up { background: hsl(142 71% 45% / 0.1); color: hsl(142 71% 45%); }
.kpi-trend--down { background: hsl(0 84% 60% / 0.1); color: hsl(0 84% 60%); }
.kpi-trend--flat { background: hsl(var(--muted) / 0.5); color: hsl(var(--muted-foreground)); }

/* KPI Grade */
.kpi-grade {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.375rem;
    height: 1.375rem;
    border-radius: 0.25rem;
    font-size: 0.6875rem;
    font-weight: 700;
    margin-left: 0.375rem;
    vertical-align: middle;
}

.kpi-grade--A { background: hsl(142 71% 45% / 0.15); color: hsl(142 71% 45%); }
.kpi-grade--B { background: hsl(142 76% 50% / 0.15); color: hsl(142 76% 50%); }
.kpi-grade--C { background: hsl(38 92% 50% / 0.15); color: hsl(38 92% 50%); }
.kpi-grade--D { background: hsl(0 84% 60% / 0.15); color: hsl(0 84% 60%); }
.kpi-grade--F { background: hsl(0 84% 60% / 0.2); color: hsl(0 84% 60%); }

/* Sparkline Canvas */
.kpi-sparkline {
    display: block;
    flex-shrink: 0;
    opacity: 0.6;
}
