/* hub-master-web — style minimal */
/* Variables : palette sombre par défaut, claire si data-theme="light"
   ou si système préfère light et que l'utilisateur n'a pas forcé dark. */
:root {
    --bg: #0f1419;
    --bg-elev: #1a2028;
    --fg: #e6edf3;
    --fg-dim: #8b949e;
    --accent: #58a6ff;
    --border: #30363d;
    --ok: #3fb950;
    --warn: #d29922;
    --err: #f85149;
    color-scheme: dark;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg: #ffffff;
        --bg-elev: #f6f8fa;
        --fg: #1f2328;
        --fg-dim: #59636e;
        --accent: #0969da;
        --border: #d1d9e0;
        --ok: #1a7f37;
        --warn: #9a6700;
        --err: #cf222e;
        color-scheme: light;
    }
}

:root[data-theme="light"] {
    --bg: #ffffff;
    --bg-elev: #f6f8fa;
    --fg: #1f2328;
    --fg-dim: #59636e;
    --accent: #0969da;
    --border: #d1d9e0;
    --ok: #1a7f37;
    --warn: #9a6700;
    --err: #cf222e;
    color-scheme: light;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.5;
}

header.top {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
}

.brand {
    font-weight: 700;
    color: var(--fg);
    text-decoration: none;
    font-size: 1.1rem;
}

header.top nav {
    display: flex;
    gap: 1rem;
    flex: 1;
}

header.top nav a {
    color: var(--fg-dim);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

header.top nav a:hover,
header.top nav a.active {
    color: var(--fg);
    background: rgba(88, 166, 255, 0.1);
}

header.top .user {
    color: var(--fg-dim);
    font-size: 0.9rem;
}

header.top .user a {
    color: var(--accent);
    margin-left: 0.5rem;
}

#theme-toggle {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 28px; height: 28px;
    padding: 0; margin-right: 0.6rem;
    cursor: pointer; font-size: 0.85rem; line-height: 1;
    color: var(--fg);
}
#theme-toggle:hover { border-color: var(--accent); }

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

footer.bottom {
    text-align: center;
    color: var(--fg-dim);
    font-size: 0.85rem;
    padding: 1rem;
    border-top: 1px solid var(--border);
    margin-top: 3rem;
}

h1, h2, h3 { color: var(--fg); }
a { color: var(--accent); }
code, pre {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    background: var(--bg-elev);
    border-radius: 4px;
    padding: 0.1em 0.3em;
}
pre {
    padding: 0.75rem;
    overflow-x: auto;
}

.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
}

.muted { color: var(--fg-dim); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.err { color: var(--err); }

/* --- Page de login --- */
body.login-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
main.login-wrap { padding: 1rem; width: 100%; max-width: 380px; }
.login-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}
.login-card h1 { margin: 0 0 0.5rem; text-align: center; font-size: 1.4rem; }
.login-card label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    color: var(--fg-dim);
    font-size: 0.9rem;
}
.login-card input {
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.55rem 0.7rem;
    font-size: 1rem;
    font-family: inherit;
}
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.login-card button {
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: 4px;
    padding: 0.65rem 1rem;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 0.4rem;
}
.login-card button:hover { filter: brightness(1.1); }
.login-card .err {
    background: rgba(248, 81, 73, 0.12);
    border: 1px solid var(--err);
    border-radius: 4px;
    padding: 0.5rem 0.7rem;
    margin: 0;
    font-size: 0.9rem;
}

/* --- Page Suggestions --- */
.sugg-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 1rem 0 1.5rem;
    flex-wrap: wrap;
}
.sugg-toolbar .counts { display: flex; gap: 1rem; color: var(--fg-dim); font-family: ui-monospace, monospace; }
.sugg-toolbar .counts strong { color: var(--fg); }
.sugg-toolbar .actions { display: flex; gap: 0.75rem; align-items: center; }
.sugg-toolbar .actions button {
    background: var(--accent); color: var(--bg); border: none;
    border-radius: 4px; padding: 0.5rem 0.9rem; font-weight: 600; cursor: pointer;
}
.sugg-toolbar .actions button:disabled { opacity: 0.4; cursor: not-allowed; }
.sugg-toolbar .btn-link { color: var(--accent); text-decoration: none; }

.sugg-list { display: flex; flex-direction: column; gap: 0.9rem; }
.suggestion {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    border-radius: 6px;
    padding: 1rem 1.2rem;
}
.suggestion.suggestion-state-☑ { border-left-color: var(--accent); }
.suggestion.suggestion-state-✅ { border-left-color: var(--ok); opacity: 0.75; }
.suggestion.suggestion-state-✗ { border-left-color: var(--err); opacity: 0.6; }
.suggestion.suggestion-state-⚠ { border-left-color: var(--warn); }

.suggestion header {
    display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem;
    margin-bottom: 0.6rem;
}
.suggestion header h3 {
    margin: 0; flex: 1; font-size: 1.05rem; min-width: 200px;
}
.suggestion .badge {
    display: inline-block; font-size: 0.75rem;
    padding: 0.1rem 0.5rem; border-radius: 3px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.03em;
}
.imp-haute { background: rgba(248, 81, 73, 0.2); color: var(--err); }
.imp-moyenne { background: rgba(210, 153, 34, 0.2); color: var(--warn); }
.imp-basse { background: rgba(63, 185, 80, 0.18); color: var(--ok); }
.imp-na { background: var(--bg); color: var(--fg-dim); }
.badge.proj { background: rgba(88, 166, 255, 0.15); color: var(--accent); }
.suggestion .marqueur { font-size: 0.75rem; color: var(--fg-dim); }

.suggestion p { margin: 0.4rem 0; }
.suggestion .patch {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 0.7rem 0.9rem;
    margin-top: 0.6rem;
}
.suggestion .patch > strong:first-child {
    display: block;
    color: var(--fg-dim);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    font-weight: 600;
}
.suggestion .patch .rendered,
.suggestion .patch pre {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
}
.suggestion .patch pre { white-space: pre-wrap; font-size: 0.85rem; }
.suggestion .patch .rendered > :first-child { margin-top: 0; }
.suggestion .patch .rendered > :last-child { margin-bottom: 0; }
.suggestion .patch .rendered code,
.suggestion .patch .rendered pre {
    background: var(--bg-elev);
}
.suggestion .justif .rendered { margin-top: 0.3rem; }
.suggestion .justif .rendered > :first-child { margin-top: 0; }
.suggestion .justif pre { font-size: 0.85rem; white-space: pre-wrap; margin: 0.3rem 0 0; }
#toggle-raw {
    background: transparent; color: var(--fg-dim);
    border: 1px solid var(--border); border-radius: 4px;
    padding: 0.35rem 0.7rem; cursor: pointer; font-size: 0.85rem;
}
#toggle-raw:hover { border-color: var(--accent); color: var(--fg); }
#toggle-raw.active { background: var(--bg); border-color: var(--accent); color: var(--accent); }
.suggestion details.justif summary {
    cursor: pointer; color: var(--fg-dim); font-size: 0.9rem;
    margin: 0.5rem 0 0.3rem;
}
.suggestion footer { margin-top: 0.8rem; }
.suggestion fieldset.state-toggle {
    border: none; padding: 0; margin: 0;
    display: flex; gap: 1rem; flex-wrap: wrap;
}
.suggestion fieldset.state-toggle legend {
    color: var(--fg-dim); font-size: 0.85rem; padding: 0; margin-right: 0.4rem;
}
.suggestion fieldset.state-toggle label {
    color: var(--fg-dim); font-size: 0.9rem; cursor: pointer;
    display: inline-flex; gap: 0.3rem; align-items: center;
}
.suggestion fieldset.state-toggle label:has(input:checked) { color: var(--fg); }
.state-final { color: var(--fg-dim); font-size: 0.9rem; }

/* --- Dashboard --- */
.inbox { margin: 1rem 0; }
.inbox-card {
    background: var(--bg-elev); border: 1px solid var(--border);
    border-radius: 6px; padding: 0.8rem 1.2rem;
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}
.inbox-card.has-new { border-left: 4px solid var(--accent); }
.inbox-card strong { color: var(--accent); font-size: 1.2rem; }
.inline-form { display: inline; }
.inline-form button {
    background: transparent; color: var(--accent);
    border: 1px solid var(--accent); border-radius: 4px;
    padding: 0.3rem 0.7rem; cursor: pointer; font-size: 0.85rem;
}
.inline-form button:hover { background: rgba(88,166,255,0.1); }

.global-stats { display: flex; gap: 0.75rem; margin: 1rem 0 1.5rem; flex-wrap: wrap; }
.stat-pill {
    background: var(--bg-elev); border: 1px solid var(--border);
    border-radius: 18px; padding: 0.3rem 0.9rem; font-size: 0.9rem;
}
.stat-pill strong { color: var(--accent); margin-right: 0.3rem; }

.proj-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 1rem;
}
.proj-card {
    background: var(--bg-elev); border: 1px solid var(--border);
    border-radius: 6px; padding: 1rem 1.1rem;
    display: flex; flex-direction: column; gap: 0.7rem;
}
.proj-card header h2 { margin: 0 0 0.2rem; font-size: 1.05rem; }
.proj-card .proj-path {
    font-size: 0.75rem; color: var(--fg-dim);
    background: transparent; padding: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    display: block;
}
.proj-metrics { display: flex; gap: 0.7rem; flex-wrap: wrap; }
.proj-metrics .metric { flex: 1; min-width: 90px; }
.proj-metrics .label { display: block; font-size: 0.72rem; color: var(--fg-dim); }
.proj-metrics .value { font-size: 1.1rem; font-weight: 600; }
.proj-metrics .value.has-pending { color: var(--warn); }
.proj-card footer { display: flex; gap: 0.7rem; flex-wrap: wrap; font-size: 0.85rem; }
.proj-card footer a { text-decoration: none; }
.proj-card footer .warn { font-size: 0.8rem; }

.heatmap { display: grid; grid-template-columns: repeat(30, 1fr); gap: 2px; }
.hm-cell {
    aspect-ratio: 1; min-height: 8px; border-radius: 1px;
    background: rgba(255,255,255,0.04);
}
.hm-cell.hm-i1 { background: rgba(88,166,255,0.25); }
.hm-cell.hm-i2 { background: rgba(88,166,255,0.45); }
.hm-cell.hm-i3 { background: rgba(88,166,255,0.7); }
.hm-cell.hm-i4 { background: rgba(88,166,255,1); }

/* --- Page Journal --- */
.journal-filters {
    display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: end;
    background: var(--bg-elev); border: 1px solid var(--border);
    border-radius: 6px; padding: 0.8rem 1rem; margin-bottom: 1rem;
}
.journal-filters label {
    display: flex; flex-direction: column; gap: 0.3rem;
    color: var(--fg-dim); font-size: 0.8rem;
}
.journal-filters input, .journal-filters select {
    background: var(--bg); color: var(--fg);
    border: 1px solid var(--border); border-radius: 4px;
    padding: 0.4rem 0.6rem; font-family: inherit; font-size: 0.95rem;
}
.journal-filters button {
    background: var(--accent); color: var(--bg); border: none;
    border-radius: 4px; padding: 0.45rem 1rem; cursor: pointer; font-weight: 600;
}

.journal-layout { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 1000px) {
    .journal-layout:has(.journal-detail) { grid-template-columns: 1fr 1.2fr; }
}
.journal-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.journal-table th, .journal-table td {
    text-align: left; padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--border);
}
.journal-table th { color: var(--fg-dim); font-weight: 500; font-size: 0.78rem; text-transform: uppercase; }
.journal-table tr.is-viewed { background: rgba(88,166,255,0.08); }
.journal-table td.objectif { color: var(--fg-dim); font-size: 0.85rem; }
.journal-table a { text-decoration: none; }

.journal-detail {
    background: var(--bg-elev); border: 1px solid var(--border);
    border-radius: 6px; padding: 1rem 1.2rem;
    max-height: 80vh; overflow-y: auto;
}
.journal-detail header h2 { margin: 0 0 0.7rem; }
.journal-detail .meta-block summary { cursor: pointer; color: var(--fg-dim); font-size: 0.85rem; }
.journal-detail .meta-block table { font-size: 0.8rem; margin-top: 0.4rem; }
.journal-detail .meta-block th {
    text-align: left; padding: 0.2rem 0.6rem 0.2rem 0;
    color: var(--fg-dim); font-weight: 400; vertical-align: top;
}
.journal-detail .meta-block td { padding: 0.2rem 0; font-family: ui-monospace, monospace; }
.md-body { margin-top: 0.8rem; line-height: 1.55; }
.md-body h1, .md-body h2, .md-body h3 { margin-top: 1.2rem; }
.md-body pre { background: var(--bg); padding: 0.7rem; border-radius: 4px; }
.md-body code { background: var(--bg); padding: 0.1em 0.3em; border-radius: 3px; }
.md-body blockquote {
    border-left: 3px solid var(--fg-dim); padding-left: 0.8rem;
    margin: 0.8rem 0; color: var(--fg-dim);
}

/* --- Page Notes --- */
.notes-tabs { display: flex; gap: 0.4rem; margin-bottom: 0.8rem; border-bottom: 1px solid var(--border); }
.notes-tabs a {
    padding: 0.5rem 0.9rem; color: var(--fg-dim); text-decoration: none;
    border-bottom: 2px solid transparent; font-family: ui-monospace, monospace; font-size: 0.9rem;
}
.notes-tabs a.active { color: var(--fg); border-bottom-color: var(--accent); }
.notes-status {
    display: flex; align-items: center; gap: 0.8rem; margin: 0.5rem 0;
    color: var(--fg-dim); font-size: 0.85rem;
}
.notes-status button {
    background: var(--accent); color: var(--bg); border: none;
    border-radius: 4px; padding: 0.35rem 0.8rem; cursor: pointer; font-size: 0.85rem; font-weight: 600;
}
.notes-status button:last-child {
    background: transparent; color: var(--accent); border: 1px solid var(--accent);
}
.notes-edit { margin-top: 0.5rem; }
.notes-edit textarea {
    width: 100%; min-height: 65vh;
    background: var(--bg); color: var(--fg);
    border: 1px solid var(--border); border-radius: 4px;
    padding: 0.8rem 1rem; font-family: ui-monospace, monospace; font-size: 0.9rem;
    line-height: 1.5; resize: vertical;
}
.notes-edit textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.notes-edit #notes-preview {
    min-height: 65vh; padding: 1rem;
    background: var(--bg-elev); border: 1px solid var(--border); border-radius: 4px;
}
.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal[hidden], .toast[hidden], #notes-preview[hidden] { display: none !important; }
.modal-content {
    background: var(--bg-elev); border: 1px solid var(--warn);
    border-radius: 6px; padding: 1.5rem; max-width: 600px; max-height: 80vh; overflow-y: auto;
}
.modal-content pre {
    background: var(--bg); padding: 0.7rem; border-radius: 4px;
    max-height: 300px; overflow-y: auto; white-space: pre-wrap;
}
.modal-actions { display: flex; gap: 0.7rem; justify-content: flex-end; margin-top: 1rem; }
.modal-actions button {
    background: var(--warn); color: var(--bg); border: none;
    border-radius: 4px; padding: 0.5rem 1rem; cursor: pointer; font-weight: 600;
}
.modal-actions button:last-child {
    background: transparent; color: var(--fg); border: 1px solid var(--border);
}

/* Toast */
.toast {
    position: fixed; bottom: 1rem; right: 1rem;
    background: var(--bg-elev); color: var(--fg);
    border: 1px solid var(--border); border-left: 4px solid var(--ok);
    border-radius: 4px; padding: 0.7rem 1rem; max-width: 400px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    z-index: 100;
}
.toast.err { border-left-color: var(--err); }
