/* Tableau de bord des sauvegardes Acronis — feuille de style unique, sans dépendance externe. */

:root {
    color-scheme: light dark;

    --bg: #f4f6fa;
    --bg-elevated: #ffffff;
    --bg-sunken: #eef1f7;
    --sidebar-bg: #131a2a;
    --sidebar-fg: #aab4cc;
    --sidebar-fg-strong: #ffffff;
    --sidebar-active: #1e2941;

    --fg: #1b2333;
    --fg-muted: #667089;
    --border: #dde2ec;
    --border-strong: #c3cad9;

    --accent: #2f6df0;
    --accent-soft: #e6edfe;
    --accent-fg: #ffffff;

    --ok: #17864b;
    --ok-soft: #e2f5eb;
    --warn: #a86400;
    --warn-soft: #fdf1dc;
    --error: #c22c37;
    --error-soft: #fdeaec;
    --info: #1a6a94;
    --info-soft: #e3f2fa;
    --muted-soft: #eceff5;

    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(19, 26, 42, .06), 0 4px 14px rgba(19, 26, 42, .05);
    --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #10141d;
        --bg-elevated: #171c28;
        --bg-sunken: #1d2432;
        --sidebar-bg: #0b0f18;
        --sidebar-fg: #8e99b3;
        --sidebar-active: #1b2333;

        --fg: #e5e9f2;
        --fg-muted: #8e99b3;
        --border: #262e3d;
        --border-strong: #37415a;

        --accent: #5a8dff;
        --accent-soft: #1b2743;

        --ok: #4ecb8d;
        --ok-soft: #12301f;
        --warn: #e0a33a;
        --warn-soft: #33260c;
        --error: #ff7b86;
        --error-soft: #38161b;
        --info: #63bce8;
        --info-soft: #102a38;
        --muted-soft: #222a39;

        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--fg);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

/* ---------- Structure ---------- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 236px;
    flex: 0 0 236px;
    background: var(--sidebar-bg);
    color: var(--sidebar-fg);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    color: var(--sidebar-fg-strong);
    font-weight: 650;
    font-size: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand .logo {
    width: 30px; height: 30px;
    display: grid; place-items: center;
    border-radius: 8px;
    background: linear-gradient(140deg, #2f6df0, #6f4df0);
    color: #fff;
    font-size: 15px;
}
.sidebar-brand small { display: block; font-weight: 400; font-size: 11px; color: var(--sidebar-fg); }

.sidebar-nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-fg);
    font-weight: 500;
}
.sidebar-nav a:hover { background: var(--sidebar-active); color: var(--sidebar-fg-strong); text-decoration: none; }
.sidebar-nav a.is-active { background: var(--sidebar-active); color: var(--sidebar-fg-strong); }
.sidebar-nav .nav-count {
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 20px;
    background: rgba(255, 255, 255, .1);
}
.sidebar-nav .nav-count.is-alert { background: var(--error); color: #fff; }

.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid rgba(255, 255, 255, .07);
    font-size: 12px;
}
.sidebar-footer .user { color: var(--sidebar-fg-strong); font-weight: 500; }
.sidebar-footer a { color: var(--sidebar-fg); }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 24px 28px 0;
}
.page-header .subtitle { color: var(--fg-muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.page-body { padding: 20px 28px 40px; }

/* ---------- Composants ---------- */

.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.card-header .hint { color: var(--fg-muted); font-size: 12px; font-weight: 400; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 18px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; } }
@media (max-width: 620px) { .grid.cols-4 { grid-template-columns: 1fr; } }

.stat {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}
.stat .label { color: var(--fg-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 26px; font-weight: 650; margin-top: 6px; letter-spacing: -.02em; }
.stat .detail { color: var(--fg-muted); font-size: 12px; margin-top: 4px; }
.stat.is-error .value { color: var(--error); }
.stat.is-warn .value { color: var(--warn); }
.stat.is-ok .value { color: var(--ok); }

/* Badges d'état */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 550;
    white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.error { background: var(--error-soft); color: var(--error); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.muted { background: var(--muted-soft); color: var(--fg-muted); }
.badge.plain::before { display: none; }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.data th, table.data td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--fg-muted);
    font-weight: 600;
    background: var(--bg-sunken);
    white-space: nowrap;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--bg-sunken); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .primary { font-weight: 550; }
table.data .muted { color: var(--fg-muted); }
table.data .nowrap { white-space: nowrap; }

.empty {
    padding: 34px 18px;
    text-align: center;
    color: var(--fg-muted);
}
.empty strong { display: block; color: var(--fg); margin-bottom: 4px; }

/* Boutons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg-elevated);
    color: var(--fg);
    font: inherit;
    font-weight: 550;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { background: var(--bg-sunken); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--error); border-color: var(--error); background: transparent; }
.btn.danger:hover { background: var(--error-soft); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* Alertes / messages flash */
.flash {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    margin-bottom: 14px;
}
.flash.success { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.flash.error { background: var(--error-soft); border-color: var(--error); color: var(--error); }
.flash.warning { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.flash.info { background: var(--info-soft); border-color: var(--info); color: var(--info); }

.callout {
    padding: 12px 16px;
    border-radius: var(--radius);
    background: var(--warn-soft);
    color: var(--warn);
    border: 1px solid var(--warn);
    font-size: 13px;
}
.callout.error { background: var(--error-soft); color: var(--error); border-color: var(--error); }
.callout.neutral { background: var(--bg-sunken); color: var(--fg-muted); border-color: var(--border); }

/* Formulaires */
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-weight: 550; margin-bottom: 5px; font-size: 13px; }
.form-row input[type="text"],
.form-row input[type="url"],
.form-row input[type="email"],
.form-row input[type="password"],
.form-row input[type="search"],
.form-row input[type="time"],
.form-row input[type="number"],
.form-row select,
.form-row textarea {
    width: 100%;
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg-elevated);
    color: var(--fg);
    font: inherit;
    font-size: 13px;
}
.form-row textarea { resize: vertical; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: var(--accent);
}
.form-row .help { color: var(--fg-muted); font-size: 12px; margin-top: 5px; }
.form-row .errors { color: var(--error); font-size: 12px; margin: 5px 0 0; padding-left: 16px; }
.form-row.checkbox { display: flex; align-items: flex-start; gap: 9px; }
.form-row.checkbox label { margin: 0; }
.form-row.checkbox input { margin-top: 3px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 22px; }
/* Intertitre separant deux groupes de champs dans un meme formulaire. */
.form-section {
    margin: 22px 0 14px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .01em;
}

.filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.filters .form-row { margin: 0; min-width: 170px; }

/* Graphique */
.chart { width: 100%; height: 140px; display: block; }
.sparkline { width: 100%; height: 140px; display: block; overflow: visible; }
.sparkline-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.sparkline-area { fill: var(--accent); opacity: .1; stroke: none; }
.chart-empty { color: var(--fg-muted); text-align: center; padding: 40px 0; margin: 0; }
.chart-legend { display: flex; justify-content: space-between; color: var(--fg-muted); font-size: 12px; margin-top: 8px; }

/* Divers */
.mono { font-family: var(--mono); font-size: 12px; }
.stack { display: flex; flex-direction: column; gap: 3px; }
.stack .mono { white-space: nowrap; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; font-size: 13px; }
.dl dt { color: var(--fg-muted); }
.dl dd { margin: 0; word-break: break-word; }
.section-title { margin: 26px 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--fg-muted); }
.section-title:first-child { margin-top: 0; }

/* Barre de répartition des états */
.statusbar { display: flex; height: 8px; border-radius: 20px; overflow: hidden; background: var(--muted-soft); }
.statusbar span { display: block; height: 100%; }
.statusbar .s-ok { background: var(--ok); }
.statusbar .s-warn { background: var(--warn); }
.statusbar .s-error { background: var(--error); }
.statusbar .s-muted { background: var(--border-strong); }
.statusbar-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--fg-muted); }
.statusbar-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }

/* Page de connexion */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--bg);
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 30px;
}
.login-card .brand { display: flex; align-items: center; gap: 11px; margin-bottom: 6px; }
.login-card .brand .logo {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    border-radius: 9px;
    background: linear-gradient(140deg, #2f6df0, #6f4df0);
    color: #fff;
}
.login-card p.lead { color: var(--fg-muted); margin: 0 0 22px; font-size: 13px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 4px; }

@media (max-width: 860px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; flex: none; height: auto; position: static; }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
    .page-header, .page-body { padding-left: 16px; padding-right: 16px; }
}

/* Tuile cliquable vers la liste filtrée */
a.stat { display: block; color: inherit; transition: border-color .12s ease; }
a.stat:hover { text-decoration: none; border-color: var(--accent); }

/* Compteur coloré dans les tableaux de synthèse */
.count {
    display: inline-block;
    min-width: 24px;
    padding: 1px 8px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 12px;
    text-align: center;
}
.count.ok { background: var(--ok-soft); color: var(--ok); }
.count.warn { background: var(--warn-soft); color: var(--warn); }
.count.error { background: var(--error-soft); color: var(--error); }

/* Colonne « motif » : le texte qui explique l'état */
table.data td.reason {
    color: var(--fg-muted);
    min-width: 260px;
    max-width: 460px;
}

/* Filtre actif rappelé au-dessus des listes */
.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filter-chips .chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 550;
}
.filter-chips .chip a { color: inherit; font-weight: 700; line-height: 1; }

/* Commentaire libre attaché à une charge de travail */
.note {
    color: var(--fg);
    font-size: 12px;
    font-weight: 550;
}
.note::before { content: "✎ "; color: var(--fg-muted); font-weight: 400; }
.note-edit {
    margin-left: 6px;
    color: var(--fg-muted);
    font-size: 12px;
    text-decoration: none;
    opacity: 0;
    transition: opacity .12s ease;
}
tr:hover .note-edit, .note-edit:focus { opacity: 1; }
.note-edit:hover { color: var(--accent); text-decoration: none; }
