/* Correcteur orthographique — feuille de style intranet */

:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-alt: #f8f9fa;
  --border: #d8dbe0;
  --border-strong: #b9bec6;
  --text: #1f2328;
  --muted: #5f6670;
  --primary: #1d5bb8;
  --primary-hover: #174b99;
  --primary-soft: #e8eff9;
  --focus: rgba(29, 91, 184, .35);
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --success: #1a7f37;
  --success-soft: #e8f5ec;
  --warn: #9a6700;
  --ins-bg: #dcf1e2;
  --ins-fg: #0f5c25;
  --del-bg: #fbe4e4;
  --del-fg: #9b1c1c;
  --radius: 6px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
h1, h2 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.i { width: 16px; height: 16px; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.btn:hover:not(:disabled) { background: var(--surface-alt); border-color: #9aa1ab; }
.btn:active:not(:disabled) { background: #eceef1; }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn::-webkit-details-marker { display: none; }
.btn-sm { height: 28px; padding: 0 9px; font-size: 13px; }
.btn-icon { width: 34px; padding: 0; }
.btn-sm.btn-icon { width: 28px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary:active:not(:disabled) { background: #123d7d; }
.btn-quiet { border-color: transparent; background: none; color: var(--muted); }
.btn-quiet:hover:not(:disabled) { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }

.spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: tourner .8s linear infinite;
}
.is-busy .spinner { display: block; }
.is-busy .btn-primary .ico { display: none; }
@keyframes tourner { to { transform: rotate(360deg); } }

/* ---------- Champs ---------- */
.f { display: grid; gap: 4px; margin-bottom: 14px; }
.f > span, .f > label { font-weight: 600; font-size: 13px; }
.f em { font-style: normal; font-weight: 400; color: var(--muted); }
input[type="text"], input[type="password"], input[type="search"], input:not([type]), select {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--primary); }
textarea.consignes {
  width: 100%;
  min-height: 180px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  line-height: 1.5;
  resize: vertical;
}
.input-group { display: flex; gap: 6px; }
.input-group input { flex: 1; min-width: 0; }

/* ---------- Messages ---------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 12px;
  margin-bottom: 14px;
  border: 1px solid;
  border-radius: var(--radius);
}
.alert .i { margin-top: 2px; }
.alert-succes { color: var(--success); background: var(--success-soft); border-color: #a7d7b5; }
.alert-erreur { color: var(--danger); background: var(--danger-soft); border-color: #f1b5b0; }
.flashes { max-width: 1100px; margin: 16px auto 0; padding: 0 20px; }
.flashes .alert { margin-bottom: 8px; }

/* ---------- Barre du haut ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-in {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
}
.brand .i { width: 20px; height: 20px; color: var(--primary); }
.nav { display: flex; align-self: stretch; gap: 4px; flex: 1; }
.nav a {
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom-color: var(--primary); }
.session { display: flex; align-items: center; gap: 12px; }
.session-name { display: grid; text-align: right; line-height: 1.25; font-weight: 600; font-size: 13px; }
.session-name small { font-weight: 400; color: var(--muted); font-size: 12px; }

/* ---------- Mise en page ---------- */
.page { max-width: 1100px; margin: 0 auto; padding: 24px 20px 48px; }
.page-narrow { max-width: 860px; }
.page-form { max-width: 560px; }
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.page-head p { margin: 2px 0 0; }
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 16px;
}
.panel > h2 { margin-bottom: 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.help { margin: 0; font-size: 13px; }

/* ---------- Widget de correction ---------- */
.widget { padding: 0; display: flex; flex-direction: column; container-type: inline-size; }
.widget-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
}
.tabs { display: flex; flex: 1; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 0 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.tab:hover:not(:disabled) { color: var(--text); }
.tab.is-active { color: var(--text); font-weight: 600; border-bottom-color: var(--primary); }
.tab:disabled { opacity: .5; cursor: not-allowed; }
.tab:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.count {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  line-height: 18px;
}
.tab.is-active .count { background: var(--primary-soft); border-color: #bfd2ef; color: var(--primary); }
.pip-title { display: none; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; color: var(--muted); }
.pip-title .i { color: var(--primary); }

.editor { position: relative; display: flex; }
#zone, .diff {
  width: 100%;
  height: 42vh;
  min-height: 260px;
  margin: 0;
  padding: 14px 16px;
  border: 0;
  font: inherit;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--surface);
}
#zone { display: block; resize: vertical; }
#zone:focus { outline: none; }
.editor:focus-within { box-shadow: inset 0 0 0 2px var(--focus); }
#zone::placeholder { color: #8a9099; }
.is-busy #zone { color: var(--muted); background: var(--surface-alt); }
.diff { overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; outline: none; }
.diff ins { text-decoration: none; background: var(--ins-bg); color: var(--ins-fg); border-radius: 2px; padding: 0 1px; }
.diff del { color: var(--del-fg); background: var(--del-bg); border-radius: 2px; padding: 0 1px; text-decoration-thickness: 1px; }
.diff-vide { color: var(--muted); }

.widget-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 13px;
  color: var(--muted);
}
.status { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status[data-etat="busy"] { color: var(--primary); }
.status[data-etat="ok"] { color: var(--success); }
.status[data-etat="warn"] { color: var(--warn); }
.status[data-etat="err"] { color: var(--danger); }
.counter { white-space: nowrap; font-variant-numeric: tabular-nums; }
.counter.is-over { color: var(--danger); font-weight: 600; }

.actions {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
}
.actions #btn-corriger { min-width: 140px; }
.actions #btn-effacer { margin-left: auto; }
#btn-copier.is-copied { color: var(--success); border-color: var(--success); background: var(--success-soft); }

@container (max-width: 560px) {
  .actions { flex-wrap: wrap; }
  .actions #btn-corriger { flex: 1 0 100%; }
  .actions .btn:not(#btn-corriger) { flex: 1; }
  .actions #btn-effacer { margin-left: 0; }
}
@container (max-width: 380px) {
  .actions .btn:not(#btn-corriger) .lbl { display: none; }
  .widget-foot .counter { display: none; }
}

/* Noms de médicaments dans la vue des modifications */
.diff ins.med { background: #fdebc8; color: #7a4100; box-shadow: inset 0 -2px 0 #e0a340; }
.diff del.med { background: #fbe4e4; }

/* Contrôle des médicaments et des valeurs */
.controles { border-top: 1px solid var(--border); padding: 8px 16px 10px; max-height: 30vh; overflow: auto; }
.controles-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; margin-bottom: 4px; }
.controles.has-alerte .controles-head .muted { color: #9a5b00; font-weight: 600; }
.controles ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ctrl { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 4px 8px; font-size: 13px; padding: 4px 0; }
.ctrl > span { flex: 1 1 260px; }
.ctrl > .i { margin-top: 2px; }
.ctrl-ok > .i { color: var(--success); }
.ctrl-info { color: var(--muted); }
.ctrl-alerte { background: #fff6e5; border: 1px solid #f0cf8f; border-radius: var(--radius); padding: 6px 8px; }
.ctrl-alerte > .i { color: #b26a00; }

.pip-placeholder { display: flex; align-items: center; gap: 12px; }
.pip-placeholder > span { flex: 1; }
.pip-placeholder > .i { color: var(--primary); width: 20px; height: 20px; }

/* Fenêtre « Premier plan » (Document Picture-in-Picture) */
body.pip { padding: 0; overflow: hidden; background: var(--surface); }
body.pip .widget { height: 100vh; margin: 0; border: 0; border-radius: 0; }
body.pip .editor { flex: 1 1 auto; min-height: 0; }
body.pip #zone, body.pip .diff { height: 100% !important; min-height: 0; resize: none; }
body.pip .pip-title { display: inline-flex; }
body.pip .tab { height: 38px; padding: 0 9px; }

/* ---------- Connexion ---------- */
.page-login main { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 380px; }
.login-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.login-head > div { display: grid; line-height: 1.3; }
.login-head strong { font-size: 16px; }
.login-head .muted { font-size: 13px; }
.login-logo {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
}
.login-logo .i { width: 22px; height: 22px; }
.login-form { padding: 22px; }
.login-form h1 { font-size: 18px; margin-bottom: 16px; }
.login-form .btn-primary { height: 38px; margin-top: 4px; }
.login-form [data-toggle-password].is-on { color: var(--primary); border-color: var(--primary); }
.login-foot { margin: 12px 0 0; font-size: 13px; text-align: center; }

/* ---------- Administration ---------- */
.create-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 14px; }
.create-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 13px; }

.search { position: relative; width: 240px; }
.search .i { position: absolute; left: 9px; top: 9px; color: var(--muted); }
.search input { padding-left: 32px; }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbfc; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.is-off td { color: var(--muted); }
.actions-col { width: 1%; }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; white-space: nowrap; }
.tag {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.state::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: currentColor; vertical-align: 1px; }
.state-on { color: var(--success); }
.state-off { color: var(--muted); }

.popover { position: relative; }
.popover > summary { list-style: none; }
.popover-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  width: 300px;
  display: grid;
  gap: 8px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
  white-space: normal;
}
.popover-panel label { font-weight: 600; font-size: 13px; }
.popover-panel .btn-primary { justify-self: start; }

.subnav { display: flex; gap: 4px; margin: -4px 0 16px; border-bottom: 1px solid var(--border); }
.subnav a { padding: 8px 12px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subnav a:hover { color: var(--text); }
.subnav a[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom-color: var(--primary); }
.small { font-size: 13px; margin: 2px 0 0; }
.panel-head h2 .count { margin-left: 4px; vertical-align: 1px; }
.spinner-dark { border-color: rgba(0, 0, 0, .15); border-top-color: var(--text); }
.verif { max-width: 420px; margin: 4px 0 6px; }
.verif .search { width: 100%; }
.verif-resultat p { margin: 2px 0; font-size: 13px; }
.verif-resultat .ok { color: var(--success); }
.verif-resultat .alerte { color: #9a5b00; }

/* ---------- Mon compte ---------- */
.infos { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; margin: 0; }
.infos dt { color: var(--muted); }
.infos dd { margin: 0; font-weight: 500; }

/* ---------- Petits écrans ---------- */
@media (max-width: 900px) {
  .create-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .topbar-in { flex-wrap: wrap; gap: 0 12px; padding: 0 12px; }
  .brand { min-height: 48px; flex: 1; }
  .session-name { display: none; }
  .nav { order: 3; flex: 0 0 100%; border-top: 1px solid var(--border); overflow-x: auto; }
  .nav a { height: 40px; white-space: nowrap; }
  .flashes { padding: 0 12px; }
  .page { padding: 16px 12px 32px; }
  .page-head { flex-wrap: wrap; align-items: flex-start; }
  .create-grid { grid-template-columns: 1fr; }
  .panel { padding: 14px; }
  .widget { padding: 0; }
  #zone, .diff { height: 45vh; min-height: 220px; }
  .search { width: 100%; }
  .panel-head { flex-wrap: wrap; }

  /* Tableau en fiches */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; text-align: right; }
  .table td::before { content: attr(data-label); color: var(--muted); text-align: left; }
  .table td.num { text-align: right; }
  .table td.row-actions { justify-content: flex-start; padding-top: 8px; }
  .table td.row-actions::before { content: none; }
  .table tbody tr:hover td { background: none; }
  .popover-panel { left: 0; right: auto; width: min(300px, calc(100vw - 48px)); }
  .infos { grid-template-columns: 1fr; gap: 0; }
  .infos dd { margin-bottom: 8px; }
}

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