/* SPDX-License-Identifier: GPL-3.0-or-later */
:root {
  --bg: #f9f9f7; --surface: #fcfcfb; --text: #0b0b0b; --text2: #52514e; --muted: #898781; --grid: #e1e0d9; --axis: #c3c2b7; --hover: #f4f4f2;
  --s1: #2a78d6; --s2: #eb6834; --neutral: #898781; --accent: #2a78d6; --on-accent: #fff;
  --warn-text: #a56f00; --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b; --good-text: #006300; --crit-text: #a32020;
  --shadow: 0 1px 2px rgba(11, 11, 11, .06); color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0d0d; --surface: #1a1a19; --text: #f0efec; --text2: #c3c2b7; --grid: #2c2c2a; --axis: #383835; --hover: #232321;
    --s1: #3987e5; --s2: #d95926; --accent: #3987e5; --good-text: #0ca30c; --crit-text: #e66767; --warn-text: #fab219; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0d0d; --surface: #1a1a19; --text: #f0efec; --text2: #c3c2b7; --grid: #2c2c2a; --axis: #383835; --hover: #232321;
  --s1: #3987e5; --s2: #d95926; --accent: #3987e5; --good-text: #0ca30c; --crit-text: #e66767; --warn-text: #fab219; --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
#app { padding: 12px 14px 24px; max-width: 1800px; margin: 0 auto; }

/* barre d'outils */
.lw-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.lw-brand { display: flex; align-items: center; gap: 8px; }
.lw-brand h1 { margin: 0; font-size: 18px; font-weight: 650; }
.lw-logo { color: var(--accent); font-size: 18px; }
.lw-spacer { flex: 1; }
.lw-status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border: 1px solid var(--axis); border-radius: 999px; background: var(--surface); font-size: 12px; color: var(--text2); }
.lw-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.lw-status[data-state="live"] .lw-dot { background: var(--good); }
.lw-status[data-state="error"] .lw-dot { background: var(--critical); border-radius: 2px; }
.lw-status[data-state="paused"] .lw-dot { background: var(--warning); border-radius: 1px; }
.lw-btn { border: 1px solid var(--axis); background: var(--surface); border-radius: 6px; padding: 5px 12px; cursor: pointer; }
.lw-btn:hover { background: var(--hover); }
.lw-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.lw-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.lw-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.lw-danger { color: var(--crit-text); }
.lw-banner { padding: 10px 14px; border-radius: 6px; margin-bottom: 10px; border: 1px solid var(--axis); background: var(--surface); }
.lw-banner-warn { border-color: var(--warning); }

/* widgets */
.grid-stack-item-content { background: var(--surface); border: 1px solid var(--grid); border-radius: 10px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden !important; inset: 3px !important; }
.lw-head { display: flex; align-items: center; gap: 6px; padding: 8px 12px 0; min-height: 30px; color: var(--text2); font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.lw-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lw-stale { color: var(--text2); font-weight: 500; }
.lw-wbtn { display: none; border: 0; background: transparent; cursor: pointer; padding: 2px 6px; border-radius: 4px; color: var(--text2); }
.lw-wbtn:hover { background: var(--hover); }
.is-editing .lw-wbtn { display: inline-block; }
.is-editing .lw-head { cursor: move; }
.is-editing .grid-stack-item-content { border-style: dashed; border-color: var(--axis); }
.lw-body { position: relative; flex: 1; min-height: 0; padding: 4px 12px 10px; overflow: auto; container-type: size; }
.lw-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 12px; color: var(--text2); background: var(--surface); z-index: 2; }
.lw-overlay-err { flex-direction: column; gap: 4px; }
.lw-overlay .lw-gl { color: var(--crit-text); }

.lw-kpi { height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 2px; border-left: 4px solid transparent; padding-left: 10px; margin-left: -6px; }
.lw-kpi[data-state="ok"] { border-left-color: var(--good); }
.lw-kpi[data-state="warn"] { border-left-color: var(--warning); }
.lw-kpi[data-state="crit"] { border-left-color: var(--critical); }
.lw-kpi-value { font-size: clamp(22px, min(38cqh, 24cqw), 120px); font-weight: 650; line-height: 1.05; font-variant-numeric: tabular-nums; }
.lw-kpi-subs { color: var(--text2); font-size: clamp(11px, min(10cqh, 7cqw), 16px); }
.lw-badge { font-size: 12px; font-weight: 600; margin-top: 2px; }
.lw-kpi[data-state="ok"] .lw-gl { color: var(--good-text); }
.lw-kpi[data-state="warn"] .lw-gl { color: var(--warn-text); }
.lw-kpi[data-state="crit"] .lw-gl { color: var(--crit-text); }
@container (max-height: 90px) { .lw-kpi-subs, .lw-badge { display: none; } }

.lw-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.lw-table th { text-align: left; font-weight: 600; color: var(--text2); border-bottom: 1px solid var(--axis); padding: 4px 8px; white-space: nowrap; position: sticky; top: 0; background: var(--surface); }
.lw-table td { padding: 4px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.lw-table tbody tr:hover { background: var(--hover); }
.lw-num { text-align: right !important; font-variant-numeric: tabular-nums; }
.lw-gl { display: inline-block; min-width: 1.1em; text-align: center; }
.lw-st-ready .lw-gl, .lw-ok .lw-gl { color: var(--good-text); }
.lw-st-paused .lw-gl { color: var(--warn-text); }
.lw-st-offline { color: var(--text2); }
.lw-bad .lw-gl { color: var(--crit-text); }
.lw-call-ringing .lw-gl { color: var(--warn-text); }
.lw-call-talking .lw-gl { color: var(--good-text); }
.lw-empty { height: 100%; min-height: 40px; display: flex; align-items: center; justify-content: center; color: var(--text2); text-align: center; }
.lw-more { color: var(--text2); font-size: 12px; padding: 6px 8px; }
.lw-chart { position: relative; height: 100%; min-height: 120px; }
.lw-segbar { display: flex; height: 18px; border-radius: 4px; overflow: hidden; gap: 2px; margin-top: 6px; }
.lw-segbar > span { display: block; min-width: 2px; }
.lw-seg-empty { background: var(--grid); }
.lw-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 10px; font-size: 13px; color: var(--text2); }
.lw-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.lw-text { height: 100%; display: flex; align-items: center; white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 600; }
.lw-text[data-size="sm"] { font-size: 14px; } .lw-text[data-size="md"] { font-size: 22px; } .lw-text[data-size="lg"] { font-size: clamp(28px, 30cqh, 90px); }
.lw-clock { height: 100%; display: flex; flex-direction: column; justify-content: center; }
.lw-clock-time { font-size: clamp(24px, min(42cqh, 20cqw), 110px); font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.05; }
.lw-clock-date { color: var(--text2); text-transform: capitalize; }

/* poignées : visibles uniquement en édition (la grille est statique sinon) */
.grid-stack > .grid-stack-item > .ui-resizable-se { background-color: var(--accent); border-radius: 3px; opacity: .55; }
.grid-stack-placeholder > .placeholder-content { border: 2px dashed var(--accent) !important; background: transparent !important; border-radius: 10px; }

/* dialogues */
.lw-dialog { border: 1px solid var(--axis); border-radius: 12px; background: var(--surface); color: var(--text); padding: 18px 20px; width: min(480px, 92vw); }
.lw-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.lw-dialog-wide { width: min(760px, 94vw); }
.lw-dialog h2 { margin: 0 0 12px; font-size: 16px; }
.lw-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; border: 0; padding: 0; }
.lw-field > span, .lw-field > legend { font-weight: 600; font-size: 13px; padding: 0; }
.lw-field input, .lw-field select, .lw-field textarea { border: 1px solid var(--axis); border-radius: 6px; padding: 6px 8px; background: var(--bg); }
.lw-field textarea { font: 12px/1.35 ui-monospace, Menlo, Consolas, monospace; resize: vertical; }
.lw-field small, .lw-hint { color: var(--text2); font-size: 12px; margin: 0; }
.lw-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.lw-actions { display: flex; gap: 8px; align-items: center; margin-top: 14px; justify-content: flex-end; }
.lw-msg { font-size: 12px; min-height: 16px; color: var(--text2); }
#catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; max-height: 55vh; overflow: auto; padding: 2px; }
.lw-cat-title { grid-column: 1 / -1; font-size: 12px; font-weight: 650; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; margin-top: 6px; }
.lw-card { text-align: left; border: 1px solid var(--grid); border-radius: 8px; background: var(--bg); padding: 10px 12px; cursor: pointer; }
.lw-card:hover { border-color: var(--accent); }
.lw-card strong { display: block; margin-bottom: 2px; }
.lw-card span { color: var(--text2); font-size: 12px; }

/* mode TV */
.is-kiosk .lw-toolbar { display: none; }
.is-kiosk #app { padding-top: 8px; }
.lw-kiosk-exit { position: fixed; top: 8px; right: 8px; z-index: 50; opacity: .35; }
.lw-kiosk-exit:hover, .lw-kiosk-exit:focus { opacity: 1; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
