/* ==========================================================
   Agent IA — Système de design professionnel
   Palette configurable via --brand-primary (injectée en inline
   depuis config.yaml → branding.primary_color).
   ========================================================== */

:root {
    /* Primary — défaut, remplacé par branding côté template */
    --brand-primary: #2563eb;
    --brand-primary-hover: #1d4ed8;
    --brand-primary-soft: rgba(37, 99, 235, 0.08);

    /* Surfaces (thème clair par défaut) */
    --bg: #f7f8fa;
    --bg-elevated: #ffffff;
    --bg-muted: #f1f3f5;
    --bg-hover: #eef0f2;

    /* Bordures */
    --border: #e4e7ec;
    --border-strong: #d0d5dd;

    /* Texte */
    --text: #101828;
    --text-muted: #475467;
    --text-subtle: #667085;
    --text-on-primary: #ffffff;

    /* États */
    --success: #12b76a;
    --warning: #f79009;
    --danger: #f04438;
    --danger-soft: #fef3f2;

    /* Divers */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-lg: 0 12px 24px -8px rgba(16, 24, 40, 0.12), 0 4px 8px -4px rgba(16, 24, 40, 0.06);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Thème sombre — activé via <body data-theme="dark"> */
[data-theme="dark"] {
    --bg: #0f1115;
    --bg-elevated: #161a21;
    --bg-muted: #1c212b;
    --bg-hover: #232935;
    --border: #232935;
    --border-strong: #2d3442;
    --text: #e7eaf0;
    --text-muted: #9ba3b4;
    --text-subtle: #707889;
    --danger-soft: #2a1618;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--brand-primary); text-decoration: none; }
a:visited { color: var(--brand-primary); }
a:hover { text-decoration: underline; color: var(--brand-primary-hover); }

/* Bannière licence (admins only) — barre haute fixe, jamais en colonne latérale */
.license-grace-banner {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    width: 100% !important;
    max-width: 100vw;
    box-sizing: border-box;
    margin: 0;
    padding: 0.45rem 1rem;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1.35;
    white-space: normal;
    writing-mode: horizontal-tb !important;
    color: #f8fafc;
    background: #334155;
    border-bottom: 1px solid rgba(251, 191, 36, 0.45);
    z-index: 100000;
}
.license-grace-banner i {
    color: #fbbf24;
    margin-right: 0.4rem;
}
body.has-license-banner {
    padding-top: 2.35rem;
}
.demo-ephemeral-banner {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    width: 100% !important;
    max-width: 100vw;
    box-sizing: border-box;
    margin: 0;
    padding: 0.45rem 1rem;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.35;
    color: #fffbeb;
    background: #92400e;
    border-bottom: 1px solid rgba(251, 191, 36, 0.55);
    z-index: 100001;
}
.demo-ephemeral-banner i {
    color: #fcd34d;
    margin-right: 0.4rem;
}
body.has-license-banner.has-demo-banner .demo-ephemeral-banner {
    top: 2.35rem;
}
body.has-demo-banner {
    padding-top: 2.35rem;
}
body.has-license-banner.has-demo-banner {
    padding-top: 4.7rem;
}
body.has-top-banner {
    padding-top: 2.35rem;
}

/* ── Typographie ── */
h1, h2, h3, h4 { color: var(--text); margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); font-size: 0.85rem; }

/* ── Carte ── */
.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.card-padded { padding: 24px; }
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: 20px; }

/* ── Layout auth (login / register / change-password) ── */
.auth-shell {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at 20% 0%, var(--brand-primary-soft), transparent 50%),
        var(--bg);
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px;
}
.auth-brand {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 24px;
}
.auth-brand-mark {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: var(--brand-primary);
    color: var(--text-on-primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
}
.auth-brand-mark img { width: 100%; height: 100%; object-fit: contain; border-radius: 8px; }
.auth-brand-text { font-weight: 600; font-size: 1rem; color: var(--text); }
.auth-title { font-size: 1.35rem; font-weight: 600; margin-bottom: 4px; }
.auth-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 24px; }
.auth-footer { margin-top: 20px; font-size: 0.85rem; color: var(--text-muted); text-align: center; }

/* ── Formulaires ── */
.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}
.input, .select, .textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, .textarea:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-primary-soft);
}
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 42px; }
.pw-toggle {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    border: 0; background: transparent; color: var(--text-muted);
    cursor: pointer; width: 32px; height: 32px; border-radius: 6px;
}
.pw-toggle:hover { color: var(--text); }
.textarea { min-height: 90px; resize: vertical; }

/* ── Boutons ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 16px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-family: inherit; font-size: 0.9rem; font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    text-decoration: none;
    line-height: 1.2;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
    background: var(--brand-primary);
    color: var(--text-on-primary);
}
.btn-primary:hover:not(:disabled) { background: var(--brand-primary-hover); }

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover:not(:disabled) { filter: brightness(0.93); }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 0.82rem; }

/* ── Alertes ── */
.alert {
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    margin-bottom: 16px;
    display: flex; gap: 10px; align-items: flex-start;
    border: 1px solid transparent;
}
.alert-danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.alert-warning { background: #fffaeb; border-color: var(--warning); color: #b54708; }
.alert-info { background: var(--brand-primary-soft); border-color: var(--brand-primary); color: var(--brand-primary); }

/* ── Badges ── */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 500;
    background: var(--bg-muted);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.badge-admin { background: var(--brand-primary-soft); color: var(--brand-primary); border-color: transparent; }
.badge-success { background: #ecfdf3; color: #027a48; border-color: transparent; }

/* ── Tables ── */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.table th, .table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.table th {
    background: var(--bg-muted);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.table tbody tr:hover { background: var(--bg-hover); }
.table td { color: var(--text); }

/* ── Top bar app ── */
.app-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 24px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    height: 56px;
}
.app-topbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.app-topbar-brand .mark {
    width: 28px; height: 28px;
    background: var(--brand-primary);
    color: var(--text-on-primary);
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
}
.app-topbar-nav { display: flex; gap: 4px; }
.app-topbar-nav a,
.app-topbar-nav a:link,
.app-topbar-nav a:visited {
    color: var(--text-muted, #98a2b3);
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    text-decoration: none;
}
.app-topbar-nav a:hover, .app-topbar-nav a.active,
.app-topbar-nav a.active:visited,
.app-topbar-nav a.active:link {
    background: var(--bg-muted, #1f2937);
    color: var(--text, #f9fafb);
    text-decoration: none;
}
.app-topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ── Utilitaires ── */
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.spacer { flex: 1; }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}
.stat-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
}
.stat-label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 1.75rem; font-weight: 600; margin-top: 6px; color: var(--text); }

/* Footer */
.app-footer {
    text-align: center;
    color: var(--text-subtle);
    font-size: 0.78rem;
    padding: 16px;
}
