/* =====================================================================
   agents.jandbprod.fr — Thème « cockpit sombre »
   Une couleur d'accent par agent est injectée via --accent.
   ===================================================================== */

:root {
    --bg:        #0d1117;
    --bg-2:      #161b22;
    --bg-3:      #1c2330;
    --line:      #263041;
    --txt:       #e6edf3;
    --txt-dim:   #9aa7b4;
    --txt-mute:  #6b7684;
    --accent:    #4f8cff;
    --danger:    #f0616d;
    --radius:    14px;
    --shadow:    0 6px 24px rgba(0,0,0,.35);
    --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--txt);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
code { background: var(--bg-3); padding: .1em .4em; border-radius: 6px; font-size: .9em; }
.muted { color: var(--txt-mute); }

/* --- Barre supérieure -------------------------------------------------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 20px;
    background: linear-gradient(180deg, #10161f, var(--bg));
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-dot {
    width: 11px; height: 11px; border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #7aa2ff, #2f6bff);
    box-shadow: 0 0 12px #3f7bff; align-self: center;
}
.brand-name { font-weight: 700; letter-spacing: .3px; }
.brand-sub  { color: var(--txt-mute); font-size: .8rem; }
.topnav { display: flex; gap: 18px; align-items: center; }
.topnav a { color: var(--txt-dim); font-size: .92rem; }
.topnav a:hover { color: var(--txt); }
.topnav .logout { color: var(--txt-mute); }

/* --- Conteneur --------------------------------------------------------- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 26px 20px 60px; }
.page-head h1 { margin: 0 0 4px; font-size: 1.5rem; }
.page-head p  { margin: 0 0 22px; }

.flash {
    background: var(--bg-3); border: 1px solid var(--line);
    padding: 10px 14px; border-radius: 10px; margin-bottom: 18px;
}

/* --- Cartes ------------------------------------------------------------ */
.card {
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
}
.empty { color: var(--txt-dim); }

/* --- Trombinoscope ----------------------------------------------------- */
.grid-agents {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.agent-card {
    display: block; position: relative; overflow: hidden;
    transition: transform .12s ease, border-color .12s ease;
    border-top: 3px solid var(--accent);
}
.agent-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.agent-top { display: flex; align-items: center; justify-content: space-between; }
.avatar {
    width: 42px; height: 42px; border-radius: 12px;
    display: grid; place-items: center;
    font-weight: 700; color: #fff; font-size: 1.1rem;
}
.avatar.sm { width: 34px; height: 34px; border-radius: 10px; font-size: .95rem; }
.mode-tag {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .5px;
    padding: 3px 8px; border-radius: 999px;
    background: var(--bg-3); color: var(--txt-dim); border: 1px solid var(--line);
}
.agent-nom { margin: 14px 0 2px; font-size: 1.15rem; }
.agent-role { margin: 0 0 16px; color: var(--txt-dim); font-size: .9rem; min-height: 2.4em; }
.agent-stats { display: flex; gap: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.agent-stats > div { display: flex; flex-direction: column; }
.stat-val { font-weight: 600; font-size: .95rem; }
.stat-lbl { font-size: .72rem; color: var(--txt-mute); text-transform: uppercase; letter-spacing: .4px; }
.agent-cta { margin-top: 14px; color: var(--accent); font-size: .9rem; font-weight: 600; }

/* --- Boutons / formulaires -------------------------------------------- */
.btn {
    display: inline-block; border: 1px solid var(--line); cursor: pointer;
    background: var(--bg-3); color: var(--txt);
    padding: 10px 16px; border-radius: 10px; font-size: .95rem; font-family: inherit;
    transition: filter .12s ease, background .12s ease;
}
.btn:hover { filter: brightness(1.12); }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }

label { display: block; margin-bottom: 14px; font-size: .9rem; color: var(--txt-dim); }
input, textarea {
    width: 100%; margin-top: 6px;
    background: var(--bg); color: var(--txt);
    border: 1px solid var(--line); border-radius: 10px;
    padding: 11px 13px; font-size: 1rem; font-family: inherit;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }

/* --- Écran de connexion ------------------------------------------------ */
.login-screen { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 360px; }
.login-logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15rem; }
.login-tagline { color: var(--txt-mute); margin: 6px 0 22px; font-size: .9rem; }
.alert { background: rgba(240,97,109,.12); border: 1px solid var(--danger); color: #ffd7da; padding: 10px 13px; border-radius: 10px; margin-bottom: 16px; font-size: .9rem; }

/* --- Chat -------------------------------------------------------------- */
.chat {
    display: grid; grid-template-columns: 260px 1fr; gap: 18px;
    height: calc(100vh - 130px); min-height: 420px;
}
.chat-side { display: flex; flex-direction: column; gap: 12px; overflow: hidden; }
.chat-agent { display: flex; gap: 10px; align-items: center; padding: 4px 2px; }
.chat-agent-nom { font-weight: 600; }
.chat-agent-role { font-size: .8rem; }
.conv-list { list-style: none; margin: 4px 0 0; padding: 0; overflow-y: auto; flex: 1; }
.conv-list li a {
    display: block; padding: 9px 11px; border-radius: 10px;
    border: 1px solid transparent; margin-bottom: 4px;
}
.conv-list li a:hover { background: var(--bg-2); }
.conv-list li.active a { background: var(--bg-2); border-color: var(--accent); }
.conv-titre { display: block; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-date { font-size: .72rem; }

.chat-main {
    display: flex; flex-direction: column;
    background: var(--bg-2); border: 1px solid var(--line);
    border-radius: var(--radius); overflow: hidden;
}
.chat-thread { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.chat-hint { color: var(--txt-mute); text-align: center; margin: auto; }
.msg { display: flex; }
.msg-user { justify-content: flex-end; }
.msg-bulle {
    max-width: 76%; padding: 11px 15px; border-radius: 14px;
    white-space: normal; word-wrap: break-word;
}
.msg-user .msg-bulle { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg-assistant .msg-bulle { background: var(--bg-3); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg-assistant.pending .msg-bulle { color: var(--txt-mute); font-style: italic; }

.composer { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--line); background: var(--bg-2); }
.composer textarea { margin: 0; resize: none; max-height: 160px; }
.composer .btn { align-self: flex-end; }

/* --- Navigation badge -------------------------------------------------- */
.nav-badge {
    display: inline-block; min-width: 18px; height: 18px; line-height: 18px;
    padding: 0 5px; border-radius: 9px; text-align: center;
    background: var(--danger); color: #fff; font-size: .72rem; font-weight: 700;
}
.btn-danger { background: transparent; border-color: var(--danger); color: #ff9aa2; }
.btn-danger:hover { background: rgba(240,97,109,.14); }

.section-titre { margin: 28px 0 12px; font-size: 1.05rem; color: var(--txt-dim); }

/* --- File de validation ------------------------------------------------ */
.valid-card { border-left: 3px solid var(--accent); margin-bottom: 16px; }
.valid-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.type-tag {
    display: inline-block; font-size: .7rem; text-transform: uppercase; letter-spacing: .5px;
    padding: 2px 8px; border-radius: 999px; margin-right: 8px;
    background: var(--bg-3); color: var(--txt-dim); border: 1px solid var(--line);
}
.valid-titre { font-size: 1.02rem; }
.valid-contenu {
    background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
    padding: 12px 14px; margin-bottom: 12px; white-space: normal; line-height: 1.55;
    max-height: 320px; overflow-y: auto;
}
.valid-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.valid-actions input[type=text] { flex: 1; min-width: 180px; margin: 0; }

.decisions, .runs, .taches { list-style: none; margin: 0; padding: 0; }
.decisions li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.decisions li:last-child { border-bottom: 0; }
.dec-titre { font-weight: 600; }
.dec-com { font-style: italic; }
.pastille { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.pastille-valide { background: #2ecc71; }
.pastille-rejete { background: var(--danger); }

/* --- Journal ----------------------------------------------------------- */
.journal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.runs li, .taches li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.runs li:last-child, .taches li:last-child { border-bottom: 0; }
.run-agent, .tache-titre { font-weight: 600; margin-right: 8px; }
.run-resume { margin-top: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: .92rem; line-height: 1.5; }
.run-err { margin-top: 8px; color: #ff9aa2; font-size: .88rem; }
.statut-tag { display: inline-block; font-size: .68rem; text-transform: uppercase; letter-spacing: .4px; padding: 2px 7px; border-radius: 999px; margin-right: 8px; border: 1px solid var(--line); color: var(--txt-dim); }
.statut-terminee, .statut-validee { color: #7ee6bf; border-color: #2ecc71; }
.statut-en_cours { color: #ffd08a; border-color: #f5a623; }
.tache-res { margin-top: 8px; }
.tache-res summary { cursor: pointer; color: var(--accent); font-size: .9rem; }
.tache-res > div { margin-top: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: .92rem; line-height: 1.5; }

/* --- Responsive -------------------------------------------------------- */
@media (max-width: 760px) {
    .chat { grid-template-columns: 1fr; height: auto; }
    .chat-side { order: 2; }
    .chat-main { order: 1; height: 60vh; }
    .conv-list { max-height: 180px; }
    .journal-grid { grid-template-columns: 1fr; }
}
