/* Tableau de bord SAV Docdialy Care.
 *
 * ⭐ Couleurs de Docdialy, pas d'autres. Mesurees dans le CSS calcule du logiciel
 * praticien : en-tete turquoise #50C6D9, rail en degrade turquoise vers vert #A8D59C,
 * Roboto partout. Le bleu #006293 vient de la charte du site.
 *
 * La disposition, elle, reste celle du tableau de bord des operatrices Beauty Market :
 * rail a gauche, barre de filtres, table qui se replie quand un detail s'ouvre.
 * On copie la FORME de ce qui marche, pas ses couleurs.
 */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

:root {
  --bg: #F4FAFF;
  --panel: #ffffff;
  --ink: #333333;
  --muted: #6C6C6C;
  --line: #E3EAEF;

  --bleu: #006293;
  --bleu-fonce: #004b71;
  --cyan: #1D92B3;
  --turquoise: #50C6D9;
  --vert-app: #A8D59C;
  --jaune: #DBBE04;

  /* Les trois etats gardent la forme de Beauty Market -- un fond pale, une encre
     soutenue de la meme famille -- mais dans les teintes de Docdialy. */
  --danger: #9c2b45;      --etat-rouge-bg: #FDECF0;
  --warn: #6b5c02;        --etat-ambre-bg: #FDF6D8;
  --ok: #3d6b33;          --etat-vert-bg: #EDF6EA;

  --rail: linear-gradient(197deg, #50C6D9 0%, #A8D59C 100%);
  --rail-fg: #ffffff;
  --rail-dim: rgba(255, 255, 255, .82);
  --rail-hover: rgba(255, 255, 255, .18);
  --rail-actif: rgba(255, 255, 255, .30);

  --shadow: 0 1px 2px rgba(0, 62, 94, .06), 0 8px 24px rgba(0, 62, 94, .08);
}

* { box-sizing: border-box; }

/* L'attribut hidden a une specificite quasi nulle : le moindre display:flex ecrit
   ensuite le neutralise, et deux ecrans se superposent sans que rien ne le signale. */
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Roboto, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: ui-monospace, 'Roboto Mono', monospace; }

/* ⛔ Les styles de l'écran de connexion ont été retirés avec l'écran lui-même :
   la connexion se fait sur la page d'entrée, une seule fois. Du CSS orphelin finit
   toujours par être recopié ailleurs « parce qu'il existe ». */

/* --------------------------------------------------------------- la charpente */

.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }

.rail {
  position: sticky; top: 0;
  height: 100vh;
  background: var(--rail);
  color: var(--rail-fg);
  background-attachment: fixed;
  padding: 18px 14px;
  display: flex; flex-direction: column;
}
.rail .marque { display: flex; align-items: center; gap: 10px; padding: 8px 10px 18px; font-weight: 700; }
.rail .marque small { display: block; font-weight: 400; font-size: 11px; color: var(--rail-dim); }
.marque-texte { display: flex; flex-direction: column; gap: 3px; }
.rail .logo-image { height: 20px; }
#form-connexion .logo-image { height: 26px; }

.nav-section {
  margin: 16px 0 6px; padding: 0 10px;
  color: var(--rail-dim);
  font-size: 11px; font-weight: 700; letter-spacing: .4px;
  text-transform: uppercase;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: 0; background: none;
  border-radius: 8px;
  color: var(--rail-fg);
  font-size: 13.5px;
  cursor: pointer; text-align: left;
}
.nav-link:hover { background: var(--rail-hover); }
.nav-link.actif { background: var(--rail-actif); font-weight: 600; }
.nav-link .compte {
  margin-left: auto;
  min-width: 21px; padding: 1px 6px;
  border-radius: 10px;
  background: var(--bleu); color: #fff;
  font-size: 11px; font-weight: 700; text-align: center;
}
.nav-link .compte.zero { background: rgba(255, 255, 255, .14); color: var(--rail-dim); }

.rail-pied { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .12); }
.moi { display: flex; align-items: center; gap: 9px; padding: 8px 10px 10px; font-size: 13px; }
.point { width: 8px; height: 8px; border-radius: 50%; background: var(--rail-dim); flex: none; }
.point.en-ligne { background: #4ade80; }

/* ------------------------------------------------------------------ le corps */

.main { min-width: 0; display: flex; flex-direction: column; }
.page-entete { padding: 20px 24px 12px; }
.page-entete h1 { margin: 0; font-size: 21px; font-weight: 600; }
.page-entete p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.page { padding: 0 24px 24px; display: flex; flex-direction: column; gap: 13px; flex: 1; min-height: 0; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card.pad { padding: 14px 16px; }

/* les trois grandes cartes d'escalade, cliquables : elles servent de filtre */
.grille-trois { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.stat-escalade {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px 16px;
  text-align: left; cursor: pointer;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 0 12px 12px 0;
  box-shadow: var(--shadow);
}
.stat-escalade strong { font-size: 28px; font-weight: 600; line-height: 1; }
.stat-escalade span { font-size: 12px; color: var(--muted); line-height: 1.5; }
.stat-escalade b { font-size: 13px; }

/* barre de filtres */
.filtres {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: #fafbfc; border: 1px solid var(--line); border-radius: 10px;
}
.filtres input[type="search"] {
  flex: 1 1 220px; min-width: 170px;
  padding: 7px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.filtres select { padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 13px; cursor: pointer; }
.compteur-vue { font-size: 12px; color: var(--muted); font-weight: 600; }

.button {
  padding: 6px 13px;
  border: 1px solid var(--line); border-radius: 20px;
  background: #fff;
  font-size: 12.5px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.button:hover:not(:disabled) { border-color: #b9c2d0; background: #fbfcfd; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button.principal { background: var(--bleu); border-color: var(--bleu); color: #fff; }
.button.principal:hover:not(:disabled) { background: var(--bleu-fonce); }
.button.vert { color: var(--ok); border-color: #b9dcc5; }
.button.rouge { color: var(--danger); border-color: #edc6d0; }

/* la table, puis le detail : pleine largeur tant que rien n'est choisi */
.split { display: grid; grid-template-columns: 1fr; gap: 14px; min-height: 0; }
.split.ouvert { grid-template-columns: minmax(300px, 38%) minmax(0, 1fr); }

.enveloppe-table { max-height: calc(100vh - 250px); overflow: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 600; font-size: 11px; letter-spacing: .3px;
  text-transform: uppercase; color: var(--muted);
  padding: 9px 12px; background: #fafbfc; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1;
}
.table td { padding: 10px 12px; border-bottom: 1px solid #eef1f5; vertical-align: top; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: #fafbfc; }
.table tbody tr.choisie { background: #EAF4F9; }
.table tbody tr.choisie td:first-child { box-shadow: inset 3px 0 0 var(--bleu); }

.table td .sous { display: block; margin-top: 2px; }
.ref { font-size: 11px; font-weight: 500; color: var(--cyan); letter-spacing: .3px; display: block; margin-top: 2px; }
.colonne-heure { font-size: 12px; color: var(--ink); white-space: nowrap; width: 1%; }
.colonne-heure .sous { font-size: 11px; }
.qui-soccupe { font-size: 12.5px; font-weight: 500; margin-bottom: 3px; }
.colonne-etat { white-space: nowrap; width: 1%; }
.colonne-etat .badge + .badge { margin-left: 4px; }
.colonne-attente { font-size: 12px; color: var(--muted); white-space: nowrap; width: 1%; text-align: right; }
.colonne-attente.presse { color: var(--danger); font-weight: 500; }
.sous { font-size: 11.5px; color: var(--muted); }
.tronque { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px;
  background: #eef1f5; color: var(--muted);
  white-space: nowrap;
}
.badge.nouveau { background: var(--etat-rouge-bg); color: var(--danger); }
.badge.prise_en_charge { background: var(--etat-ambre-bg); color: var(--warn); }
.badge.attente_medecin { background: #E4F5F8; color: #175e6b; }
.badge.resolu { background: var(--etat-vert-bg); color: var(--ok); }
.badge.remonte { background: var(--etat-rouge-bg); color: var(--danger); font-weight: 700; }
.badge.non-lus { background: var(--bleu); color: #fff; }

.vide { padding: 32px 16px; text-align: center; color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------------ le detail */

.detail { position: sticky; top: 14px; align-self: start; display: flex; flex-direction: column; max-height: calc(100vh - 28px); }
.detail-entete {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 10px 13px; border-bottom: 1px solid var(--line); background: #fafbfc;
}
.nav-fleches { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.position { font-size: 11px; color: var(--muted); min-width: 44px; text-align: center; }

.identite { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.initiales {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: #E4F5F8; color: var(--bleu);
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.identite strong { font-size: 14px; font-weight: 600; display: block; }

.actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.actions .separateur { width: 1px; height: 20px; background: var(--line); }
.titre-mini { font-size: 11px; color: var(--muted); }

.alerte { margin: 0; padding: 9px 14px; background: var(--etat-ambre-bg); color: var(--warn); font-size: 12.5px; }

.fil { flex: 1; overflow-y: auto; padding: 15px; display: flex; flex-direction: column; gap: 10px; background: #fbfcfd; min-height: 220px; }
.msg { max-width: 76%; display: flex; flex-direction: column; gap: 3px; }
.msg-corps { padding: 9px 12px; font-size: 13.5px; line-height: 1.55; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-meta { font-size: 10.5px; color: var(--muted); }
.msg.de-medecin .msg-corps { background: var(--bleu); color: #fff; border-bottom-left-radius: 3px; }
.msg.de-agent { align-self: flex-end; align-items: flex-end; }
.msg.de-agent .msg-corps { background: #fff; color: var(--ink); border: 1px solid var(--line); border-bottom-right-radius: 3px; }
.msg.de-agent.en-attente .msg-corps { background: #f4f7f9; color: var(--muted); }
.msg.de-systeme { align-self: center; max-width: 100%; }
.msg.de-systeme .msg-corps { background: transparent; color: var(--muted); font-size: 11.5px; padding: 2px 0; text-align: center; }
.msg-capture { padding: 4px; }
.msg-capture img { display: block; max-width: 300px; max-height: 280px; border-radius: 8px; cursor: zoom-in; }
.msg-capture .msg-texte { display: block; padding: 6px 9px 4px; }
.jour { align-self: center; font-size: 10.5px; color: var(--muted); }
.frappe { font-size: 12px; color: var(--muted); font-style: italic; padding: 0 15px 6px; }

.corps-detail { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 176px; min-height: 0; }
.colonne-fil { display: flex; flex-direction: column; min-height: 0; }
.colonne-reponses {
  border-left: 1px solid var(--line);
  padding: 10px 10px 12px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
  background: #FBFDFE;
}
.colonne-reponses #puces-reponses { display: flex; flex-direction: column; gap: 5px; }
.entete-reponses { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.bouton-plus {
  width: 22px; height: 22px; flex: none;
  border: 0; border-radius: 6px;
  background: var(--bleu); color: #fff;
  font-size: 15px; line-height: 1; cursor: pointer;
}
.bouton-plus:hover { background: var(--bleu-fonce); }

.ligne-reponse { display: flex; align-items: stretch; gap: 3px; }
.ligne-reponse .puce { flex: 1; min-width: 0; }
.crayon {
  flex: none; width: 22px;
  border: 0; border-radius: 6px;
  background: transparent; color: var(--muted);
  font-size: 12px; cursor: pointer;
}
.crayon:hover { background: #E4F5F8; color: var(--bleu); }

#form-reponse { display: flex; flex-direction: column; gap: 5px; margin-bottom: 4px; }
#form-reponse input, #form-reponse textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px;
  font-size: 12px; background: #fff; resize: vertical;
}
.actions-reponse { display: flex; flex-wrap: wrap; gap: 4px; }
.actions-reponse .button { padding: 4px 9px; font-size: 11.5px; }
.puce {
  font-size: 11.5px; padding: 6px 10px; border-radius: 8px;
  background: #E4F5F8; color: var(--bleu); border: 0; cursor: pointer;
  text-align: left; line-height: 1.35;
}
.puce:hover { background: var(--bleu); color: #fff; }

@media (max-width: 980px) {
  .corps-detail { grid-template-columns: 1fr; }
  .colonne-reponses { border-left: 0; border-top: 1px solid var(--line); flex-direction: row; flex-wrap: wrap; max-height: 92px; }
  .colonne-reponses #puces-reponses { flex-direction: row; flex-wrap: wrap; }
}

.composeur { display: flex; align-items: flex-end; gap: 8px; padding: 10px 14px 12px; border-top: 1px solid var(--line); }
.composeur .bouton-plus { width: 34px; height: 34px; font-size: 19px; border-radius: 10px; }

#apercu-capture { position: relative; display: inline-block; margin: 8px 0 0 14px; }
#apercu-image { max-height: 84px; border-radius: 8px; border: 1px solid var(--line); display: block; }
#retirer-capture {
  position: absolute; top: -7px; right: -7px;
  width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 15px; line-height: 1; cursor: pointer;
}
#erreur-envoi { padding: 0 14px 8px; margin: 0; }
.composeur textarea {
  flex: 1; resize: none; max-height: 130px;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13.5px; line-height: 1.45; background: #fff;
}
.composeur textarea:disabled { background: #f4f6f8; color: var(--muted); }

#loupe {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 62, 94, .82);
  display: flex; align-items: center; justify-content: center; padding: 26px; cursor: zoom-out;
}
#loupe img { max-width: 100%; max-height: 100%; border-radius: 10px; }

@media (max-width: 1100px) {
  .split.ouvert { grid-template-columns: 1fr; }
  .detail { position: static; max-height: none; }
}
@media (max-width: 640px) {
  .app-shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px; padding: 10px; }
  .rail .marque { padding: 0 10px 0 0; }
  .nav-section { display: none; }
  .nav-link { width: auto; }
  .rail-pied { margin: 0 0 0 auto; border: 0; padding: 0; }
  .enveloppe-table { max-height: none; }
}

/* Le bandeau de démonstration — voyant, et c'est voulu : il doit être impossible de
   prendre une conversation inventée pour un vrai cas. */
#bandeau-demo {
  flex: none;
  background: #FEF3C7; color: #92400E;
  border-bottom: 1px solid #FDE68A;
  padding: 8px 26px;
  font-size: 12.5px; font-weight: 500;
  letter-spacing: .01em;
}
