/* Smilo 1.10.30 — surface d'intégration e-LAB
   Le portail e-LAB reste maître de son propre contenu. Cette feuille habille
   uniquement le contexte Smilo, sans cadre concurrent autour de l'iframe. */

.elab-root {
  --elab-control-h: 38px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 132px);
  height: calc(100dvh - 132px);
  min-height: 420px;
  color: var(--text, #0f172a);
  font-size: 14px;
}

.elab-head {
  display: grid;
  grid-template-columns: minmax(225px, .65fr) minmax(0, 3.35fr);
  align-items: center;
  gap: 18px;
  box-sizing: border-box;
  width: 100%;
  max-width: 1240px;
  margin-right: auto;
  margin-bottom: 10px;
  margin-left: auto;
  padding: 12px 14px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 14px;
  background: var(--card, #fff);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .055);
}

.elab-heading {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.elab-brandmark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: auto;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: inherit;
  font-size: 22px;
  line-height: 1;
}

.elab-empty-ico svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.elab-heading-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.elab-title {
  overflow: hidden;
  color: var(--text, #0f172a);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.elab-subtitle {
  overflow: hidden;
  color: var(--text3, #64748b);
  font-size: 11.5px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.elab-actions {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.elab-control {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: var(--text3, #64748b);
}

.elab-control-label {
  padding-left: 2px;
  color: var(--text3, #64748b);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .055em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.elab-control--lab { flex: 1 1 190px; min-width: 160px; max-width: 230px; }
.elab-pick { flex: 1.15 1 225px; min-width: 210px; max-width: 285px; }
.elab-control--patient { flex: 1.5 1 310px; min-width: 280px; max-width: 390px; }

.elab-select,
.elab-inp,
.elab-labname,
.elab-pat-chip,
.elab-btn {
  box-sizing: border-box;
  min-height: var(--elab-control-h);
  border: 1px solid var(--border2, #d1d5db);
  border-radius: 10px;
  background: var(--card, #fff);
  color: var(--text, #0f172a);
  font: inherit;
  font-size: 13px;
}

.elab-select,
.elab-inp {
  width: 100%;
  padding: 7px 30px 7px 10px;
  outline: none;
}

.elab-inp { padding-right: 10px; }

.elab-select:hover,
.elab-inp:hover,
.elab-btn:hover {
  border-color: rgba(var(--primary-rgb, 255, 110, 22), .62);
}

.elab-select:focus-visible,
.elab-inp:focus-visible,
.elab-btn:focus-visible,
.elab-x:focus-visible,
.elab-pat-row:focus-visible {
  outline: 3px solid rgba(var(--primary-rgb, 255, 110, 22), .18);
  outline-offset: 1px;
  border-color: var(--primary, #ff6e16);
}

.elab-labname {
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: 7px 11px;
  background: var(--bg2, #f8fafc);
  color: var(--text2, #475569);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.elab-pat-wrap {
  position: relative;
  display: block;
  min-width: 0;
}

.elab-pat-inp { width: 100%; }

.elab-pat-res {
  position: absolute;
  z-index: 80;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  min-width: 260px;
  max-height: 310px;
  overflow: auto;
  padding: 5px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  background: var(--card, #fff);
  box-shadow: 0 18px 42px rgba(15, 23, 42, .16);
}

.elab-pat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 38px;
  padding: 7px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text, #0f172a);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.elab-pat-row:hover { background: var(--hover, #f1f5f9); }
.elab-pat-dob { color: var(--text3, #64748b); font-size: 11.5px; font-weight: 400; white-space: nowrap; }
.elab-pat-empty { padding: 11px 10px; color: var(--text3, #64748b); font-size: 12.5px; }

.elab-pat-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  overflow: hidden;
  padding: 5px 7px 5px 11px;
  background: var(--bg2, #f8fafc);
  color: var(--text2, #475569);
}

.elab-pat-chip b {
  overflow: hidden;
  color: var(--text, #0f172a);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.elab-x {
  display: grid;
  place-items: center;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text3, #64748b);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.elab-x:hover { background: var(--card, #fff); color: var(--danger, #b91c1c); }

.elab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  color: var(--text2, #475569);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.elab-btn:hover { color: var(--primary-dark, #e55a00); }
.elab-btn-main { margin-top: 12px; border-color: var(--primary, #ff6e16); background: var(--primary, #ff6e16); color: #fff; }
.elab-btn-main:hover { border-color: var(--primary-dark, #e55a00); background: var(--primary-dark, #e55a00); color: #fff; }
.elab-select-lg { min-width: 220px; margin: 11px 0 0; padding: 9px 12px; font-size: 14px; }

.elab-body {
  position: relative;
  flex: 1;
  min-height: 340px;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.elab-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
}

.elab-msg {
  padding: 24px 12px;
  color: var(--text3, #64748b);
  font-size: 13px;
  text-align: center;
}

.elab-msg.err {
  margin-top: 12px;
  border: 1px solid #fecaca;
  border-radius: 12px;
  background: #fef2f2;
  color: #991b1b;
}

.elab-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.elab-wait {
  position: absolute;
  inset: 0;
  background: var(--card, #fff);
}

.elab-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border2, #d1d5db);
  border-top-color: var(--primary, #ff6e16);
  border-radius: 50%;
  animation: elab-spin .75s linear infinite;
}

@keyframes elab-spin { to { transform: rotate(360deg); } }

.elab-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  color: var(--text3, #64748b);
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
}

.elab-empty-ico {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 12px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 14px;
  background: var(--bg2, #f8fafc);
  color: var(--primary, #ff6e16);
}

.elab-empty b { display: block; margin-bottom: 5px; color: var(--text2, #475569); font-size: 15px; }
.elab-empty > div:not(.elab-empty-ico) { max-width: 480px; }

/* Onglet Labo d'une fiche patient : même langage visuel, densité adaptée. */
.elab-root.elab-inline { height: auto; min-height: 0; }
.elab-root.elab-inline .elab-body { flex: none; height: min(62vh, 560px); min-height: 300px; }

/* Pont v1.20.16 : réutiliser une pièce déjà rangée dans le dossier patient.
   La barre reste hors de l'iframe : le consentement est donné dans Smilo,
   puis e-LAB reçoit les File et les place dans son formulaire de commande. */
.elab-docbar {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 6px;
  padding: 0 4px;
}
.elab-docshare { min-height: 32px; padding: 5px 10px; font-size: 12px; }
.elab-docstatus {
  overflow: hidden;
  color: var(--text3, #64748b);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ⛔⛔ v1.10.320 — [Jacob] « ici pourquoi on ne profite pas de toute la
   fenetre ? ». Parce que le portail se voyait attribuer 62 % de la
   hauteur de L'ECRAN — une fraction choisie a l'aveugle, sans rapport
   avec la place que la fenetre lui laisse REELLEMENT.

   ★★ ET LA FENETRE, ELLE, CONNAIT SA TAILLE : la modale de l'espace
     patient a une hauteur FIXE (min(92dvh, 1100px)) et son corps porte
     deja flex:1. Il suffit que ce corps devienne une COLONNE pour que le
     portail prenne ce qui reste sous les onglets et la ligne du labo.
     Aucune fraction a deviner : la place restante est le resultat d'un
     calcul que le navigateur fait deja.

   ⚠️ `:has()` ET C'EST DELIBERE : la regle ne doit s'appliquer QUE sur
      l'onglet Labo. Les autres onglets (Soins, Documents, RDV) doivent
      continuer de couler et de defiler normalement — les passer en
      colonne etirerait leur contenu.
   ★ ET C'EST UNE DEGRADATION DOUCE : un navigateur qui ne connait pas
     `:has()` ignore ces trois regles et garde le comportement
     d'aujourd'hui. On ne perd rien, on n'ajoute pas de repli a
     maintenir. */
.modal.pspace > .mb:has(.elab-inline) {
  display: flex;
  flex-direction: column;
}
.modal.pspace > .mb:has(.elab-inline) .elab-root.elab-inline {
  flex: 1 1 auto;
  min-height: 0;   /* sans lui, l'enfant pousse le parent au lieu de defiler */
}
.modal.pspace > .mb:has(.elab-inline) .elab-root.elab-inline .elab-body {
  flex: 1 1 auto;
  height: auto;
  /* ⚠️ Un plancher quand meme : sur un ecran tres bas, un cadre de 40px
     ne serait pas un portail, ce serait une fente. La fenetre defile
     alors, ce qui est le comportement attendu. */
  min-height: 220px;
}
.elab-head--inline { grid-template-columns: 1fr; padding: 10px 11px; border-radius: 11px; box-shadow: none; }

/* ★ v1.10.315 — Le bloc Laboratoire / Praticien, REPLIE par defaut dans
   l'onglet d'une fiche patient. Sur un telephone il prenait la moitie de
   la hauteur pour deux listes qu'on ne touche presque jamais. */
/* ⛔ v1.10.318 — [Jacob] « tu as oublie de reduire la hauteur du champ
   (nom labo - nom dentiste) ».
   ★ CE N'ETAIT PAS LA LIGNE, C'ETAIT CE QU'IL Y AVAIT AUTOUR : le bloc
     herite de `.elab-head`, qui porte `margin-bottom: 10px` — un espace
     pense pour une CARTE, alors que ce n'est plus qu'une ligne. Le
     padding du resume a suivi (6px -> 4px). ~14px rendus a l'ecran. */
.elab-repli { display: block; padding: 0; margin-bottom: 4px; }
.elab-repli-sum {
  display: flex;
  align-items: center;
  gap: 8px;
  /* ★ v1.10.316 — UNE LIGNE, ET RIEN DE PLUS. [Jacob] « ce cadre peut
     etre reduit a une ligne, il prend encore beaucoup trop de place sur
     l'ecran d'un tel ». 9px de haut -> 6px, et la bordure du cadre s'en
     va : le bloc n'est plus une carte, c'est une ligne de reglage. */
  padding: 4px 10px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text2, #475569);
  list-style: none;
}
/* Le cadre disparait quand le bloc est ferme : il entourait du vide. */
.elab-repli:not([open]) { border: 0; background: transparent; }
/* Safari dessine son propre triangle en plus du notre. */
.elab-repli-sum::-webkit-details-marker { display: none; }
.elab-repli-ico {
  color: var(--text3, #94a3b8);
  font-size: 11px;
  transition: transform .15s ease;
}
.elab-repli[open] .elab-repli-ico { transform: rotate(90deg); }
/* ★ LE LABO A GAUCHE, LE DENTISTE A DROITE — l'idee de Jacob.
   Les deux noms se ressemblent (« Esthetica Dental », « Dr. Dentasoft
   Jacob ») : c'est la PLACE qui dit lequel est lequel, pas une
   etiquette qu'il faudrait lire. */
.elab-repli-lab {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text, #1f2937);
}
.elab-repli-prov {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
  color: var(--text2, #475569);
}
/* Aucun praticien choisi : on le montre au lieu de le taire. */
.elab-repli-prov.elab-repli-vide { color: var(--primary, #ff6e16); font-weight: 600; }
.elab-repli .elab-actions { padding: 0 11px 11px; }
.elab-head--inline .elab-actions { justify-content: flex-start; }
.elab-head--inline .elab-control--patient { display: none; }

.elab-soins-bar { display: flex; justify-content: flex-end; margin-bottom: 10px; }

/* Configuration e-LAB dans Paramètres. */
.elab-cfg { display: block; height: auto; min-height: 0; }
.elab-help { margin-bottom: 14px; color: var(--text2, #475569); font-size: 13px; line-height: 1.6; }
.elab-warn { margin-bottom: 14px; padding: 12px 14px; border: 1px solid #fecaca; border-radius: 10px; background: #fef2f2; color: #991b1b; font-size: 13px; }
.elab-opt { margin-top: 14px; padding: 11px 13px; border: 1px solid var(--border, #e5e7eb); border-radius: 10px; background: var(--card, #fff); }
.elab-opt label { display: flex; align-items: flex-start; gap: 10px; margin: 0; font-size: 13.5px; cursor: pointer; }
.elab-opt input { flex: none; margin-top: 2px; }
.elab-opt-h { color: var(--text3, #64748b); font-size: 12.5px; }
.elab-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.elab-table { width: 100%; min-width: 400px; border-collapse: collapse; font-size: 13px; }
.elab-table th { padding: 8px 10px; border-bottom: 2px solid var(--border, #e5e7eb); color: var(--text2, #475569); font-weight: 600; text-align: left; white-space: nowrap; }
.elab-table td { padding: 9px 10px; border-bottom: 1px solid var(--border, #e5e7eb); }
.elab-table code { padding: 1px 5px; border-radius: 4px; background: var(--bg2, #f8fafc); font-size: 12px; }
.elab-mini { min-height: 30px; padding: 4px 9px; font-size: 12px; }
.elab-grid { display: grid; grid-template-columns: 230px 1fr; align-items: center; gap: 10px 14px; }
.elab-grid label { color: var(--text2, #475569); font-size: 13px; }
.elab-inp:disabled { background: var(--bg2, #f1f5f9); color: var(--text3, #64748b); cursor: not-allowed; }
.elab-fixed { margin-top: 18px; padding: 14px; border: 1px solid var(--border, #e5e7eb); border-radius: 12px; }
.elab-fixed-t { margin-bottom: 10px; color: var(--text3, #64748b); font-size: 12px; }
.elab-hint { margin-top: 4px; color: var(--text3, #64748b); font-size: 12px; line-height: 1.45; }
.elab-tech { margin-top: 18px; color: var(--text3, #64748b); font-size: 13px; }
.elab-tech summary { padding: 6px 0; cursor: pointer; user-select: none; }
.elab-tech[open] { padding-bottom: 8px; }

[data-theme="dark"] .elab-head { box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
[data-theme="dark"] .elab-msg.err,
[data-theme="dark"] .elab-warn { border-color: #7f1d1d; background: #2a1618; color: #fecaca; }
[data-theme="dark"] .elab-pat-res { box-shadow: 0 18px 42px rgba(0, 0, 0, .42); }

@media (max-width: 1180px) {
  .elab-head { grid-template-columns: 1fr; gap: 11px; }
  .elab-actions { justify-content: flex-start; }
  .elab-control--patient { max-width: none; }
}

@media (max-width: 820px) {
  .elab-root { height: calc(100vh - 168px); height: calc(100dvh - 168px); }
  .elab-head { padding: 11px; }
  .elab-heading { gap: 9px; }
  .elab-brandmark { flex-basis: auto; width: auto; height: auto; border-radius: 0; }
  .elab-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .elab-control--lab,
  .elab-pick,
  .elab-control--patient { min-width: 0; max-width: none; }
  .elab-control--patient { grid-column: 1 / -1; }
  .elab-root.elab-inline .elab-body { height: min(56vh, 420px); }
  .elab-head--inline .elab-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .elab-soins-bar { justify-content: stretch; }
  .elab-soins-bar .elab-btn { width: 100%; }
  .elab-grid { grid-template-columns: 1fr; gap: 4px 0; }
  .elab-grid label { margin-top: 8px; }
}

@media (max-width: 560px) {
  .elab-head { border-radius: 12px; }
  .elab-subtitle { white-space: normal; }
  .elab-actions,
  .elab-head--inline .elab-actions { grid-template-columns: 1fr; }
  .elab-control--patient { grid-column: auto; }
  .elab-pat-res { right: 0; left: 0; min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .elab-spinner { animation-duration: 1.5s; }
}
