/* hub-codex — 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;
}

/* --- Dashboard --- */
.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; }
.stat-pill-warn strong { color: var(--warn); }

.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); }

.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], #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);
}

/* --- Page Projet --- */
.proj-card header h2 a.proj-title-link {
    color: var(--fg); text-decoration: none;
}
.proj-card header h2 a.proj-title-link:hover {
    color: var(--accent); text-decoration: underline;
}
.breadcrumb { font-size: 0.85rem; margin-bottom: 0.6rem; }
.breadcrumb a { color: var(--fg-dim); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }

.proj-header {
    background: var(--bg-elev); border: 1px solid var(--border);
    border-radius: 6px; padding: 1rem 1.2rem; margin-bottom: 1rem;
}
.proj-header h1 { margin: 0 0 0.3rem; }
.proj-header .proj-path-big {
    font-family: ui-monospace, monospace; font-size: 0.85rem;
    color: var(--fg-dim); background: transparent; padding: 0;
}
.proj-header-links {
    margin-top: 0.5rem;
    display: flex; flex-wrap: wrap; gap: 0.6rem 1.4rem;
    font-size: 0.9rem;
}
.proj-header-links a { color: var(--accent); text-decoration: none; }
.proj-header-links a:hover { text-decoration: underline; }
.proj-header-links .vscode-link {
    color: var(--fg); border: 1px solid var(--border);
    border-radius: 4px; padding: 0.15rem 0.6rem; background: var(--bg);
}
.proj-header-links .vscode-link:hover { border-color: var(--accent); text-decoration: none; }

.proj-header-meta {
    display: flex; flex-wrap: wrap; gap: 1rem;
    margin-top: 0.6rem; font-size: 0.88rem; color: var(--fg-dim);
}
.proj-header-meta .has-pending { color: var(--warn); }
.proj-header-meta .warn { color: var(--warn); }

.proj-tabs {
    display: flex; gap: 0.4rem; margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}
.proj-tabs a {
    padding: 0.5rem 0.9rem; color: var(--fg-dim); text-decoration: none;
    border-bottom: 2px solid transparent; font-size: 0.95rem;
}
.proj-tabs a:hover { color: var(--fg); }
.proj-tabs a.active { color: var(--fg); border-bottom-color: var(--accent); }

.proj-panel {
    background: var(--bg-elev); border: 1px solid var(--border);
    border-radius: 6px; padding: 1.2rem 1.4rem;
}
.proj-panel-head {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 0.4rem; gap: 1rem; flex-wrap: wrap;
}
.proj-panel-head h2 { margin: 0; }
.proj-panel .muted { color: var(--fg-dim); }

.proj-empty-guide {
    border: 1px dashed var(--border); border-radius: 6px;
    padding: 1rem 1.2rem; color: var(--fg-dim); background: var(--bg);
}
.proj-empty-guide strong { color: var(--fg); }
.proj-empty-guide ul { margin: 0.5rem 0 0 1.2rem; }

.doc-list { list-style: none; padding: 0; margin: 0.6rem 0 0; }
.doc-list li { padding: 0.25rem 0; }
.doc-list code { font-size: 0.9rem; }

/* Rendu markdown plus agréable pour la lecture longue */
.md-body-wide { max-width: 78ch; font-size: 0.98rem; }
.md-body-wide h1 { font-size: 1.6rem; margin: 0.3rem 0 1rem; }
.md-body-wide h2 {
    font-size: 1.25rem; margin-top: 1.8rem; padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
}
.md-body-wide h3 { font-size: 1.05rem; margin-top: 1.4rem; }
.md-body-wide p { margin: 0.7rem 0; }
.md-body-wide ul, .md-body-wide ol { padding-left: 1.4rem; }
.md-body-wide li { margin: 0.25rem 0; }
.md-body-wide table {
    border-collapse: collapse; margin: 0.8rem 0; font-size: 0.92rem;
}
.md-body-wide th, .md-body-wide td {
    border: 1px solid var(--border); padding: 0.4rem 0.7rem;
}
.md-body-wide th { background: var(--bg); }
.md-body-wide hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.md-body-wide pre { overflow-x: auto; line-height: 1.4; }
.md-body-wide a { color: var(--accent); }

/* Visionneuse modale .md (project.php) */
.md-modal {
    position: fixed; inset: 0; z-index: 300;
    display: flex; align-items: center; justify-content: center;
    padding: 2rem;
}
.md-modal[hidden] { display: none !important; }
.md-modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.6);
}
.md-modal-dialog {
    position: relative; z-index: 1;
    display: flex; flex-direction: column;
    width: min(900px, 100%); max-height: 90vh;
    background: var(--bg-elev);
    border: 1px solid var(--border); border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}
.md-modal-head {
    display: flex; align-items: center; gap: 1rem;
    padding: 0.8rem 1.1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
.md-modal-titles { flex: 1; min-width: 0; }
.md-modal-head h2 {
    margin: 0; font-size: 1.05rem; font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.md-modal-path {
    display: block; font-size: 0.8rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.md-modal-close {
    background: transparent; border: none; color: var(--fg);
    font-size: 1.6rem; line-height: 1; cursor: pointer;
    padding: 0.1rem 0.5rem; border-radius: 4px;
}
.md-modal-close:hover { background: var(--border); }
.md-modal-body {
    flex: 1; min-height: 0; overflow-y: auto;
    padding: 1rem 1.4rem;
}
body.md-modal-open { overflow: hidden; }
