/* Seite „Systemstatus“ als Dashboard (modules/core/system-status.js): Gesamtzustand, Übersichtskacheln, Prüf-Widgets.
   Farben über MDB-Variablen (Erfolg/Warnung/Fehler) und die aqc-Variablen der Desktop-Oberfläche; kein Schatten wie die übrigen Karten. */

.aqc-sd {
    --aqc-sd-ok: var(--mdb-success-rgb, 20, 164, 77);
    --aqc-sd-warning: var(--mdb-warning-rgb, 228, 161, 27);
    --aqc-sd-error: var(--mdb-danger-rgb, 220, 76, 100);
    --aqc-sd-neutral: var(--mdb-secondary-rgb, 159, 166, 178);
    --aqc-sd-brand: var(--mdb-primary-rgb, 0, 61, 253);
    --aqc-sd-radius: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Statusfarbe je Zustand als RGB-Tripel; alle Bausteine leiten Fläche/Rand/Schrift daraus ab */
.aqc-sd .is-ok { --aqc-sd-tone: var(--aqc-sd-ok); }
.aqc-sd .is-warning { --aqc-sd-tone: var(--aqc-sd-warning); }
.aqc-sd .is-error { --aqc-sd-tone: var(--aqc-sd-error); }
.aqc-sd .is-pending { --aqc-sd-tone: var(--aqc-sd-neutral); }
.aqc-sd .is-loading { --aqc-sd-tone: var(--aqc-sd-brand); }
.aqc-sd .aqc-sd-overview.is-ok { --aqc-sd-tone: var(--aqc-sd-ok); }
.aqc-sd .aqc-sd-overview.is-warning { --aqc-sd-tone: var(--aqc-sd-warning); }
.aqc-sd .aqc-sd-overview.is-error { --aqc-sd-tone: var(--aqc-sd-error); }
.aqc-sd .aqc-sd-overview.is-loading { --aqc-sd-tone: var(--aqc-sd-brand); }

/* ---------- Gesamtzustand */
.aqc-sd-overview {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border: 1px solid rgba(var(--aqc-sd-tone), 0.35);
    border-left: 4px solid rgb(var(--aqc-sd-tone));
    border-radius: var(--aqc-sd-radius);
    background: linear-gradient(90deg, rgba(var(--aqc-sd-tone), 0.10), rgba(var(--aqc-sd-tone), 0.02) 60%), #fff;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.aqc-sd-overview-icon {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    font-size: 1.5rem;
    color: #fff;
    background-color: rgb(var(--aqc-sd-tone));
    box-shadow: 0 0 0 6px rgba(var(--aqc-sd-tone), 0.15);
}

.aqc-sd-overview-text {
    flex: 1 1 auto;
    min-width: 0;
}

.aqc-sd-overview-title {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--aqc-text, #1f1f1f);
}

.aqc-sd-overview-sub {
    font-size: 0.8125rem;
    color: var(--aqc-text-label, #6b7280);
    font-variant-numeric: tabular-nums;
}

.aqc-sd-overview-counts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.aqc-sd-count {
    display: inline-flex;
    align-items: baseline;
    gap: 0.375rem;
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-size: 0.8125rem;
    color: var(--aqc-text-label, #6b7280);
    background-color: rgba(var(--aqc-sd-tone), 0.10);
}

.aqc-sd-count strong {
    font-size: 1rem;
    color: rgb(var(--aqc-sd-tone));
    font-variant-numeric: tabular-nums;
}

/* ---------- Übersichtskacheln: eine je Prüfung, Klick springt zum Widget */
.aqc-sd-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
    gap: 0.75rem;
}

.aqc-sd-tile {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    padding: 0.75rem 1rem;
    text-align: left;
    border: 1px solid var(--aqc-border-subtle, #e0e3e8);
    border-radius: var(--aqc-sd-radius);
    background-color: #fff;
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.aqc-sd-tile:hover,
.aqc-sd-tile:focus-visible {
    border-color: rgba(var(--aqc-sd-tone), 0.6);
    box-shadow: 0 4px 14px -8px rgba(var(--aqc-sd-tone), 0.6);
    transform: translateY(-1px);
    outline: none;
}

.aqc-sd-tile-icon {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.5rem;
    color: rgb(var(--aqc-sd-tone));
    background-color: rgba(var(--aqc-sd-tone), 0.12);
}

.aqc-sd-tile-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.aqc-sd-tile-title {
    font-size: var(--aqc-font-size-label, 0.6875rem);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--aqc-text-label, #6b7280);
}

.aqc-sd-tile-summary {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--aqc-text, #1f1f1f);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aqc-sd-tile-dot {
    position: absolute;
    top: 0.625rem;
    right: 0.625rem;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background-color: rgb(var(--aqc-sd-tone));
}

.aqc-sd-tile.is-loading .aqc-sd-tile-dot,
.aqc-sd-tile.is-error .aqc-sd-tile-dot {
    animation: aqc-sd-pulse 1.4s ease-in-out infinite;
}

/* ---------- Widget */
/* Widgets nicht auf die Höhe des Nachbarn strecken: kurze Prüfungen hätten sonst große Leerflächen */
.aqc-sd-grid {
    align-items: flex-start;
}

body .card.aqc-sd-widget {
    display: flex;
    flex-direction: column;
    border-radius: var(--aqc-sd-radius);
    overflow: hidden;
    scroll-margin-top: calc(var(--aqc-navbar-height, 4.5rem) + 1rem);
}

/* Farbleiste oben zeigt den Zustand auch ohne Lesen der Pille */
.aqc-sd-widget::before {
    content: '';
    height: 3px;
    background-color: rgb(var(--aqc-sd-neutral));
    transition: background-color 0.3s ease;
}

.aqc-sd-widget[data-state="ok"]::before { background-color: rgb(var(--aqc-sd-ok)); }
.aqc-sd-widget[data-state="warning"]::before { background-color: rgb(var(--aqc-sd-warning)); }
.aqc-sd-widget[data-state="error"]::before { background-color: rgb(var(--aqc-sd-error)); }
.aqc-sd-widget.is-loading::before { background-color: rgba(var(--aqc-sd-brand), 0.35); }

.aqc-sd-widget-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--aqc-border-subtle, #e0e3e8);
}

.aqc-sd-widget-icon {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    color: rgb(var(--aqc-sd-brand));
    background-color: rgba(var(--aqc-sd-brand), 0.08);
}

.aqc-sd-widget-titles {
    flex: 1 1 auto;
    min-width: 0;
}

.aqc-sd-widget-title {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.3;
}

.aqc-sd-widget-description {
    font-size: 0.75rem;
    color: var(--aqc-text-subtle, #8a919c);
}

body .aqc-sd-widget-refresh {
    padding: 0.25rem 0.5rem;
    color: var(--aqc-text-label, #6b7280);
}

body .aqc-sd-widget-refresh:hover {
    color: rgb(var(--aqc-sd-brand));
}

.aqc-sd-widget.is-loading .aqc-sd-widget-refresh {
    pointer-events: none;
    opacity: 0.4;
}

.aqc-sd-widget-body {
    flex: 1 1 auto;
    padding: 0.875rem 1rem;
}

.aqc-sd-widget-footer {
    padding: 0.375rem 1rem;
    font-size: 0.75rem;
    color: var(--aqc-text-subtle, #8a919c);
    background-color: var(--aqc-surface-muted, #f5f6f8);
    border-top: 1px solid var(--aqc-border-subtle, #e0e3e8);
    font-variant-numeric: tabular-nums;
}

.aqc-sd-widget-footer:empty {
    display: none;
}

/* ---------- Status-Pille */
.aqc-sd-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.125rem 0.625rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    color: rgb(var(--aqc-sd-tone));
    background-color: rgba(var(--aqc-sd-tone), 0.12);
}

/* Gelb ist auf hellem Grund schwer lesbar: Schrift dunkler */
.aqc-sd-pill.is-warning,
.aqc-sd-count.is-warning strong {
    color: #8a5a00;
}

.aqc-sd-pill.is-pending {
    color: var(--aqc-text-label, #6b7280);
}

/* ---------- Kennzahl-Kacheln */
.aqc-sd-metrics {
    display: grid;
    grid-template-columns: repeat(var(--aqc-sd-columns, 3), minmax(0, 1fr));
    gap: 0.625rem;
}

.aqc-sd-metric {
    min-width: 0;
    padding: 0.625rem 0.75rem;
    border-radius: 0.375rem;
    background-color: var(--aqc-surface-muted, #f5f6f8);
    border-left: 3px solid transparent;
}

.aqc-sd-metric.is-ok { border-left-color: rgb(var(--aqc-sd-ok)); }
.aqc-sd-metric.is-warning { border-left-color: rgb(var(--aqc-sd-warning)); }
.aqc-sd-metric.is-error { border-left-color: rgb(var(--aqc-sd-error)); }

.aqc-sd-metric-label {
    font-size: var(--aqc-font-size-label, 0.6875rem);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--aqc-text-label, #6b7280);
}

.aqc-sd-metric-value {
    margin-top: 0.125rem;
    font-size: 1.0625rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--aqc-text, #1f1f1f);
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.aqc-sd-metric-sub {
    margin-top: 0.125rem;
    font-size: 0.75rem;
    color: var(--aqc-text-subtle, #8a919c);
    font-variant-numeric: tabular-nums;
}

.aqc-sd-section-label {
    margin: 1rem 0 0.5rem;
    font-size: var(--aqc-font-size-label, 0.6875rem);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--aqc-text-label, #6b7280);
}

/* ---------- Ablaufliste (z. B. Läufe der Datensicherung) mit Zeitleiste */
.aqc-sd-runs {
    position: relative;
    margin: 0;
    padding: 0;
    list-style: none;
}

.aqc-sd-run {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.aqc-sd-run + .aqc-sd-run {
    border-top: 1px dashed var(--aqc-border-subtle, #e0e3e8);
}

.aqc-sd-run-dot {
    flex: 0 0 auto;
    width: 0.625rem;
    height: 0.625rem;
    margin-top: 0.375rem;
    border-radius: 50%;
    background-color: rgb(var(--aqc-sd-tone));
    box-shadow: 0 0 0 3px rgba(var(--aqc-sd-tone), 0.18);
}

.aqc-sd-run-main {
    flex: 1 1 auto;
    min-width: 0;
}

.aqc-sd-run-label {
    font-weight: 600;
    font-size: 0.875rem;
}

.aqc-sd-run-time {
    display: flex;
    flex-wrap: wrap;
    gap: 0 0.5rem;
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}

.aqc-sd-run-relative,
.aqc-sd-run-extra {
    font-size: 0.75rem;
    color: var(--aqc-text-subtle, #8a919c);
}

.aqc-sd-run-failure {
    margin-top: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    color: rgb(var(--aqc-sd-error));
    background-color: rgba(var(--aqc-sd-error), 0.08);
}

/* ---------- Listen in Widgets (z. B. Request-Log): Überschrift links, Schalter rechts */
.aqc-sd-list-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 1rem 0 0.25rem;
}

.aqc-sd-list-header .aqc-sd-section-label {
    margin: 0;
}

.aqc-sd-log-table {
    margin-bottom: 0;
}

.aqc-sd-log-time,
.aqc-sd-log-number {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.aqc-sd-log-request {
    min-width: 0;
}

.aqc-sd-log-method {
    display: inline-block;
    min-width: 3.25rem;
    margin-right: 0.375rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--aqc-text-label, #6b7280);
}

.aqc-sd-log-path,
.aqc-sd-log-code,
.aqc-sd-log-ip {
    font-family: var(--aq-font-mono, ui-monospace, monospace);
    font-size: 0.8125rem;
    overflow-wrap: anywhere;
}

.aqc-sd-log-path {
    color: var(--aqc-text, #1f1f1f);
}

.aqc-sd-log-engine {
    font-size: 0.75rem;
    color: var(--aqc-text-subtle, #8a919c);
}

.aqc-sd-log-message {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 0.5rem;
}

.aqc-sd-log-code,
.aqc-sd-log-ip {
    color: var(--aqc-text, #1f1f1f);
    white-space: nowrap;
}

/* ---------- Laden, leer, Fehler */
.aqc-sd-skeleton {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.aqc-sd-skeleton span {
    display: block;
    height: 0.875rem;
    border-radius: 0.25rem;
    background: linear-gradient(90deg, #eceef2 25%, #f6f7f9 50%, #eceef2 75%);
    background-size: 200% 100%;
    animation: aqc-sd-shimmer 1.3s linear infinite;
}

.aqc-sd-empty {
    margin: 0;
    font-size: 0.875rem;
    color: var(--aqc-text-label, #6b7280);
}

.aqc-sd-error {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: rgb(var(--aqc-sd-error));
    background-color: rgba(var(--aqc-sd-error), 0.08);
}

.aqc-sd-error i {
    margin-top: 0.1875rem;
}

@keyframes aqc-sd-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

@keyframes aqc-sd-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

/* ---------- Schmale Bildschirme */
@media (max-width: 575.98px) {
    .aqc-sd-overview {
        flex-wrap: wrap;
    }

    .aqc-sd-overview-counts {
        width: 100%;
    }

    .aqc-sd-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    .aqc-sd-overview,
    .aqc-sd-tile,
    .aqc-sd-widget::before {
        transition: none;
    }

    .aqc-sd-tile:hover,
    .aqc-sd-tile:focus-visible {
        transform: none;
    }

    .aqc-sd-skeleton span,
    .aqc-sd-tile-dot {
        animation: none !important;
    }
}

/* ---------- Kunden-Cockpit (modules/customers/cockpit.js): Widgets im Stil der Systemstatus-Seite, Fußzeile mit Sprüngen in die Listen */
.aqc-cockpit .aqc-cockpit-links { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; font-size: 0.8125rem; }
.aqc-cockpit .aqc-cockpit-links:empty { display: none; }
.aqc-cockpit .aqc-cockpit-ellipsis { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
