/* =========================================================
   App ÉQUIPE IA — feuille de style
   Identité Meti-Concept : encre profonde + or Meti (#E5CA17)
   Reprise du design system du Plan financier / Caisse.
   Type : Fraunces (titres) + Inter Tight (interface)
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Inter+Tight:wght@400;450;500;600;700&display=swap');

:root {
    --ink:        #14161b;
    --ink-1:      #2a2f3a;
    --ink-soft:   #63697a;
    --ink-faint:  #9099ab;
    --line:       #e7e4dc;
    --line-2:     #f0ede6;
    --bg:         #f6f4ee;
    --bg-warm:    #efece3;
    --surface:    #ffffff;
    --surface-2:  #fbfaf6;

    --gold:       #E5CA17;
    --gold-deep:  #c9ae06;
    --gold-soft:  #fbf4cf;
    --gold-line:  #ecdf9a;

    --green:      #1f7a4d;
    --green-soft: #e7f2ea;
    --amber:      #b5820a;
    --amber-soft: #fbf1d8;
    --red:        #b23b3b;
    --red-soft:   #f8e9e6;
    --blue:       #2563A6;
    --blue-soft:  #e8f0f8;

    --r-sm: 8px;
    --r:    12px;
    --r-lg: 18px;
    --shadow-xs: 0 1px 0 rgba(20,22,27,.03), 0 1px 2px rgba(20,22,27,.04);
    --shadow:    0 1px 1px rgba(20,22,27,.04), 0 4px 14px -6px rgba(20,22,27,.14);
    --shadow-lg: 0 20px 60px -20px rgba(20,22,27,.35), 0 4px 12px -6px rgba(20,22,27,.18);
    --ring: 0 0 0 3px rgba(229,202,23,.32);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter Tight', system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
}

a { color: var(--ink); text-decoration-color: var(--gold-line); }

h1, h2, h3 {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 600;
    letter-spacing: -.01em;
    line-height: 1.14;
    font-optical-sizing: auto;
}
h1 { font-size: 1.55rem; margin: 0 0 4px; }
h2 { font-size: 1.2rem; margin: 26px 0 12px; }
.subtitle { color: var(--ink-soft); margin: 0 0 20px; }

/* ---------- Topbar ---------- */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 clamp(14px, 4vw, 26px);
    height: 60px;
    box-shadow: var(--shadow-xs);
}
.brand { display: flex; align-items: center; gap: 13px; }
.logo-img { height: 26px; width: auto; display: block; }
.brand > div {
    display: flex; flex-direction: column; gap: 1px;
    border-left: 1px solid var(--line);
    padding-left: 13px; margin-left: 2px;
}
.brand-name { font-family: 'Fraunces', serif; font-weight: 600; font-size: 16px; letter-spacing: -.01em; line-height: 1; }
.brand-sub  { font-size: 11.5px; color: var(--ink-soft); letter-spacing: .01em; }

.mainnav { display: flex; align-items: center; gap: 2px; margin-left: 22px; }
.mainnav a {
    color: var(--ink-soft);
    text-decoration: none;
    padding: 8px 13px;
    border-radius: var(--r-sm);
    font-size: .9rem;
    font-weight: 500;
}
.mainnav a:hover { background: var(--bg-warm); color: var(--ink); }
.mainnav a.active { background: var(--ink); color: #fff; }

.spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-actions .user { font-size: .88rem; color: var(--ink-soft); display: flex; align-items: center; gap: 10px; }
.user-link { color: var(--ink); text-decoration: none; font-weight: 600; }
.badge-admin {
    background: var(--gold); color: var(--ink);
    font-size: .7rem; font-weight: 700;
    padding: 2px 9px; border-radius: 999px;
    text-transform: uppercase; letter-spacing: .05em;
}

/* ---------- Conteneur ---------- */
.wrap { max-width: 1100px; margin: 30px auto; padding: 0 clamp(14px, 4vw, 20px); }
.wrap-sm { max-width: 430px; }

/* ---------- Cartes ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-xs);
    padding: 24px;
    margin-bottom: 20px;
}

/* ---------- Hub des agents ---------- */
.hub-head { margin-bottom: 22px; }
.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}
.agent-card {
    position: relative;
    display: flex; flex-direction: column; gap: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: 3px solid var(--agent, var(--gold));
    border-radius: var(--r);
    box-shadow: var(--shadow-xs);
    padding: 20px;
    text-decoration: none;
    color: var(--ink);
    transition: transform .14s, box-shadow .14s;
}
.agent-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.agent-top { display: flex; align-items: center; gap: 12px; }
.agent-av {
    flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%;
    display: grid; place-items: center;
    font-family: 'Fraunces', serif; font-weight: 700; font-size: 1.15rem;
    color: #fff; background: var(--agent, var(--gold));
}
.agent-av-img {
    flex: 0 0 auto; border-radius: 50%; display: block;
    object-fit: cover; background: var(--bg-warm);
    box-shadow: inset 0 0 0 1px rgba(20,22,27,.06);
}
.agent-id .agent-name { font-family: 'Fraunces', serif; font-weight: 600; font-size: 1.12rem; line-height: 1.1; }
.agent-id .agent-role { font-size: .82rem; color: var(--ink-soft); }
.agent-tagline { font-size: .9rem; color: var(--ink-1); }
.agent-cta { margin-top: auto; font-size: .84rem; font-weight: 600; color: var(--agent, var(--gold-deep)); }

/* ---------- Chat ---------- */
.chat-head {
    display: flex; align-items: center; gap: 14px; margin-bottom: 18px;
}
.chat-head .agent-av { width: 48px; height: 48px; }
.chat-head .h-txt h1 { margin: 0; }
.chat-head .h-txt .role { color: var(--ink-soft); font-size: .9rem; }
.chat-head .back { margin-left: auto; }

.chat-window {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-xs);
    padding: 20px;
    min-height: 340px;
    display: flex; flex-direction: column; gap: 16px;
}
.msg { display: flex; gap: 11px; align-items: flex-start; max-width: 92%; }
.msg .bubble {
    border-radius: 12px; padding: 11px 14px; font-size: .95rem;
    white-space: pre-wrap; word-wrap: break-word;
}
.msg.user { flex-direction: row-reverse; margin-left: auto; }
.msg.user .bubble { background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.msg.agent .bubble { background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg .m-av {
    flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center; font-weight: 700; font-size: .85rem; color: #fff;
    font-family: 'Fraunces', serif;
}
.msg.user .m-av { background: var(--ink-soft); }
.msg.agent .m-av { background: var(--agent, var(--gold)); }
.m-av-img {
    flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
    display: block; object-fit: cover; background: var(--bg-warm);
    box-shadow: inset 0 0 0 1px rgba(20,22,27,.06);
}
.msg.no-source .bubble { background: var(--amber-soft); border-color: var(--gold-line); color: #8a6207; }

/* Sources sous une réponse */
.sources { margin-top: 9px; display: flex; flex-direction: column; gap: 7px; }
.sources .src-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); font-weight: 700; }
.src {
    display: block; text-decoration: none;
    border: 1px solid var(--line); border-left: 3px solid var(--gold);
    background: var(--gold-soft); border-radius: 8px; padding: 8px 11px;
    font-size: .84rem; color: var(--ink-1);
}
.src:hover { background: #fbf0c2; }
.src .src-h { font-weight: 600; color: var(--ink); }
.src .src-q { color: var(--ink-soft); font-style: italic; }
.src .src-d { color: var(--ink-faint); font-size: .78rem; }

/* Zone de saisie */
.chat-form { display: flex; gap: 10px; margin-top: 16px; align-items: flex-end; }
.chat-form textarea { resize: vertical; min-height: 46px; max-height: 200px; }
.typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); animation: blink 1.2s infinite both; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }

/* ---------- Tableaux ---------- */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
thead th {
    text-align: left; padding: 11px 12px;
    background: var(--surface-2); color: var(--ink-soft);
    font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em;
    border-bottom: 1px solid var(--line);
}
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); }
tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.pill { display: inline-block; font-size: .73rem; padding: 2px 9px; border-radius: 999px; font-weight: 600; }
.pill.live { background: var(--green-soft); color: var(--green); }
.pill.draft { background: var(--amber-soft); color: #8a6207; }
.pill.superseded { background: var(--red-soft); color: var(--red); }
.chip { display: inline-block; font-size: .72rem; padding: 1px 8px; border-radius: 999px; background: var(--bg-warm); color: var(--ink-1); margin: 1px 2px; }

/* ---------- Formulaires ---------- */
label { display: block; font-size: .84rem; font-weight: 600; margin: 15px 0 6px; color: var(--ink-1); }
input, select, textarea {
    width: 100%; padding: 10px 12px;
    border: 1px solid var(--line); border-radius: var(--r-sm);
    font-size: .95rem; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--gold-deep); box-shadow: var(--ring);
}
select {
    appearance: none; -webkit-appearance: none; -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='%2364697a'%20stroke-width='2.4'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpolyline%20points='6%209%2012%2015%2018%209'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 11px center; background-size: 16px 16px;
    padding-right: 36px; cursor: pointer;
}
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 6px; }
.checks label { display: flex; align-items: center; gap: 7px; margin: 0; font-weight: 500; }
.checks input { width: 16px; height: 16px; margin: 0; accent-color: var(--gold-deep); }

.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px; }
.pw-eye {
    position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; padding: 6px;
    color: var(--ink-soft); display: grid; place-items: center; border-radius: 6px; width: auto;
}
.pw-eye:hover { color: var(--ink); background: var(--bg-warm); }
.check { display: flex; align-items: center; gap: 9px; font-size: .9rem; font-weight: 500; color: var(--ink-1); margin: 14px 0 0; cursor: pointer; }
.check input { width: 17px; height: 17px; margin: 0; accent-color: var(--gold-deep); cursor: pointer; }

/* ---------- Boutons ---------- */
.btn {
    display: inline-block; background: var(--ink); color: #fff; border: none;
    padding: 10px 18px; border-radius: var(--r-sm);
    font-size: .92rem; font-weight: 600; font-family: inherit; cursor: pointer;
    text-decoration: none; transition: background .15s, transform .15s;
}
.btn:hover { background: #000; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn.gold { background: var(--gold); color: var(--ink); }
.btn.gold:hover { background: var(--gold-deep); }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.secondary:hover { background: var(--bg-warm); box-shadow: none; }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #8f2f2f; }
.btn.sm { padding: 6px 12px; font-size: .82rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.actions { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }

/* ---------- Alertes ---------- */
.alert { padding: 12px 16px; border-radius: var(--r-sm); margin-bottom: 18px; font-size: .92rem; border: 1px solid transparent; }
.alert.ok   { background: var(--green-soft); color: var(--green); border-color: #b7dcc5; }
.alert.err  { background: var(--red-soft); color: var(--red); border-color: #e6c3c3; }
.alert.warn { background: var(--amber-soft); color: #8a6207; border-color: var(--gold-line); }

/* ---------- Divers ---------- */
.muted { color: var(--ink-soft); }
.right { text-align: right; }
.center { text-align: center; }
.empty { text-align: center; color: var(--ink-soft); padding: 44px 0; }
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .spacer { flex: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
    .topbar { height: auto; min-height: 60px; flex-wrap: wrap; gap: 6px 10px; padding: 8px 14px; }
    .brand > div { display: none; }
    .mainnav { margin-left: 0; order: 3; width: 100%; overflow-x: auto; }
    .topbar-actions { margin-left: auto; }
    .msg { max-width: 100%; }
}
