/*
 * DCS Galaxy — reprend le design de DCS Pulsar (DcsPulsar.App) : mêmes couleurs, cartes, pastilles,
 * barre de lecture. Thème sombre par défaut, clair selon le système.
 */
:root {
    --app-bg: #0e1116;
    --panel-bg: #131820;
    --card-bg: #19202a;
    --card-bg-hover: #1e2632;
    --card-border: #27303d;
    --subtle-fill: #222a36;
    --muted: #8d97a6;
    --text: #e6e9ee;
    --mono-bg: #0a0d11;
    --ok: #3fb950;
    --ok-fill: rgba(63, 185, 80, 0.12);
    --warn: #e3a33a;
    --warn-fill: rgba(227, 163, 58, 0.12);
    --bad: #f4665c;
    --bad-fill: rgba(244, 102, 92, 0.12);
    --idle: #6b7482;
    --idle-fill: rgba(141, 151, 166, 0.12);
    --accent: #f0a93c;
    --accent-fill: rgba(240, 169, 60, 0.1);
    --accent-text: #1a1206;
    --mono: 'Cascadia Mono', Consolas, Menlo, monospace;
    color-scheme: dark;
}

@media (prefers-color-scheme: light) {
    :root {
        --app-bg: #f3f4f6;
        --panel-bg: #fafbfc;
        --card-bg: #ffffff;
        --card-bg-hover: #f7f8fa;
        --card-border: #dde1e7;
        --subtle-fill: #eef0f3;
        --muted: #5c6573;
        --text: #1d2229;
        --mono-bg: #f7f8fa;
        --ok: #1f883d;
        --ok-fill: rgba(31, 136, 61, 0.1);
        --warn: #9a6700;
        --warn-fill: rgba(154, 103, 0, 0.1);
        --bad: #cf222e;
        --bad-fill: rgba(207, 34, 46, 0.1);
        --idle: #8c959f;
        --idle-fill: rgba(92, 101, 115, 0.1);
        --accent: #9a5b00;
        --accent-fill: rgba(154, 91, 0, 0.08);
        --accent-text: #ffffff;
        color-scheme: light;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--app-bg);
    color: var(--text);
    font: 14px/1.45 'Segoe UI', system-ui, -apple-system, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app { display: flex; flex-direction: column; min-height: 100vh; }

/* ------------------------------------------------------------------ en-tête */

.header {
    background: var(--panel-bg);
    border-bottom: 1px solid var(--card-border);
    padding: 14px 24px 0;
}
.header-row { display: flex; align-items: center; gap: 14px; }
.logo {
    width: 38px; height: 38px; border-radius: 9px;
    display: grid; place-items: center;
    background: var(--accent-fill); border: 1px solid var(--accent); color: var(--accent);
    flex: none;
}
.header h1 { font-size: 18px; font-weight: 600; margin: 0; }
.header .spacer { flex: 1; }
.header .who { color: var(--muted); font-size: 12px; text-align: right; }
.header .who a.active { color: var(--text); font-weight: 600; }

.nav { display: flex; gap: 22px; margin-top: 8px; overflow-x: auto; }
.nav button, .nav a {
    background: none; border: 0; padding: 8px 0 10px; cursor: pointer;
    color: var(--muted); font: inherit; font-size: 14px;
    border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none;
}
.nav button:hover, .nav a:hover { color: var(--text); text-decoration: none; }
.nav .active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.main { flex: 1; padding: 20px; width: 100%; }
.main.narrow { max-width: 900px; }

/* ------------------------------------------------------------------ texte */

.h2 { font-size: 15px; font-weight: 600; margin: 0; }
.section {
    font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
    color: var(--muted); text-transform: uppercase; margin: 0 0 12px;
}
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.key { color: var(--muted); font-size: 13px; padding: 3px 16px 3px 0; white-space: nowrap; vertical-align: top; }
.val { font-size: 13px; padding: 3px 0; word-break: break-word; }

/* ------------------------------------------------------------------ cartes */

.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 16px 18px;
}
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }

.callout {
    display: flex; gap: 12px; align-items: flex-start;
    background: var(--accent-fill); border-left: 3px solid var(--accent);
    border-radius: 4px; padding: 12px 14px;
}
.callout.bad { background: var(--bad-fill); border-left-color: var(--bad); }
.callout.warn { background: var(--warn-fill); border-left-color: var(--warn); }
.callout .grow { flex: 1; }

.chip {
    display: inline-flex; flex-direction: column;
    background: var(--subtle-fill); border-radius: 6px; padding: 6px 10px; margin: 0 8px 8px 0;
}
.chip .label { font-size: 11px; color: var(--muted); }
.chip .value { font-size: 14px; font-weight: 600; }

.code-chip {
    font-family: var(--mono); font-size: 11px;
    background: var(--subtle-fill); border-radius: 4px; padding: 1px 6px; color: var(--muted);
}

/* ------------------------------------------------------------------ pastilles d'état */

.pill {
    display: inline-flex; align-items: center; gap: 7px;
    border-radius: 12px; padding: 4px 12px 4px 10px; font-size: 12px; white-space: nowrap;
    background: var(--idle-fill);
}
.pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--idle); }
.pill.ok { background: var(--ok-fill); } .pill.ok::before { background: var(--ok); }
.pill.warn { background: var(--warn-fill); } .pill.warn::before { background: var(--warn); }
.pill.bad { background: var(--bad-fill); } .pill.bad::before { background: var(--bad); }

.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--idle); flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.dot.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

/* ------------------------------------------------------------------ boutons et champs */

button.btn, a.btn, label.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border-radius: 6px; padding: 6px 12px; cursor: pointer;
    font: inherit; font-size: 13px; line-height: 20px;
    background: var(--subtle-fill); color: var(--text); border: 1px solid var(--card-border);
    text-decoration: none;
}
.btn:hover:not(:disabled) { border-color: var(--muted); text-decoration: none; }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.45; cursor: not-allowed; }
.btn.accent { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.btn.accent:hover:not(:disabled) { filter: brightness(1.08); border-color: var(--accent); }
.btn.subtle { background: transparent; border-color: transparent; color: var(--muted); }
.btn.subtle:hover:not(:disabled) { color: var(--text); background: var(--subtle-fill); }
.btn.danger:hover:not(:disabled) { color: var(--bad); border-color: var(--bad); }
.btn.big { padding: 10px 18px; font-size: 14px; }
.btn.icon { padding: 6px; }
.btn svg { width: 16px; height: 16px; flex: none; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field .field-label { color: var(--muted); font-size: 13px; }
input.input, select.input, textarea.input {
    width: 100%; font: inherit; color: var(--text);
    background: var(--mono-bg); border: 1px solid var(--card-border); border-radius: 6px; padding: 7px 10px;
}
input.input:focus, select.input:focus, textarea.input:focus { outline: none; border-color: var(--accent); }
input.code-input { font-family: var(--mono); font-size: 22px; letter-spacing: 0.2em; text-transform: uppercase; text-align: center; }
.help { font-size: 12px; color: var(--muted); margin-top: 2px; }
.field-error { font-size: 12px; color: var(--bad); }
.rules { list-style: none; margin: -4px 0 14px; padding: 0; font-size: 12px; color: var(--muted); columns: 2; column-gap: 12px; }
.rules li { break-inside: avoid; margin-bottom: 2px; }
.rules li.ok { color: var(--ok); }

/* ------------------------------------------------------------------ onglets secondaires */

.tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--card-border); margin-bottom: 16px; overflow-x: auto; }
.tabs button, .tabs a {
    background: none; border: 0; padding: 6px 0 9px; cursor: pointer; font: inherit;
    color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button.active, .tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* ------------------------------------------------------------------ listes de tracks */

.list { display: flex; flex-direction: column; gap: 6px; }
.track {
    display: flex; align-items: center; gap: 10px;
    background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 8px;
    padding: 6px 8px 6px 6px; min-height: 44px;
}
.track:hover { background: var(--card-bg-hover); }
.track.current { border-color: var(--accent); background: var(--accent-fill); }
.track.dragging { opacity: 0.4; }
.track.drop-target { border-color: var(--accent); border-style: dashed; }
.track .handle { cursor: grab; color: var(--muted); display: grid; place-items: center; width: 22px; }
.track .handle svg { width: 14px; height: 14px; }
.track .index { font-family: var(--mono); font-size: 12px; color: var(--muted); width: 22px; text-align: right; }
.track .name { flex: 1; min-width: 0; }
.track .name strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track .name .sub { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track .meta { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.track input.input { padding: 4px 8px; }

.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty .bubble {
    width: 56px; height: 56px; border-radius: 50%; background: var(--subtle-fill);
    display: grid; place-items: center; margin: 0 auto 12px; color: var(--muted);
}
.empty .bubble svg { width: 22px; height: 22px; }
.empty .h2 { color: var(--text); margin-bottom: 4px; }

/* ------------------------------------------------------------------ choix du mode serveur */

.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.choice {
    text-align: left; cursor: pointer; font: inherit; color: var(--text);
    background: var(--card-bg); border: 1.5px solid var(--card-border); border-radius: 8px; padding: 12px 14px;
}
.choice:hover:not(:disabled) { background: var(--card-bg-hover); }
.choice.selected { border-color: var(--accent); background: var(--accent-fill); }
.choice:disabled { opacity: 0.55; cursor: not-allowed; }

/* ------------------------------------------------------------------ journal */

.log {
    font-family: var(--mono); font-size: 12px;
    background: var(--mono-bg); border: 1px solid var(--card-border); border-radius: 8px;
    padding: 10px 12px; height: 55vh; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.log .line { display: flex; gap: 10px; }
.log .time { color: var(--muted); flex: none; }
.log .warning { color: var(--warn); }
.log .error { color: var(--bad); }

/* ------------------------------------------------------------------ barre de lecture */

.transport {
    position: sticky; bottom: 0;
    background: var(--panel-bg); border-top: 1px solid var(--card-border);
    padding: 16px 24px; display: flex; gap: 14px; align-items: center;
}
.transport .status { flex: 1; min-width: 0; }
.transport .title { font-size: 15px; font-weight: 600; }
.transport .percent { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.transport .detail { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { height: 6px; border-radius: 3px; background: var(--subtle-fill); margin: 8px 0 6px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width 0.4s ease; }
.transport .actions { display: flex; gap: 8px; }

/* ------------------------------------------------------------------ appareils */

.devices { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.device-card .name { font-size: 16px; font-weight: 600; }
.device-card table { margin: 10px 0 14px; border-collapse: collapse; }

/* ------------------------------------------------------------------ administration des comptes */

.account {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 8px;
    padding: 10px 12px;
}
.account .name { flex: 1; min-width: 220px; }
.account .name strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account .name .sub { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.auth { max-width: 400px; margin: 60px auto; }
.auth .logo { width: 56px; height: 56px; border-radius: 14px; margin: 0 auto 16px; }
.auth .logo svg { width: 30px; height: 30px; }
.center { text-align: center; }

.banner { padding: 10px 24px; background: var(--bad-fill); border-bottom: 1px solid var(--bad); font-size: 13px; }
.banner.warn { background: var(--warn-fill); border-bottom-color: var(--warn); }

.version { text-align: right; font-size: 11px; color: var(--muted); padding: 4px 16px 6px; }

dialog.modal {
    width: min(440px, calc(100vw - 32px));
    background: var(--card-bg); color: var(--text);
    border: 1px solid var(--card-border); border-radius: 10px; padding: 20px 22px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
}
dialog.modal::backdrop { background: rgba(0, 0, 0, 0.55); }

.spinner {
    width: 14px; height: 14px; border-radius: 50%; flex: none;
    border: 2px solid var(--card-border); border-top-color: var(--accent);
    animation: spin 0.8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Interrupteur (case à cocher role="switch") */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input {
    appearance: none; margin: 0; flex: none; cursor: inherit;
    width: 36px; height: 20px; border-radius: 10px; position: relative;
    background: var(--subtle-fill); border: 1px solid var(--card-border);
    transition: background 0.15s, border-color 0.15s;
}
.switch input::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 14px; height: 14px; border-radius: 50%; background: var(--muted);
    transition: transform 0.15s, background 0.15s;
}
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(16px); background: var(--accent-text); }
.switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled, .switch input:disabled + span { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 700px) {
    .header { padding: 12px 16px 0; }
    .main { padding: 16px; }
    .transport { flex-wrap: wrap; padding: 12px 16px; }
    .transport .actions { width: 100%; }
    .transport .actions .btn { flex: 1; }
}

/* Paires libellé / valeur (Mon compte) */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin-bottom: 12px; }

/* Texte juridique (CGU) */
.legal { line-height: 1.6; max-width: 72ch; }
.legal h1 { font-size: 20px; margin: 0 0 4px; }
.legal h2 { font-size: 14px; letter-spacing: 0.02em; margin: 22px 0 6px; }
.legal p { margin: 0 0 10px; }
.legal ul { margin: 0 0 10px; padding-left: 22px; }
.legal li { margin-bottom: 4px; }
.legal table { border-collapse: collapse; width: 100%; margin: 0 0 12px; font-size: 13px; }
.legal th, .legal td { border: 1px solid var(--card-border); padding: 6px 10px; text-align: left; vertical-align: top; }
.legal th { background: var(--subtle-fill); }
/* Logo Orionsys en haut à droite des textes juridiques ; fond blanc : logo noir lisible en thème sombre */
.legal-logo { float: right; width: 140px; height: auto; margin: 0 0 12px 16px; padding: 8px; background: #fff; border-radius: 8px; }
@media (max-width: 700px) { .legal-logo { width: 96px; } }

