/* =========================================================================
   Mur de supervision (page d'accueil)
   Tout est namespacé sous .wall ; les couleurs passent par des variables
   pour les thèmes sombre (par défaut) et clair.
   ========================================================================= */

.wall {
    --bg: #0a101d;
    --bg-glow-1: rgba(56, 189, 248, .09);
    --bg-glow-2: rgba(99, 102, 241, .08);
    --surface: #111a2c;
    --surface-2: #17223a;
    --border: rgba(148, 163, 184, .14);
    --text: #e7edf7;
    --text-muted: #8f9cb4;
    --text-faint: #64728b;
    --logo-bg: #ffffff;
    --ok: #22c55e;
    --ok-soft: rgba(34, 197, 94, .13);
    --down: #fb4f6d;
    --down-strong: #e11d48;
    --down-soft: rgba(244, 63, 94, .16);
    --down-border: rgba(244, 63, 94, .6);
    --warn: #f5a524;
    --warn-soft: rgba(245, 158, 11, .14);
    --warn-border: rgba(245, 158, 11, .45);
    --unstable: #fb923c;
    --pending: #94a3b8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 28px rgba(0, 0, 0, .22);
    --radius: 14px;

    min-height: 100vh;
    padding: 20px 24px 96px;
    background:
        radial-gradient(1100px 600px at 5% -10%, var(--bg-glow-1), transparent 60%),
        radial-gradient(900px 520px at 100% 0%, var(--bg-glow-2), transparent 60%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}

.wall[data-theme="light"] {
    --bg: #edf1f7;
    --bg-glow-1: rgba(56, 189, 248, .14);
    --bg-glow-2: rgba(99, 102, 241, .09);
    --surface: #ffffff;
    --surface-2: #f3f6fa;
    --border: rgba(15, 23, 42, .09);
    --text: #0f172a;
    --text-muted: #59657a;
    --text-faint: #8e99ab;
    --ok: #16a34a;
    --ok-soft: rgba(22, 163, 74, .1);
    --down: #e11d48;
    --down-strong: #e11d48;
    --down-soft: rgba(225, 29, 72, .08);
    --down-border: rgba(225, 29, 72, .55);
    --warn: #c96a04;
    --warn-soft: rgba(217, 119, 6, .1);
    --warn-border: rgba(217, 119, 6, .4);
    --unstable: #ea580c;
    --pending: #7c8799;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 22px rgba(15, 23, 42, .06);
}

.wall h2 {
    margin: 0;
}

/* ---------- En-tête ---------- */

.wall-header {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) auto minmax(240px, 1fr);
    align-items: center;
    gap: 24px;
    padding: 16px 22px;
    margin-bottom: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: linear-gradient(135deg, #38bdf8, #6366f1);
    color: #fff;
    font-size: 21px;
    box-shadow: 0 8px 20px rgba(99, 102, 241, .35);
}

.brand-name {
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -.01em;
    line-height: 1.2;
}

    .brand-name span {
        color: var(--text-muted);
        font-weight: 500;
    }

.brand-sub {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: .1em;
}

.overview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.global-status {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    border-radius: 999px;
    font-size: 20px;
    font-weight: 650;
    white-space: nowrap;
}

    .global-status.is-up {
        background: var(--ok-soft);
        color: var(--ok);
    }

    .global-status.is-warning {
        background: var(--warn-soft);
        color: var(--warn);
    }

    .global-status.is-down {
        background: var(--down-strong);
        color: #fff;
        animation: wall-pulse-ring 1.6s ease-in-out infinite;
    }

.global-dot {
    position: relative;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: currentColor;
}

    .global-dot::after {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: 50%;
        background: currentColor;
        animation: wall-ping 2s cubic-bezier(0, 0, .2, 1) infinite;
    }

.counters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.counter {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 3px 11px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
}

    .counter::before {
        content: "";
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--pending);
    }

    .counter b {
        color: var(--text);
        font-weight: 650;
    }

    .counter.is-zero {
        opacity: .55;
    }

    .counter.is-up::before { background: var(--ok); }
    .counter.is-down::before { background: var(--down); }
    .counter.is-warning::before { background: var(--warn); }

.clock {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
}

.clock-time {
    font-size: 36px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -.02em;
}

    .clock-time small {
        font-size: 18px;
        font-weight: 600;
        color: var(--text-faint);
    }

.clock-date {
    margin-top: 5px;
    font-size: 13px;
    color: var(--text-muted);
}

    .clock-date::first-letter {
        text-transform: uppercase;
    }

.refresh {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-faint);
}

    .refresh.is-lost {
        padding: 3px 11px;
        border-radius: 999px;
        background: var(--down-strong);
        color: #fff;
        font-weight: 600;
    }

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ok);
    animation: wall-blink 2s ease-in-out infinite;
}

/* ---------- Titres de section ---------- */

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px !important;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--text-muted);
}

    .section-title.is-down { color: var(--down); }
    .section-title.is-warning { color: var(--warn); }

.section-count {
    padding: 1px 9px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 12px;
    letter-spacing: 0;
}

/* ---------- Incidents ---------- */

.incidents,
.warnings {
    margin-bottom: 28px;
}

.incident-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(440px, 1fr));
    gap: 14px;
}

.incident {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 18px 22px;
    border-radius: var(--radius);
    background: linear-gradient(120deg, #be123c 0%, #e11d48 55%, #f43f5e 100%);
    color: #fff;
    animation: wall-pulse-card 1.6s ease-in-out infinite;
}

.incident-body {
    flex: 1;
    min-width: 0;
}

.incident-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 24px;
    font-weight: 750;
    line-height: 1.15;
}

.incident-host {
    font-size: 13px;
    opacity: .8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.incident-reason {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    margin-top: 9px;
    padding: 4px 11px;
    border-radius: 8px;
    background: rgba(0, 0, 0, .2);
    font-size: 14px;
    font-weight: 600;
}

.incident-since {
    text-align: right;
    white-space: nowrap;
}

    .incident-since span {
        display: block;
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .08em;
        opacity: .8;
    }

    .incident-since b {
        font-size: 28px;
        font-weight: 750;
    }

/* ---------- Points d'attention ---------- */

.warning-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.warning {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 9px 15px;
    border-radius: 12px;
    background: var(--warn-soft);
    border: 1px solid var(--warn-border);
    font-size: 14px;
}

    .warning i {
        color: var(--warn);
    }

    .warning b {
        font-weight: 650;
    }

    .warning span {
        color: var(--text-muted);
    }

/* ---------- Groupes de tuiles ---------- */

.group {
    margin-bottom: 28px;
}

.group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

    .group-header > i {
        color: var(--text-faint);
        font-size: 15px;
    }

    .group-header h2 {
        font-size: 16px;
        font-weight: 700;
    }

.group-count {
    padding: 1px 9px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

.group-health {
    margin-left: auto;
    font-size: 13px;
    font-weight: 600;
}

    .group-health.is-up { color: var(--ok); }
    .group-health.is-warning { color: var(--warn); }
    .group-health.is-down { color: var(--down); }

.tiles {
    display: grid;
    grid-template-columns: repeat(var(--cols, 12), minmax(0, 1fr));
    grid-auto-flow: dense;
    gap: 12px;
}

/* ---------- Tuile ---------- */

.tile {
    --state-color: var(--ok);
    position: relative;
    display: flex;
    min-height: 136px;
    padding: 16px 10px 12px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}

    .tile::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 3px;
        background: var(--state-color);
        opacity: .85;
    }

    .tile.is-down {
        --state-color: var(--down);
        background: linear-gradient(var(--down-soft), var(--down-soft)), var(--surface);
        border-color: var(--down-border);
        animation: wall-pulse-tile 1.6s ease-in-out infinite;
    }

    .tile.is-warning,
    .tile.is-stale {
        --state-color: var(--warn);
        border-color: var(--warn-border);
    }

    .tile.is-unstable {
        --state-color: var(--unstable);
        border-color: var(--warn-border);
    }

    .tile.is-pending {
        --state-color: var(--pending);
    }

.tile-dot {
    position: absolute;
    top: 11px;
    right: 11px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--state-color);
    box-shadow: 0 0 10px var(--state-color);
}

.tile-identity {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 9px;
    text-align: center;
}

.logo {
    width: 58px;
    height: 58px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    padding: 8px;
    border-radius: 14px;
    background: var(--logo-bg);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .08);
}

    .logo img {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
    }

    .logo.no-icon {
        background: linear-gradient(135deg, #6366f1, #38bdf8);
        box-shadow: none;
    }

    .logo.logo-lg {
        width: 76px;
        height: 76px;
        border-radius: 18px;
        padding: 10px;
    }

.initials {
    color: #fff;
    font-size: 19px;
    font-weight: 750;
    letter-spacing: .02em;
}

.logo-lg .initials {
    font-size: 24px;
}

.incident .logo.no-icon {
    background: rgba(255, 255, 255, .2);
}

.tile-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.tile-state {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--state-color);
    white-space: nowrap;
}

/* Tuile avec données remontées par un agent */

.tile.has-data {
    grid-column: span 2;
    align-items: stretch;
    gap: 14px;
    padding: 16px 16px 12px;
}

    .tile.has-data .tile-identity {
        flex: 0 0 36%;
    }

    .tile.has-data .tile-dot {
        left: 11px;
        right: auto;
    }

.tile-data {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    padding-left: 14px;
    border-left: 1px solid var(--border);
}

.tile-metrics {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--text);
    text-align: left;
}

    .tile-metrics .metric {
        overflow-wrap: anywhere;
    }

    .tile-metrics b,
    .tile-metrics strong {
        font-weight: 700;
    }

    /* Les gabarits des composants utilisent souvent des couleurs nommées choisies pour un fond blanc :
       on les ramène sur la palette du thème pour qu'elles restent lisibles. */
    .tile-metrics [style*="color:green"], .tile-metrics [style*="color: green"] { color: var(--ok) !important; }
    .tile-metrics [style*="color:red"], .tile-metrics [style*="color: red"] { color: var(--down) !important; }
    .tile-metrics [style*="color:orange"], .tile-metrics [style*="color: orange"] { color: var(--warn) !important; }
    .tile-metrics [style*="color:black"], .tile-metrics [style*="color: black"],
    .tile-metrics [style*="color:#000"], .tile-metrics [style*="color: #000"] { color: var(--text) !important; }

    .tile-metrics .text-muted { color: var(--text-muted) !important; }

    .tile-metrics .progress {
        height: 6px;
        margin: 3px 0 2px;
        background: var(--surface-2);
        border-radius: 999px;
    }

    .tile-metrics hr {
        margin: 4px 0;
        border-color: var(--border);
    }

    .tile-metrics p {
        margin: 0;
    }

.tile-updated {
    margin-top: auto;
    font-size: 11px;
    color: var(--text-faint);
    text-align: right;
    white-space: nowrap;
}

    .tile-updated.is-stale {
        color: var(--warn);
        font-size: 12px;
        font-weight: 700;
    }

/* ---------- États vides ---------- */

.wall-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 40vh;
    font-size: 16px;
    color: var(--text-muted);
}

/* ---------- Barre d'outils flottante ---------- */

.toolbar {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 6px;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    opacity: .4;
    transition: opacity .2s ease;
}

    .toolbar:hover,
    .toolbar:focus-within {
        opacity: 1;
    }

    /* Repliée, seule la poignée est visible pour ne pas masquer les tuiles du bas. */
    .toolbar:not(:hover):not(:focus-within) > :not(.toolbar-handle) {
        display: none;
    }

    .toolbar:hover > .toolbar-handle,
    .toolbar:focus-within > .toolbar-handle {
        display: none;
    }

.toolbar-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    color: var(--text-muted);
    font-size: 14px;
}

    .toolbar a,
    .toolbar button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        height: 34px;
        min-width: 34px;
        padding: 0 10px;
        border: 0;
        border-radius: 10px;
        background: transparent;
        color: var(--text-muted);
        font-size: 13px;
        font-weight: 600;
        text-decoration: none;
        cursor: pointer;
    }

        .toolbar a:hover,
        .toolbar button:hover:not(:disabled) {
            background: var(--surface-2);
            color: var(--text);
        }

        .toolbar button:disabled {
            opacity: .35;
            cursor: default;
        }

.toolbar-value {
    min-width: 22px;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    color: var(--text);
}

.toolbar-sep {
    width: 1px;
    height: 20px;
    margin: 0 5px;
    background: var(--border);
}

/* ---------- Animations ---------- */

@keyframes wall-ping {
    75%, 100% {
        transform: scale(2.4);
        opacity: 0;
    }
}

@keyframes wall-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: .3; }
}

@keyframes wall-pulse-ring {
    0%, 100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, .55); }
    50% { box-shadow: 0 0 0 10px rgba(244, 63, 94, 0); }
}

@keyframes wall-pulse-card {
    0%, 100% { box-shadow: 0 10px 30px rgba(225, 29, 72, .35), 0 0 0 0 rgba(244, 63, 94, .6); }
    50% { box-shadow: 0 10px 30px rgba(225, 29, 72, .35), 0 0 0 10px rgba(244, 63, 94, 0); }
}

@keyframes wall-pulse-tile {
    0%, 100% { box-shadow: var(--shadow), 0 0 0 0 rgba(244, 63, 94, .5); }
    50% { box-shadow: var(--shadow), 0 0 0 6px rgba(244, 63, 94, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .wall *,
    .wall *::before,
    .wall *::after {
        animation: none !important;
    }
}

/* ---------- Petits écrans ---------- */

@media (max-width: 1100px) {
    .wall {
        padding: 12px 12px 88px;
    }

    .wall-header {
        grid-template-columns: 1fr auto;
    }

    .overview {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .incident-grid {
        grid-template-columns: 1fr;
    }

    .tiles {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
}

@media (max-width: 560px) {
    .wall-header {
        grid-template-columns: 1fr;
    }

    .clock {
        align-items: flex-start;
        text-align: left;
    }

    .global-status {
        font-size: 16px;
        white-space: normal;
    }

    .incident {
        flex-wrap: wrap;
    }

    .incident-since {
        width: 100%;
        text-align: left;
    }

    .tile.has-data {
        grid-column: 1 / -1;
    }

    .toolbar a span {
        display: none;
    }
}
