/* hdz-para — feuille de style autonome (aucun build, aucune dépendance CDN). */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6ea;
  --text: #1f2933;
  --muted: #6b7684;
  /* Charte du parc Hakim-DZ (reprise de hdz-pro : barre turquoise #3fbbc0,
     survol #2fa3a0). */
  --primary: #3fbbc0;
  --primary-dark: #2fa3a0;
  --success: #2f855a;
  --warning: #b7791f;
  --danger: #c53030;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- layout */
.topbar {
  position: relative;          /* ancre le nom du cabinet centré */
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 3px 1px rgba(0, 0, 0, .25);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 56px;
}
.topbar .brand { display: flex; align-items: center; }
.topbar .brand img { height: 31px; width: auto; display: block; }
.topbar nav { display: flex; gap: 8px; }
.topbar nav a {
  color: rgba(255, 255, 255, .85);
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 5px;
}
.topbar nav a.active, .topbar nav a:hover {
  color: #fff;
  background: var(--primary-dark);
  text-decoration: none;
}

/* Nom du cabinet : pastille translucide reprise de hdz-pro.

   ⚠️ Il était centré sur la PAGE en position absolue, protégé par un seuil
      fixe (masqué sous 1100 px). Or le chevauchement ne dépend pas que de la
      largeur d'écran : il dépend de la LONGUEUR DU NOM et du NOMBRE D'ENTRÉES
      de menu. À 1366 px — la résolution de portable la plus courante —
      « Centre Démo Paramédical » recouvrait « Patients » et « Administration »
      du directeur. Aucun seuil fixe ne pouvait l'anticiper.

   Il est désormais DANS LE FLUX, entre le menu et les boutons de droite : il
   occupe la place restante et se tronque avec « … » s'il n'y tient pas. Il ne
   peut donc plus rien recouvrir, quels que soient le nom et l'écran. Le prix :
   il est centré dans l'espace libre plutôt que sur la page — un décalage de
   quelques pixels, contre un menu illisible. */
.topbar .brand, .topbar nav, .topbar .topnav-right { flex-shrink: 0; }
.topbar .cabinet {
  flex: 1 1 auto; min-width: 0;          /* prend la place libre, peut rétrécir */
  display: flex; justify-content: center;
}
.topbar .cabinet > span {
  font-size: 22px; font-weight: 700; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
  background: rgba(17, 101, 104, .18); border-radius: 5px; padding: 1px 12px;
}
/* En dessous, la place manque même pour un nom tronqué : on le retire. */
@media (max-width: 900px) { .topbar .cabinet { display: none; } }

/* ------------------------------------------- topbar : menus déroulants */
.topbar .topnav-right { display: flex; align-items: center; gap: 4px; margin-left: auto; }
html[dir="rtl"] .topbar .topnav-right { margin-left: 0; margin-right: auto; }

.topbar .navitem {
  position: relative;
  display: flex; align-items: center; gap: 5px;
  color: #fff; font-size: 14px; font-weight: 600;
  padding: 7px 10px; border-radius: 5px; cursor: pointer; user-select: none;
}
.topbar .navitem:hover,
.topbar .navitem.open,
.topbar .navitem.current { background: var(--primary-dark); }
.topbar .navitem > i.icon { margin: 0; }
.topbar .navitem > i.dropdown.icon { font-size: 11px; opacity: .8; }

/* Le menu est ancré au bord droit de son déclencheur : ancré à gauche il
   déborderait de la fenêtre (les deux menus sont collés au bord de l'écran). */
.topbar .navmenu {
  display: none; position: absolute; top: calc(100% + 4px); right: 0; z-index: 100;
  min-width: 170px; padding: 4px 0; background: #fff; color: var(--text);
  border-radius: 5px; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); font-weight: 500;
  text-align: left;
}
html[dir="rtl"] .topbar .navmenu { right: auto; left: 0; text-align: right; }
.topbar .navitem.open > .navmenu { display: block; }
.topbar .navmenu a {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; color: var(--text); text-decoration: none; white-space: nowrap;
}
.topbar .navmenu a:hover { background: #f0f2f4; text-decoration: none; }
.topbar .navmenu .sep { height: 1px; background: var(--border); margin: 4px 0; }
/* Menu de langue : fond turquoise comme hdz-pro, donc texte en blanc. */
.topbar .navmenu.lang { background: var(--primary); }
.topbar .navmenu.lang a { color: #fff; }
.topbar .navmenu.lang a:hover { background: var(--primary-dark); }

/* Pleine largeur (agenda + prises en charge) ; padding latéral pour l'aération. */
.container { max-width: none; margin: 24px 0; padding: 0 24px; }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 16px; flex-wrap: wrap;
}
.page-head h1 { font-size: 22px; margin: 0; }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card > h2 {
  font-size: 15px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--muted); margin: 0 0 12px;
}
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.3px; }
tbody tr:hover { background: #fafbfc; }
td.num, th.num { text-align: right; }

/* ---------------------------------------------------------------- forms */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
/* `password`, `tel`, `search` et `url` manquaient : ces champs retombaient sur
   la largeur par défaut du navigateur (~150 px). Visible dès la connexion, où
   « Mot de passe » était plus étroit que « E-mail », et sur l'activation de
   compte et le changement de mot de passe. */
input[type=text], input[type=number], input[type=date], input[type=time],
input[type=email], input[type=password], input[type=tel], input[type=search],
input[type=url], select, textarea {
  width: 100%; padding: 8px 10px; font: inherit; font-size: 14px;
  border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text);
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(63,187,192,.18);
}
.field { margin-bottom: 12px; }
.fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.fields .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .fields { grid-template-columns: 1fr; } }
.hint { color: var(--muted); font-size: 12px; margin-top: 3px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
.check label { margin: 0; font-weight: 500; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-block; padding: 8px 14px; border-radius: 6px; border: 1px solid transparent;
  background: var(--primary); color: #fff; font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: #f2f4f7; }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 13px; }

/* Barre d'actions des modales : un seul groupe centré.
   Les boutons du parc portent un padding:4px inline ; on l'applique aussi à ceux
   du slot `actions`, sinon ils n'ont pas la même hauteur. Semantic met déjà une
   marge droite à chaque .ui.button, d'où le seul écart à ajouter : celui qui
   sépare les actions secondaires de la paire Annuler/Enregistrer. */
.form-actions .ui.button { padding: 4px 10px; }
/* align-items:center, sinon le conteneur flex ÉTIRE ses enfants à la hauteur du
   plus grand : un <a> ainsi étiré garde son texte collé en haut de la boîte,
   alors qu'un <button> centre le sien tout seul (style du navigateur). */
.form-actions-left { display: flex; align-items: center; gap: 6px; margin-inline-end: 18px; }
.form-actions-left .ui.button { margin: 0; }
/* Et on centre explicitement le contenu des boutons-liens, pour ne pas dépendre
   de la hauteur de leurs voisins. */
.form-actions a.ui.button { display: inline-flex; align-items: center; justify-content: center; }

/* ------------------------------------------------- quota d'ordonnance
   Trois niveaux : « proche » avertit (ambre), « atteint » et « dépassé »
   alertent (rouge). Aucun style pour l'état ok : rien ne doit attirer l'œil
   tant qu'il n'y a rien à signaler. */
.stat.quota-proche { color: var(--warning); }
.stat.quota-atteint, .stat.quota-depasse { color: var(--danger); }

.quota-alerte {
  margin-top: 12px; padding: 9px 11px; border-radius: 6px;
  font-size: 13px; font-weight: 600; line-height: 1.4;
}
.quota-alerte.quota-proche { background: #fdf3e2; color: var(--warning); border: 1px solid #f0dcb4; }
.quota-alerte.quota-atteint,
.quota-alerte.quota-depasse { background: #fdeaea; color: var(--danger); border: 1px solid #f5c6c6; }

.alert.quota-proche { background: #fdf3e2; color: var(--warning); border: 1px solid #f0dcb4; }
.alert.quota-atteint,
.alert.quota-depasse { background: #fdeaea; color: var(--danger); border: 1px solid #f5c6c6; }

.quota-renouv { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.quota-renouv label { font-size: 12px; }
.quota-renouv .fields { grid-template-columns: 1fr 1fr; }

/* ------------------------------------------- courbes d'évolution des bilans */
.evolution { margin-bottom: 16px; }
.evolution-item {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 10px; background: var(--surface);
}
.evolution-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; font-size: 14px; margin-bottom: 4px;
}
.evolution-svg { width: 100%; height: auto; display: block; }
/* Le SVG contient des libellés : il reste en LTR même en arabe, sinon l'axe du
   temps se lirait à l'envers. */
html[dir="rtl"] .evolution-svg { direction: ltr; }
.evolution-delta { font-size: 13px; font-weight: 600; color: var(--muted); }
/* Coloré seulement quand le registre déclare le sens d'une amélioration. */
.evolution-delta.mieux { color: var(--success); }
.evolution-delta.moins { color: var(--danger); }
.evolution-unit { font-size: 12px; color: var(--muted); }

/* ------------------------------------- groupes de champs du formulaire bilan
   La diététique déclare 22 champs, la psychologie 21. Empilés, le formulaire
   devenait une colonne interminable ; chaque groupe se replie désormais. */
.bilan-groupe {
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 10px; background: var(--surface);
}
.bilan-groupe > summary {
  cursor: pointer; padding: 10px 12px; font-weight: 600; font-size: 14.5px;
  list-style: none; display: flex; align-items: center; gap: 8px;
}
/* Le triangle natif de <summary> diffère selon le navigateur : on pose le
   nôtre pour que l'état ouvert/fermé se lise pareil partout. */
.bilan-groupe > summary::-webkit-details-marker { display: none; }
.bilan-groupe > summary::before {
  content: '▸'; color: var(--muted); transition: transform .15s; display: inline-block;
}
.bilan-groupe[open] > summary::before { transform: rotate(90deg); }
.bilan-groupe > summary .compte {
  margin-left: auto; background: #eef1f4; color: var(--muted);
  border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 600;
}
.bilan-groupe-corps { padding: 4px 12px 12px; }
/* Intertitre de groupe dans le compte rendu imprime. */
.bilan-groupe-titre {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; color: var(--muted);
  margin: 14px 0 4px; padding-bottom: 3px; border-bottom: 1px solid var(--border);
}
html[dir="rtl"] .bilan-groupe > summary::before { content: '◂'; }
html[dir="rtl"] .bilan-groupe[open] > summary::before { transform: rotate(-90deg); }

/* Légende d'un graphe à plusieurs tracés.
   Le repère reprend COULEUR + style de trait + forme de point : six courbes
   distinguées par la seule couleur seraient illisibles pour un daltonien et à
   l'impression en noir et blanc, or ces SVG sont faits pour être imprimés. */
.evolution-legende { list-style: none; margin: 6px 0 0; padding: 0; }
.evolution-legende li {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; padding: 2px 0; line-height: 1.5;
}
.legende-repere { flex: 0 0 34px; }
.legende-label { flex: 1 1 auto; min-width: 0; color: var(--text); }
.legende-valeurs { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Le repère est un schéma d'axe temporel : il ne se retourne pas en arabe,
   comme le SVG lui-même. */
html[dir="rtl"] .legende-repere { direction: ltr; }


/* --------------------------------------------------- tableau de bord */
.bord-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 860px) { .bord-kpis { grid-template-columns: repeat(2, 1fr); } }
.bord-kpi { text-align: center; }
.bord-svg { width: 100%; height: auto; display: block; }
/* Le graphe porte des libelles d'axe : il reste en LTR meme en arabe, sinon
   l'axe du temps se lirait a l'envers. */
html[dir="rtl"] .bord-svg { direction: ltr; }

.bord-repartition { margin-top: 10px; }
.bord-ligne { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; font-size: 13px; }
.bord-ligne .badge { min-width: 74px; text-align: center; }
.bord-metier { min-width: 110px; color: var(--muted); }
.bord-barre { flex: 1; height: 8px; background: #eef1f4; border-radius: 999px; overflow: hidden; }
.bord-barre i { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.bord-ligne b { min-width: 28px; text-align: end; }


/* ------------------------------------------------- rappels de rendez-vous
   Restitution seule : les rappels sont envoyes par hdz (portail patient). */
.rappel-box { padding: 9px 11px; border-radius: 6px; font-size: 13px; background: #f5f7f9; border: 1px solid var(--border); }
.rappel-canal { font-weight: 600; }
.rappel-box.rappel-push .rappel-canal { color: var(--success); }
.rappel-box.rappel-mail .rappel-canal,
.rappel-box.rappel-sms .rappel-canal { color: var(--primary-dark); }
/* Injoignable : seul cas qui appelle une action du praticien. */
.rappel-box.rappel-aucun { background: #fdf3e2; border-color: #f0dcb4; }
.rappel-box.rappel-aucun .rappel-canal { color: var(--warning); }
.rappel-liste { margin: 6px 0 0; padding-inline-start: 2px; list-style: none; }
.rappel-liste li { margin-top: 3px; }
.rappel-liste .meta { margin-inline-start: 6px; font-size: 12px; }


/* ------------------------------------------- bloc GPS de l'administration */
.gps-bloc { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
/* Sous 900px la carte passe dessous : cote a cote, ni l'un ni l'autre ne serait
   utilisable. */
@media (max-width: 900px) { .gps-bloc { grid-template-columns: 1fr; } }
#adm-map { height: 320px; border: 1px solid var(--border); border-radius: var(--radius); }
/* Leaflet pose ses propres controles : on neutralise l'heritage RTL du parc,
   qui retournerait l'attribution et les boutons de zoom. */
html[dir="rtl"] #adm-map { direction: ltr; }


/* ------------------------------------------------- legende de la grille PEC */
.legende {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
}
.legende-titre { font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.legende-item { display: inline-flex; align-items: center; gap: 6px; }
/* Carré, pas rond : il figure un fond de ligne, pas une pastille de statut. */
.legende .pastille {
  width: 22px; height: 13px; border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, .12); display: inline-block;
}
.legende b { font-size: 12px; }


/* ----------------------------------------- survol des lignes de grille
   Le composant du parc pose la couleur de ligne en style INLINE
   (`createdRow` -> $(row).css('background-color', …)). Un style inline bat
   toute regle CSS, y compris :hover : les lignes colorees (prise en charge
   terminee, patient sans suivi actif) ne reagissaient donc PAS au survol,
   tandis que les autres changeaient. D'ou une liste ou le survol semble
   « accrocher » sur certaines lignes.

   On colore les CELLULES et non la ligne : elles se peignent par-dessus le
   fond de la ligne, ce qui l'emporte sur l'inline sans avoir a le supprimer. */
/* APLAT, pas degrade : le survol du parc peignait un
   `linear-gradient(#1ebdbd, #92efef)` sur le <tr>. Un degrade de ligne est
   coûteux a repeindre et laisse des lignes bloquees en turquoise quand on
   survole vite ; il est neutralise par la classe `whover` sur la table.

   `!important` est ici NECESSAIRE, pas une facilite : le composant pose la
   couleur de ligne en style INLINE (createdRow), et seul !important passe
   devant un style inline. C'est d'ailleurs ce que faisait la regle du parc. */
table.datatable tbody tr:hover > td { background-color: #dff2f2 !important; }

/* Le parc coupe le texte des cellules N'IMPORTE OU (`word-break: break-all`,
   sty1.0.3.css) : « Neuropsychologie » s'affichait « Neuropsyc / hologie ».
   `break-word` ne coupe un mot que s'il ne tient vraiment pas, et laisse la
   colonne s'elargir pour le mot le plus long. */
table.datatable td { word-break: normal; overflow-wrap: break-word; }

/* ---------------------------------------------------------------- badges */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: #eef1f4; color: var(--muted);
}
.badge.en_cours   { background: #e6f5f5; color: var(--primary); }
.badge.terminee   { background: #e6f4ec; color: var(--success); }
.badge.suspendue  { background: #fdf3e2; color: var(--warning); }
.badge.abandonnee { background: #fdeaea; color: var(--danger); }
/* Séance posée à l'avance : neutre, pour ne pas la confondre avec une séance
   réellement faite (seul « présent » compte dans nb_seances_realisees). */
.badge.planifiee { background: #eef1f4; color: var(--muted); }
.badge.present { background: #e6f4ec; color: var(--success); }
.badge.absent, .badge.annule { background: #fdeaea; color: var(--danger); }
.badge.excuse { background: #fdf3e2; color: var(--warning); }

/* ---------------------------------------------------------------- misc */
.alert { padding: 10px 12px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.alert.error { background: #fdeaea; color: var(--danger); border: 1px solid #f5c6c6; }
.alert.ok { background: #e6f4ec; color: var(--success); border: 1px solid #c3e6d2; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.empty { color: var(--muted); font-size: 14px; padding: 14px 0; text-align: center; }
.meta { color: var(--muted); font-size: 13px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filters .field { margin: 0; min-width: 170px; }
.stat { font-size: 26px; font-weight: 700; }
.stat small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; }

/* ---------------------------------------------------------------- login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; width: 100%; max-width: 380px;
}
.login-brand { margin-bottom: 4px; }
.login-brand img { height: 46px; width: auto; }

/* ---------------------------------------------------------------- liens-boutons */
.linkbtn {
  background: none; border: none; padding: 0; font: inherit; font-size: 13px;
  color: var(--primary); cursor: pointer; text-decoration: underline;
}
