:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --ink: #1f1e1c;
  --ink-soft: #6b6a65;
  --ink-faint: #9c9b95;
  --line: #e8e6df;
  --accent: #4f52b2;        /* indigo AgentRH, couleur de marque */
  --accent-soft: #edeef7;
  --accent-dark: #434697;
  --warn: #b8743a;
  --danger: #a8443a;
  --ok: #4a7a52;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); height: 100vh; overflow: hidden; }

.app {
  display: grid;
  grid-template-columns: 248px 1fr 320px;
  height: 100vh;
}

/* SIDEBAR */
.sidebar { background: #f3f1ea; border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; margin-bottom: 22px; text-decoration: none; }
.brand-logo { height: 26px; width: auto; display: block; }
.brand:hover { opacity: 0.8; }
.btn-new { width: 100%; padding: 9px; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; font-size: 13px; cursor: pointer; color: var(--ink); transition: background .15s; }
.btn-new:hover { background: #fff; border-color: var(--ink-faint); }
.history-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); margin: 22px 4px 8px; }
.history { list-style: none; overflow-y: auto; flex: 1; }
.history li { padding: 8px 10px; border-radius: 8px; font-size: 13px; color: var(--ink-soft); cursor: pointer; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history li:hover { background: #ece9e1; }

/* MAIN */
.main { position: relative; overflow: hidden; display: flex; flex-direction: column; height: 100vh; min-height: 0; }
.phase { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 28px 36px; min-height: 0; }
.phase.hidden { display: none; }
.phase-head { margin-bottom: 18px; flex-shrink: 0; }
.phase-head h1 { font-size: 22px; font-weight: 600; }
.phase-head .sub { color: var(--ink-soft); font-size: 14px; margin-top: 4px; }

/* THREAD (chat creation) */
.thread { flex: 1 1 auto; overflow-y: auto; padding-right: 6px; min-height: 0; }
.msg { margin-bottom: 16px; max-width: 80%; }
.msg.user { margin-left: auto; }
.msg .bubble { padding: 12px 15px; border-radius: var(--radius); font-size: 14.5px; line-height: 1.6; white-space: pre-wrap; }
.msg.ai .bubble { background: var(--surface); border: 1px solid var(--line); }
.msg.user .bubble { background: var(--accent); color: #fff; }
.msg .who { font-size: 11px; color: var(--ink-faint); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .04em; }

/* COMPOSER */
.composer { display: flex; gap: 8px; align-items: flex-end; padding-top: 14px; border-top: 1px solid var(--line); flex-shrink: 0; }

/* COMPOSANTS INTERACTIFS DU CHAT */
.ui-host { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 16px; }
.chip { padding: 9px 15px; border: 1px solid var(--accent); background: var(--surface); color: var(--accent); border-radius: 20px; font-size: 13.5px; cursor: pointer; transition: background .15s, color .15s; font-family: var(--font); }
.chip:hover { background: var(--accent); color: #fff; }
.chip-other { border-color: var(--ink-faint); color: var(--ink-soft); }
.chip-other:hover { background: var(--ink-soft); color: #fff; }
.ui-form { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.ui-form-row { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-soft); }
.ui-form-row input { padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; font-family: var(--font); font-size: 14px; outline: none; }
.ui-form-row input:focus { border-color: var(--accent); }
.ui-form-send { align-self: flex-start; margin-top: 4px; padding: 8px 18px; border: none; background: var(--accent); color: #fff; border-radius: 8px; font-size: 13.5px; cursor: pointer; }
.ui-bio { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.ui-bio textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-family: var(--font); font-size: 14px; line-height: 1.5; outline: none; resize: vertical; }
.ui-bio textarea:focus { border-color: var(--accent); }
.ui-bio-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.ui-note { width: 100%; font-size: 13px; color: var(--ink-soft); background: var(--accent-soft); padding: 10px 14px; border-radius: 8px; }
.ui-summary { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.ui-summary-title { font-weight: 600; font-size: 14px; margin-bottom: 12px; }
.ui-summary-row { display: flex; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.ui-summary-row:last-of-type { border-bottom: none; }
.ui-summary-row .k { color: var(--ink-faint); min-width: 110px; flex-shrink: 0; }
.ui-summary-row .v { color: var(--ink); }
.ui-summary .ui-note { margin-top: 12px; }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; font-family: var(--font); font-size: 14.5px; line-height: 1.4; max-height: 140px; outline: none; }
.composer textarea:focus { border-color: var(--accent); }
.btn-send { width: 42px; height: 42px; border: none; background: var(--accent); color: #fff; border-radius: 10px; font-size: 18px; cursor: pointer; flex-shrink: 0; }
.btn-send:disabled { opacity: .4; cursor: default; }

/* CALL */
.call-stage { margin: auto; text-align: center; max-width: 420px; width: 100%; }
.call-avatar { width: 96px; height: 96px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 34px; font-weight: 600; margin: 0 auto 18px; transition: box-shadow .2s; }
.call-avatar.speaking { box-shadow: 0 0 0 6px rgba(74,88,71,.15); }
.call-stage h2 { font-size: 20px; font-weight: 600; }
.call-status { color: var(--ink-soft); font-size: 13px; margin-top: 4px; }
.tension-wrap { margin: 28px 0; text-align: left; }
.tension-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
.tension-head span:last-child { font-size: 20px; font-weight: 600; color: var(--ink); }
.tension-track { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.tension-fill { height: 100%; width: 0%; background: var(--warn); transition: width .5s, background .5s; }
.tension-mood { font-size: 12px; color: var(--ink-soft); margin-top: 6px; }
.call-controls { display: flex; gap: 10px; justify-content: center; margin-top: 8px; }
.btn-mic { padding: 10px 16px; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; cursor: pointer; font-size: 13px; }
.btn-end { padding: 10px 16px; border: none; background: var(--danger); color: #fff; border-radius: 9px; cursor: pointer; font-size: 13px; }
.call-hint { font-size: 12px; color: var(--ink-faint); margin-top: 16px; }

/* REPORT */
.report-body { flex: 1; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 26px; font-size: 14px; line-height: 1.6; }
.report-loading { color: var(--ink-soft); font-style: italic; padding: 20px 0; }
.report h3 { font-size: 14px; color: var(--accent); margin: 0 0 10px; padding-bottom: 5px; border-bottom: 2px solid var(--accent); }
.rep-section { margin-bottom: 22px; }
.rep-hero { display: flex; gap: 18px; align-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 20px; }
.rep-score { flex: none; width: 92px; height: 92px; border-radius: 50%; border: 4px solid; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.rep-score-num { font-size: 32px; font-weight: 800; line-height: 1; }
.rep-score-max { font-size: 11px; color: var(--ink-faint); }
.rep-appreciation { font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.rep-objectif { font-size: 12.5px; color: var(--ink-soft); }
.rep-traj { color: var(--ink-soft); font-size: 13px; }
.ss-grid { display: flex; flex-direction: column; gap: 8px; }
.ss-row { display: flex; align-items: center; gap: 10px; }
.ss-label { width: 150px; font-size: 12.5px; color: var(--ink-soft); flex: none; }
.ss-bar { flex: 1; height: 9px; background: var(--accent-soft); border-radius: 5px; overflow: hidden; }
.ss-fill { display: block; height: 100%; background: var(--accent); border-radius: 5px; transition: width .6s ease; }
.ss-val { width: 28px; text-align: right; font-weight: 700; font-size: 12.5px; color: var(--ink); flex: none; }
.rep-item { border: 1px solid var(--line); border-left-width: 3px; border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.rep-item.good { border-left-color: #4a5847; }
.rep-item.warn { border-left-color: #c98b3c; }
.rep-item-head { font-size: 13px; margin-bottom: 5px; }
.rep-tag { display: inline-block; font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 1px 6px; border-radius: 4px; margin-right: 4px; }
.rep-item-body { font-size: 12.5px; color: var(--ink-soft); }
.rep-item-body p { margin: 4px 0; }
.rep-reformule { color: var(--ink); }
.rep-rh { border: 1px solid var(--line); border-left: 3px solid #9c6233; border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; background: var(--bg); }
.rep-rh-sujet { font-weight: 600; font-size: 13px; margin-bottom: 3px; }
.rep-rh-rappel { font-size: 12.5px; color: var(--ink-soft); }
.rep-empty { color: var(--ink-faint); font-style: italic; }
.rep-conseil { background: var(--accent); color: #fff; border-radius: 10px; padding: 14px 16px; font-size: 14px; font-weight: 600; margin-top: 6px; }
.rep-conseil-label { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; opacity: .85; margin-bottom: 4px; font-weight: 400; }
/* Historique groupe par persona */
.hist-persona { display: flex; justify-content: space-between; align-items: center; cursor: pointer; gap: 6px; }
.hist-count { font-size: 10px; color: var(--ink-faint); flex: none; }
.hist-sessions { list-style: none; margin: 0 0 4px; padding: 0; max-height: 0; overflow: hidden; transition: max-height .25s ease; }
.hist-persona.open + .hist-sessions { max-height: 300px; }
.hist-sessions li { display: flex; justify-content: space-between; padding: 5px 10px 5px 18px; font-size: 11.5px; color: var(--ink-soft); cursor: pointer; border-radius: 6px; }
.hist-sessions li:hover { background: var(--accent-soft); }
.hist-score { font-weight: 700; color: var(--accent); }
.report-actions { display: flex; gap: 10px; margin-top: 1.5rem; flex-shrink: 0; }
.report-actions button { margin: 0; }

/* PERSONA PANEL */
.persona-panel { background: #f3f1ea; border-left: 1px solid var(--line); display: flex; flex-direction: column; height: 100vh; min-height: 0; }
.panel-head { padding: 16px 18px; font-weight: 600; font-size: 14px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.panel-body { padding: 16px 18px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.panel-body label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); margin-bottom: 13px; }
.panel-body input, .panel-body select, .panel-body textarea { width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-family: var(--font); font-size: 13.5px; color: var(--ink); background: var(--surface); text-transform: none; letter-spacing: normal; outline: none; resize: none; }
.panel-body input:focus, .panel-body select:focus, .panel-body textarea:focus { border-color: var(--accent); }
.panel-body hr { border: none; border-top: 1px solid var(--line); margin: 4px 0 16px; }
.field-hint { display: block; font-size: 11px; text-transform: none; letter-spacing: normal; color: var(--ink-faint); font-style: italic; margin: 2px 0 5px; line-height: 1.4; }
.combo-free { width: 100%; }
.ui-launch-inline { width: 100%; margin-top: 12px; padding: 11px; border: none; background: var(--accent); color: #fff; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; }
.ui-launch-inline:disabled { opacity: .4; cursor: default; }
.btn-launch { margin: 14px 18px 18px; padding: 12px; border: none; background: var(--accent); color: #fff; border-radius: 10px; font-size: 14px; font-weight: 500; cursor: pointer; flex-shrink: 0; transition: background .15s; }
.btn-launch:hover { background: var(--accent-dark); }
.btn-launch:disabled { opacity: .4; cursor: default; }

/* Barre d'onglets mobile : masquee sur desktop */
.mobile-tabs { display: none; }

@media (max-width: 1000px) {
  /* Layout empile : chaque panneau prend tout l'ecran, on bascule par onglets */
  .app { grid-template-columns: 1fr; height: 100vh; }

  /* Tous les panneaux superposes, masques par defaut */
  .sidebar, .persona-panel {
    position: fixed;
    top: 0; left: 0; right: 0;
    bottom: 52px;            /* laisse la place a la barre d'onglets */
    z-index: 30;
    height: auto;
    overflow-y: auto;
    display: none;
  }
  .main {
    position: fixed;
    top: 0; left: 0; right: 0;
    bottom: 52px;
    height: auto;
    z-index: 20;
    display: flex;
  }

  /* Le panneau actif (pilote par JS via la classe sur <body>) */
  body.panel-sidebar .sidebar { display: flex; z-index: 40; }
  body.panel-persona .persona-panel { display: flex; z-index: 40; }
  body.panel-main .main { display: flex; }
  /* quand un panneau lateral est ouvert, le main reste dessous */

  /* Barre d'onglets fixe en bas */
  .mobile-tabs {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 52px;
    background: var(--surface);
    border-top: 1px solid var(--line);
    z-index: 50;
  }
  .mtab {
    flex: 1;
    border: none;
    background: none;
    font-family: var(--font);
    font-size: 12px;
    color: var(--ink-soft);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-top: 2px solid transparent;
  }
  .mtab.active { color: var(--accent); border-top-color: var(--accent); font-weight: 600; }

  /* Ajustements de confort tactile et lisibilite */
  .phase { padding: 16px 14px; }
  .sidebar { padding: 16px 14px; }
  .composer textarea { font-size: 16px; }   /* evite le zoom auto iOS */
}

/* ===== TABLEAU DE BORD LIVE (visuels riches) ===== */
.live-dashboard.hidden { display: none; }
.live-dashboard { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.dash-body { padding: 16px; display: flex; flex-direction: column; gap: 22px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.dash-block { display: flex; flex-direction: column; gap: 8px; }
.dash-label { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; color: var(--ink-soft); font-weight: 500; }
.dash-val { font-size: 12px; color: var(--ink); font-weight: 600; }
.dash-foot { font-size: 10.5px; color: var(--ink-faint); line-height: 1.5; margin-top: 2px; border-top: 1px solid var(--line); padding-top: 12px; }

/* Courbe de tension */
.curve-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px; height: 120px; }
#tension-curve { width: 100%; height: 100%; display: block; }
.curve-line { transition: d .4s ease; }
.curve-evt-dot { stroke: #fff; stroke-width: 1.5; }

/* ZONE 1 : Nudges actionnables */
.nudges { display: flex; flex-direction: column; gap: 7px; min-height: 20px; }
.nudge-empty { font-size: 11px; color: var(--ink-faint); font-style: italic; padding: 4px 0; }
.nudge { display: flex; align-items: flex-start; gap: 8px; padding: 9px 11px; border-radius: 9px; font-size: 12px; line-height: 1.35; border: 1px solid; animation: nudgeIn .3s ease; }
.nudge-icon { flex: none; font-size: 13px; line-height: 1.2; }
.nudge.info { background: #f3f1e8; border-color: #e0dcc8; color: #6b5d3a; }
.nudge.warn { background: #fbf0e6; border-color: #e8c9a8; color: #9c6233; }
.nudge.good { background: #eef3ea; border-color: #c5d6b8; color: #4a5847; }
.nudge.alert { background: #fae9e2; border-color: #e3b3a0; color: #c0552f; }
@keyframes nudgeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* ZONE 2 : Barre d'equilibre de parole */
.parole-bar { display: flex; height: 22px; border-radius: 7px; overflow: hidden; border: 1px solid var(--line); }
.parole-you { background: var(--accent); transition: width .5s ease; min-width: 0; }
.parole-them { background: #c98b3c; transition: width .5s ease; min-width: 0; }
.parole-legend { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--ink-soft); margin-top: 4px; }

/* ZONE 3 : Timeline des moments cles */
.timeline { display: flex; flex-direction: column; gap: 0; position: relative; }
.tl-empty { font-size: 11px; color: var(--ink-faint); font-style: italic; padding: 4px 0; }
.tl-item { display: flex; gap: 10px; padding: 6px 0; position: relative; }
.tl-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 3px; border: 2px solid var(--bg); z-index: 1; }
.tl-item:not(:last-child)::before { content: ""; position: absolute; left: 4px; top: 12px; bottom: -6px; width: 2px; background: var(--line); }
.tl-body { flex: 1; }
.tl-time { font-size: 10px; color: var(--ink-faint); }
.tl-label { font-size: 12px; color: var(--ink); line-height: 1.3; }
.tl-dot.braque { background: #c0552f; }
.tl-dot.ouvre { background: #4a5847; }
.tl-dot.info { background: #c98b3c; }

#persona-fiche.hidden { display: none; }
#persona-fiche { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
