/*!
 * Lamarck UI — design system commun à toutes les apps Lamarck.
 *
 * Fournit les design tokens (couleurs, font, espacement) et les composants
 * de base : .card, .btn, .form-group, .table, etc.
 *
 * Source : extrait de steering-dashboard/dashboard/public/login.html +
 * index.html, normalisé pour usage server-rendered (Jinja2 + HTMX).
 *
 * Usage :
 *     <link rel="stylesheet" href="/lamarck-static/lamarck.css">
 */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #f4f6f9;
    --surface: #fff;
    --surface2: #f0f2f6;
    --border: rgba(0, 0, 0, 0.08);
    --border2: rgba(0, 0, 0, 0.15);
    --text: #1a1d23;
    --muted: #6b7280;
    --accent: #1e5fa3;
    --accent-light: #e8f0fb;
    --accent-dark: #1751a0;
    --green: #059669;
    --green-light: #d1fae5;
    --red: #dc2626;
    --red-light: #fef2f2;
    --amber: #d97706;
    --amber-light: #fef3c7;
    --font: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
    --r: 10px;
    --rl: 16px;
    --sh: 0 4px 24px rgba(0, 0, 0, 0.08);
    --sh-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
}

html,
body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
    line-height: 1.5;
}

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

a:hover {
    text-decoration: underline;
}

code,
pre {
    font-family: var(--font-mono);
}

/* ── Layouts ─────────────────────────────────────────────────────── */

.center-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 16px;
}

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

.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-header .brand {
    font-weight: 500;
    font-size: 15px;
    color: var(--text);
}

.app-header .brand .accent {
    color: var(--accent);
}

.app-header nav {
    display: flex;
    gap: 18px;
    font-size: 13px;
    color: var(--muted);
    align-items: center;
}

.app-header nav a {
    color: var(--muted);
}

.app-header nav a:hover {
    color: var(--text);
    text-decoration: none;
}

.app-header nav .badge-admin {
    background: var(--amber-light);
    color: var(--amber);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
}

.app-main {
    flex: 1;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 28px 24px;
}

.app-footer {
    text-align: center;
    color: var(--muted);
    font-size: 11px;
    padding: 18px;
}

/* ── Card ────────────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border-radius: var(--rl);
    box-shadow: var(--sh);
    padding: 28px;
}

.card-login {
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
}

.card-section {
    background: var(--surface);
    border-radius: var(--rl);
    box-shadow: var(--sh);
    padding: 24px;
    margin-bottom: 16px;
}

.card-section h2 {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 14px;
}

/* ── Logo ────────────────────────────────────────────────────────── */

.logo-wrap {
    text-align: center;
    margin-bottom: 28px;
}

.logo-wrap .logo {
    font-size: 24px;
    font-weight: 500;
    color: var(--accent);
    letter-spacing: -0.5px;
}

.logo-wrap p {
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
}

/* ── Forms ───────────────────────────────────────────────────────── */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border2);
    border-radius: var(--r);
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.form-group input::placeholder {
    color: var(--muted);
}

.form-group .hint {
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
}

/* ── Buttons ─────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 18px;
    border-radius: var(--r);
    border: 1px solid transparent;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-dark);
    text-decoration: none;
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--surface2);
    color: var(--text);
    border-color: var(--border2);
}

.btn-secondary:hover {
    background: var(--border);
    text-decoration: none;
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border: none;
    padding: 8px 12px;
}

.btn-ghost:hover {
    background: var(--surface2);
    color: var(--text);
}

.btn-danger {
    background: var(--surface2);
    color: var(--text);
    border-color: var(--border2);
}

.btn-danger:hover {
    background: var(--red-light);
    color: var(--red);
    text-decoration: none;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-webauthn {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border2);
}

.btn-webauthn:hover {
    background: var(--border);
    text-decoration: none;
}

.btn-webauthn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ── Divider ─────────────────────────────────────────────────────── */

.divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0;
    color: var(--muted);
    font-size: 12px;
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ── Alerts ──────────────────────────────────────────────────────── */

.alert {
    border-radius: var(--r);
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 14px;
}

.alert-error {
    background: var(--red-light);
    border: 1px solid #fecaca;
    color: var(--red);
}

.alert-success {
    background: var(--green-light);
    border: 1px solid #a7f3d0;
    color: var(--green);
}

.alert-info {
    background: var(--accent-light);
    border: 1px solid rgba(30, 95, 163, 0.2);
    color: var(--accent-dark);
}

.alert-warning {
    background: var(--amber-light);
    border: 1px solid #fde68a;
    color: var(--amber);
}

.alert ul {
    margin-left: 20px;
}

/* ── Tables ──────────────────────────────────────────────────────── */

.table {
    width: 100%;
    background: var(--surface);
    border-radius: var(--rl);
    overflow: hidden;
    box-shadow: var(--sh);
    border-collapse: collapse;
}

.table thead {
    background: var(--surface2);
}

.table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background: var(--bg);
}

/* ── Badges ──────────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.5;
}

.badge-success {
    background: var(--green-light);
    color: var(--green);
}

.badge-warning {
    background: var(--amber-light);
    color: var(--amber);
}

.badge-error {
    background: var(--red-light);
    color: var(--red);
}

.badge-info {
    background: var(--accent-light);
    color: var(--accent-dark);
}

.badge-neutral {
    background: var(--surface2);
    color: var(--muted);
}

/* ── App grid (dashboard cards) ───────────────────────────────────── */

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 8px;
}

.app-tile {
    background: var(--surface);
    border-radius: var(--rl);
    padding: 24px;
    box-shadow: var(--sh);
    transition: all 0.2s;
    color: var(--text);
    text-decoration: none;
    display: block;
    position: relative;
    border: 1px solid transparent;
}

.app-tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--sh-lg);
    border-color: var(--accent);
    text-decoration: none;
}

.app-tile.disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

.app-tile .icon {
    font-size: 28px;
    line-height: 1;
    margin-bottom: 12px;
    display: block;
}

.app-tile .name {
    font-size: 16px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
}

.app-tile .desc {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.5;
}

.app-tile .soon {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--surface2);
    color: var(--muted);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* ── Section headers ─────────────────────────────────────────────── */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
}

.page-header .sub {
    font-size: 13px;
    color: var(--muted);
}

.page-header .actions {
    display: flex;
    gap: 8px;
}

/* ── Spinner ─────────────────────────────────────────────────────── */

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-right: 6px;
    vertical-align: middle;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Utility ─────────────────────────────────────────────────────── */

.muted {
    color: var(--muted);
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mono {
    font-family: var(--font-mono);
    font-size: 13px;
}

.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gap-2 {
    gap: 8px;
}

.mt-2 {
    margin-top: 8px;
}

.mt-4 {
    margin-top: 16px;
}

.mb-4 {
    margin-bottom: 16px;
}

/* ── v0.6.0 : ajouts pour cohérence cross-apps ──────────────────────── */

/* Header alternatif "app satellite" : différencie visuellement les apps
   métier (brand-header) du portail (app-header avec nav globale). */
.brand-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}
.brand-header .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    font-size: 16px;
}
.brand-header .brand-logo {
    width: 32px;
    height: 32px;
    background: var(--accent);
    color: #fff;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}
.brand-header .brand-name {
    color: var(--text);
}
.brand-header .brand-name .accent {
    color: var(--accent);
}
.brand-header .brand-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* Nav tabs (utilisé par lamarck-recrutement pour onglets Général/Cooptation) */
.nav-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    overflow-x: auto;
}
.nav-tabs a {
    padding: 12px 20px;
    text-decoration: none;
    color: var(--muted);
    font-size: 14px;
    border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
}
.nav-tabs a.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 500;
}
.nav-tabs a:hover:not(.active) {
    color: var(--text);
    text-decoration: none;
}

/* Container max-width responsive (utilisé par les apps satellites) */
.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 24px;
}

/* Page courante dans la nav du header global (utile pour le portail
   et toute app utilisant .app-header) */
.app-header nav a.active {
    color: var(--accent);
    font-weight: 500;
}

/* Affichage "page active" via aria-current (accessibilité) */
.app-header nav a[aria-current="page"],
.brand-header .brand-actions a[aria-current="page"] {
    color: var(--accent);
    font-weight: 500;
}

/* Mobile responsive de base — < 720px : nav s'enroule, padding réduit */
@media (max-width: 720px) {
    .app-header,
    .brand-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 12px 16px;
    }
    .app-header nav,
    .brand-header .brand-actions {
        width: 100%;
        flex-wrap: wrap;
    }
    .app-main,
    .container {
        padding: 16px;
    }
    .nav-tabs a {
        padding: 10px 14px;
        font-size: 13px;
    }
}

/* KPI grid utilitaire */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 16px 20px;
}
.kpi-card h3 {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    margin: 0 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.kpi-value {
    font-size: 28px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.1;
}
.kpi-value.error {
    font-size: 14px;
    color: var(--red);
    font-weight: 400;
}
.kpi-sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
}
.delta-up { color: var(--green); }
.delta-down { color: var(--red); }

/* ── v0.7.0 : sidebar layout + modale standardisée ──────────────────── */

/* Layout shell avec sidebar : usage côté app
   <body class="lk-with-sidebar">
     {% include "_partials/sidebar.html" %}
     <main class="lk-main">{{ content }}</main>
   </body>
*/
body.lk-with-sidebar {
    display: flex;
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
}

.lk-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.lk-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--border);
    min-height: 60px;
}

.lk-sidebar-logo {
    display: inline-flex;
    line-height: 0;
}

.lk-sidebar-app-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--text);
}

.lk-sidebar-nav {
    flex: 1;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.lk-sidebar-section-title {
    font-size: 10px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 14px 12px 6px;
}

.lk-sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    transition: background 0.1s, color 0.1s;
}

.lk-sidebar-link:hover {
    background: var(--surface2);
    text-decoration: none;
}

.lk-sidebar-link.is-active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 500;
}

.lk-sidebar-icon {
    font-size: 15px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.lk-sidebar-label {
    flex: 1;
}

.lk-sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lk-sidebar-user {
    color: var(--muted);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lk-sidebar-back,
.lk-sidebar-logout {
    color: var(--muted);
    text-decoration: none;
    font-size: 12px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-align: left;
    font-family: var(--font);
}

.lk-sidebar-back:hover,
.lk-sidebar-logout:hover {
    color: var(--accent);
    text-decoration: none;
}

.lk-sidebar-logout-form {
    margin: 0;
}

.lk-main {
    flex: 1;
    padding: 24px 32px;
    max-width: 1300px;
    width: 100%;
    margin: 0 auto;
}

/* Mobile : sidebar collapse en burger en V2.x. Pour V0.7, juste un
   réordonnancement vertical sans toggle (acceptable car pas de mobile
   prioritaire). */
@media (max-width: 720px) {
    body.lk-with-sidebar {
        flex-direction: column;
    }
    .lk-sidebar {
        width: 100%;
        height: auto;
        position: relative;
        flex-direction: row;
        border-right: 0;
        border-bottom: 1px solid var(--border);
        overflow-x: auto;
    }
    .lk-sidebar-brand,
    .lk-sidebar-footer {
        border: 0;
    }
    .lk-sidebar-nav {
        flex-direction: row;
        gap: 0;
        padding: 8px 4px;
    }
    .lk-sidebar-section-title {
        display: none;
    }
    .lk-sidebar-link {
        flex-shrink: 0;
        white-space: nowrap;
    }
    .lk-main {
        padding: 16px;
    }
}

/* Modale standardisée — utilisée via lamarck_shared/ui/templates/_partials/modal.html */
.lk-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 100;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    overflow-y: auto;
}

.lk-modal-box {
    background: var(--surface);
    border-radius: 12px;
    width: 100%;
    max-width: 820px;
    padding: 24px 28px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.lk-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: 0;
    font-size: 24px;
    cursor: pointer;
    color: var(--muted);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.lk-modal-close:hover {
    color: var(--text);
    background: var(--surface2);
}
