/* Vue mobile (/m/) — chargée APRÈS style.css, dont elle reprend les variables de
   thème, les boutons, les badges, les modales et les interrupteurs .astreinte-*. */

:root {
  --m-nav-h: 60px;
}

/* L'attribut `hidden` doit gagner sur nos règles de mise en page.
   Le navigateur ne le rend que par `[hidden] { display: none }` dans SA feuille de
   style : n'importe quelle règle d'auteur portant un `display` la bat, quelle que soit
   la spécificité. Sans la ligne ci-dessous, `.m-segments { display: flex }` rendait
   visible le sélecteur VIGIE/PCM d'un cadre de permanence — un sélecteur pourtant sans
   gestionnaire de clic, puisqu'il n'a qu'un seul périmètre autorisé. Deux boutons morts.
   Même piège pour `.m-limit-notice` et `.m-icon-btn`. */
[hidden] { display: none !important; }

.m-body {
  /* Place pour la barre d'onglets fixée en bas (encoche iOS comprise). */
  padding-bottom: calc(var(--m-nav-h) + env(safe-area-inset-bottom));
}

/* ── En-tête ─────────────────────────────────────────────────────────────── */
.m-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .9rem 1rem calc(.9rem - 2px);
  padding-top: calc(.9rem + env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.m-header-id { min-width: 0; }
.m-header h1 {
  font-size: 1.15rem; margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.m-user {
  display: block; color: var(--text-muted); font-size: .8rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.m-header-actions { display: flex; gap: .35rem; flex: none; }
.m-icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--surface2); border: 1px solid var(--border); color: var(--text-muted);
  cursor: pointer;
}
.m-icon-btn:active { background: var(--border); }
/* Le bouton ⓘ porte l'en-tête à quatre icônes : sur un écran étroit (iPhone SE),
   elles mangeaient le titre. */
@media (max-width: 380px) {
  .m-header-actions { gap: .25rem; }
  .m-icon-btn { width: 34px; height: 34px; }
}

/* ── Bandeau d'installation (PWA) ────────────────────────────────────────── */
/* Affiché tant que l'application n'est pas sur l'écran d'accueil et que le cadre ne
   l'a pas écarté (modules/m/install.js). */
.m-install {
  display: flex; align-items: flex-start; gap: .75rem;
  margin: .9rem 1rem 0; padding: .8rem .9rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.m-install-icon {
  display: flex; align-items: center; justify-content: center; flex: none;
  width: 36px; height: 36px; border-radius: 9px;
  background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent);
}
.m-install-body { flex: 1; min-width: 0; }
.m-install-title { margin: 0 0 .15rem; font-size: .92rem; font-weight: 600; }
.m-install-hint { margin: 0; font-size: .82rem; color: var(--text-muted); line-height: 1.45; }
/* L'icône « Partager » est insérée au fil du texte : elle doit s'aligner dessus. */
.m-install-hint svg { vertical-align: -2px; }
.m-install-btn { width: auto; margin-top: .6rem; padding: .4rem .9rem; font-size: .85rem; }
.m-install-close { width: 30px; height: 30px; flex: none; border-radius: 8px; }

/* Bandeau « nouvelle version » : même gabarit, action alignée à droite plutôt que sous
   le texte — il n'y a rien à lire, juste un bouton à toucher. */
.m-update { align-items: center; }
.m-update-btn { flex: none; width: auto; padding: .45rem .9rem; font-size: .85rem; }

/* ── Onglet Gestion ──────────────────────────────────────────────────────── */
/* Réutilise les .astreinte-row / .astreinte-toggle de l'onglet Astreinte : ce sont les
   mêmes gestes, ils doivent avoir la même apparence. */
#gestion-body.pending { opacity: .55; pointer-events: none; }
.m-section-title {
  font-size: .78rem; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .04em; margin: 1.4rem 0 .7rem;
}
.m-section-title:first-child { margin-top: 0; }

/* Quelle ligne est pilotée ici — sans ce rappel, on croit régler « le standard » en
   général, alors que la ligne VIGIE n'est pas concernée. */
.gestion-line { display: flex; flex-direction: column; gap: .25rem; margin: 0 0 1rem; }
.gestion-line-num {
  font-size: 1.05rem; font-weight: 700; letter-spacing: .03em; white-space: nowrap;
}
.gestion-line-sub { font-size: .8rem; color: var(--text-muted); line-height: 1.45; }

/* Où sonnent les appels EN CE MOMENT — la seule chose qu'un cadre réveillé à 3 h du
   matin doit pouvoir lire d'un coup d'œil, avant même de toucher un interrupteur. */
.gestion-dest {
  display: flex; flex-direction: column; gap: .2rem;
  border-radius: 12px; padding: .95rem 1.1rem; margin-bottom: 1.1rem;
  border: 1px solid var(--border); background: var(--surface);
  border-left: 4px solid var(--text-muted);
}
.gestion-dest.is-normal   { border-left-color: var(--success); }
.gestion-dest.is-overflow { border-left-color: var(--orange); }
.gestion-dest.is-vigie    { border-left-color: var(--red); }
.gestion-dest-lead   { font-size: .78rem; color: var(--text-muted); }
.gestion-dest-label  { font-size: 1.15rem; font-weight: 700; }
.gestion-dest-detail { font-size: .82rem; color: var(--text-muted); line-height: 1.4; }

/* Levier sans effet dans l'état courant : visible (il dit quelque chose de l'état)
   mais clairement inopérant. */
.astreinte-row.is-muted { opacity: .55; }
.astreinte-toggle:disabled { cursor: not-allowed; }

.gestion-cadres { list-style: none; margin: 0 0 .9rem; padding: 0; }
.gestion-cadre {
  display: flex; flex-direction: column; gap: .1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: .7rem .9rem; margin-bottom: .5rem;
}
.gestion-cadre-name { font-size: .95rem; font-weight: 600; }
.gestion-cadre-sub  { font-size: .78rem; color: var(--text-muted); word-break: break-word; }
.gestion-add {
  display: flex; align-items: center; justify-content: center; gap: .4rem; width: 100%;
}
.gestion-note {
  margin: .8rem 0 0; font-size: .8rem; color: var(--text-muted); line-height: 1.5;
}
.gestion-field-hint {
  margin: .3rem 0 0; font-size: .76rem; color: var(--text-muted); line-height: 1.45;
}

/* ── Sections ────────────────────────────────────────────────────────────── */
#m-view { padding: 1.1rem 1rem 1.5rem; }
.m-section { display: none; }
.m-section.active { display: block; }

.m-empty { color: var(--text-muted); font-size: .9rem; padding: 1.2rem .2rem; text-align: center; }
.m-error { color: var(--danger); }
.m-btn-soft {
  width: auto; background: var(--surface); border: 1px solid var(--border); color: var(--text);
}

/* ── Barre d'onglets ─────────────────────────────────────────────────────── */
.m-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex;
  height: calc(var(--m-nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
}
.m-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .15rem; padding: 0; border: none; background: none;
  color: var(--text-muted); font-size: .68rem; cursor: pointer;
}
.m-tab.active { color: var(--accent); }
.m-tab.active svg { stroke-width: 2.4; }
/* Un cadre a cinq onglets (l'opérateur deux) : sur un iPhone SE, les libellés doivent
   rétrécir plutôt que passer à la ligne et décaler les icônes. */
.m-tab span { white-space: nowrap; }
@media (max-width: 380px) {
  .m-tab { font-size: .6rem; }
}

/* ── Mon astreinte ───────────────────────────────────────────────────────── */
/* Interrupteurs du cadre de permanence : venus de style.css avec l'ancienne page
   autonome /astreinte, dont la vue mobile est désormais le seul consommateur. */
#astreinte-body.pending { opacity: .55; pointer-events: none; }
/* Bandeau d'état : c'est la première chose que lit un cadre réveillé à 3 h. Pleine
   largeur (l'ancienne pastille en ligne se perdait en haut de page) et doublé d'une
   phrase qui dit ce que l'état implique. */
.astreinte-status {
  display: flex; flex-direction: column; gap: .15rem; border-radius: 12px;
  padding: .8rem 1rem; margin-bottom: 1.1rem; color: #fff;
}
.astreinte-status-label { font-size: 1.05rem; font-weight: 700; }
.astreinte-status-sub { font-size: .82rem; opacity: .9; line-height: 1.35; }
.astreinte-status.st-vigie { background: var(--success); }
.astreinte-status.st-overflow { background: var(--accent); }
.astreinte-status.st-paused { background: var(--yellow); color: #1a1d2e; }
.astreinte-status.st-inactif { background: var(--surface2); color: var(--text-muted); }
.astreinte-section {
  font-size: .78rem; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .04em; margin: .2rem 0 .6rem;
}
.astreinte-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 1rem 1.1rem; margin-bottom: .9rem;
}
/* Les deux seuls leviers du cadre, groupés en tête : prendre l'astreinte, ou se
   mettre en pause. Le réglage fin (quels mobiles) est relégué en bas de page. */
.astreinte-actions { margin-bottom: 1.3rem; }
.astreinte-actions .astreinte-row:last-child { margin-bottom: 0; }
.astreinte-row-main { border-color: var(--accent); }
.astreinte-row-pause { border-color: var(--warning); }
.astreinte-row-info { display: flex; flex-direction: column; gap: .2rem; }
.astreinte-row-label { font-size: 1rem; font-weight: 600; }
.astreinte-row-num { font-size: 1.25rem; font-weight: 600; letter-spacing: .02em; }
.astreinte-row-sub { font-size: .8rem; color: var(--text-muted); }
/* Qui est joignable — deux blocs côte à côte, chacun de la couleur de son rôle
   (vert = astreinte 690, bleu = débordement 695), pour qu'on lise l'appartenance
   sans lire le titre. Les listes sont disjointes (cf. astreinte.user_state). */
.astreinte-who {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .6rem; margin: 0 0 1.3rem;
}
.astreinte-who-grp { border-radius: 12px; padding: .75rem .85rem; border: 1px solid var(--border); }
.astreinte-who-grp.is-vigie {
  background: color-mix(in srgb, var(--success) 9%, transparent);
  border-color: color-mix(in srgb, var(--success) 35%, var(--border));
}
.astreinte-who-grp.is-overflow {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--border));
}
.astreinte-who-title {
  display: flex; align-items: center; gap: .35rem; margin: 0 0 .45rem;
  font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 700;
}
.astreinte-who-grp.is-vigie .astreinte-who-title { color: var(--success); }
.astreinte-who-grp.is-overflow .astreinte-who-title { color: var(--accent); }
.astreinte-who-list { list-style: none; margin: 0; padding: 0; }
.astreinte-who-item { padding: .2rem 0; line-height: 1.3; }
.astreinte-who-item.is-self { font-weight: 700; }
.astreinte-who-name { display: block; font-size: .92rem; }
.astreinte-who-empty { font-size: .88rem; color: var(--text-muted); }
/* « + les cadres d'astreinte » : rappel que la colonne débordement les inclut sans
   les répéter. Discret — c'est une note de lecture, pas une entrée de la liste. */
.astreinte-who-also {
  padding: .2rem 0; font-size: .82rem; font-style: italic; color: var(--text-muted);
}
.astreinte-you { font-size: .8rem; color: var(--text-muted); font-weight: 400; }
/* Interrupteur on/off */
.astreinte-toggle {
  position: relative; flex: none; width: 64px; height: 36px; border-radius: 999px;
  border: none; background: var(--surface2); cursor: pointer; transition: background .2s;
  padding: 0;
}
.astreinte-toggle .astreinte-knob {
  position: absolute; top: 3px; left: 3px; width: 30px; height: 30px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35); transition: transform .2s;
}
.astreinte-toggle.on { background: var(--success); }
.astreinte-toggle.on .astreinte-knob { transform: translateX(28px); }
.astreinte-toggle.pending { opacity: .5; pointer-events: none; }
.astreinte-empty {
  color: var(--text-muted); font-size: .92rem; line-height: 1.5; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 1.1rem;
}
.astreinte-msg { min-height: 1.2rem; margin: 1rem 0 0; font-size: .9rem; color: var(--success); }
.astreinte-msg.error { color: var(--danger); }

.m-warn {
  background: color-mix(in srgb, var(--orange) 12%, var(--surface));
  border: 1px solid var(--orange); border-radius: 8px;
  padding: .85rem 1rem; margin: 0 0 1.4rem; font-size: .9rem; line-height: 1.5;
}
.m-warn strong:first-child { color: var(--orange); }
.m-warn p { margin: .45rem 0 0; color: var(--text); }
.m-warn-num { font-weight: 700; font-size: 1.05rem; letter-spacing: .5px; white-space: nowrap; }
.m-warn-nums {
  display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center;
  margin: .6rem 0;
}
.m-warn-nums .m-warn-num {
  padding: .3rem .7rem; border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.m-warn-num-inline { font-weight: 700; white-space: nowrap; }
/* « C'est fait » : acquitte le bandeau, qui ne revient plus (localStorage). */
.m-warn-ack { width: 100%; margin-top: .9rem; }
/* Même consigne, dans la modale du bouton ⓘ : ni cadre ni couleur d'alerte,
   c'est de la documentation, pas un avertissement. */
.m-setup-modal { font-size: .9rem; line-height: 1.5; }
.m-setup-modal p { margin: .45rem 0 0; }
.m-setup-modal .m-warn-nums { margin: .7rem 0; }

/* ── Planning ────────────────────────────────────────────────────────────── */
.m-planning-current { font-size: .82rem; color: var(--text-muted); margin: 0 0 .8rem; line-height: 1.5; }
.m-planning-actions { display: flex; gap: .5rem; margin-bottom: .8rem; }
.m-planning-actions .btn { flex: 1; width: auto; padding: .6rem .5rem; }
.m-planning-legend { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .9rem; }
/* La barre d'outils de FullCalendar déborde sur un écran étroit. */
#vigie-planning-cal .fc-toolbar { flex-wrap: wrap; gap: .5rem; }
#vigie-planning-cal .fc-toolbar-title { font-size: 1.05rem; }
#vigie-planning-cal .fc .fc-button { padding: .3rem .6rem; font-size: .85rem; }
#vigie-planning-cal .fc-list-event-title { white-space: normal; }

/* ── Historique ──────────────────────────────────────────────────────────── */
.m-filters { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1rem; }
.m-filter-row { display: flex; gap: .5rem; }
.m-filter-row input, .m-filter-row select { flex: 1; min-width: 0; }
.m-segments {
  display: flex; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; padding: 3px; gap: 3px;
}
.m-seg {
  flex: 1; padding: .5rem .3rem; border: none; border-radius: 7px; background: none;
  color: var(--text-muted); font-size: .85rem; font-weight: 600; cursor: pointer;
}
.m-seg.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.m-limit-notice { font-size: .78rem; color: var(--text-muted); margin: 0; }

.m-calls { display: flex; flex-direction: column; gap: .5rem; }
.m-call {
  display: flex; align-items: center; gap: .7rem; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: .8rem .9rem; color: var(--text); cursor: pointer;
}
.m-call:active { background: var(--surface2); }
/* Appel sortant : liseré + flèche + libellé colorés. Déclaré AVANT .m-call-emergency,
   qui doit garder la main sur la couleur du liseré (la largeur, elle, reste acquise). */
.m-call-out { border-left: 3px solid var(--accent); }
.m-call-out .m-call-dir { color: var(--accent); }
.m-call-out-tag {
  color: var(--accent); font-weight: 700; text-transform: uppercase;
  font-size: .7rem; letter-spacing: .03em;
}
.m-call-out-tag::after { content: ' · '; color: var(--text-muted); font-weight: 400; }
.m-call-emergency { border-color: var(--red); }
.m-call-dir { flex: none; color: var(--text-muted); display: flex; }
.m-call-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.m-call-title {
  font-weight: 600; font-size: .95rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.m-call-sub { font-size: .78rem; color: var(--text-muted); }
.m-call-emerg { font-size: .75rem; color: var(--red); display: flex; align-items: center; gap: .25rem; }
.m-call-right {
  flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: .3rem;
}
.m-badge-xs { font-size: .62rem; }
.m-call-marks { display: flex; gap: .25rem; color: var(--text-muted); }
.m-mark.flagged { color: var(--yellow); }
.m-more { width: 100%; margin-top: .9rem; }

/* Feuille de détail d'un appel */
.m-detail { font-size: .9rem; }
.m-detail-audio { margin-bottom: 1rem; }
.m-detail-audio audio { width: 100%; }
.m-detail-tools { display: flex; gap: .5rem; margin: 1rem 0 .8rem; flex-wrap: wrap; }
.m-flag { display: flex; align-items: center; justify-content: center; gap: .4rem; flex: 1; }
.m-flag.flagged { border-color: var(--yellow); color: var(--yellow); }
/* Rappel VIGIE : couleur de l'astreinte, comme le bouton du panel de bureau. */
.m-callback {
  display: flex; align-items: center; justify-content: center; gap: .4rem; flex: 1;
  border-color: var(--orange); color: var(--orange);
}
.m-callback:disabled { opacity: .5; }
.m-note {
  width: 100%; min-height: 80px; resize: vertical;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
  padding: .6rem .7rem; color: var(--text); font-family: inherit; font-size: .9rem;
}
.m-detail-footer { display: flex; gap: .6rem; margin-top: 1rem; }
.m-detail-footer .btn { flex: 1; width: auto; }

/* ── Annuaire ────────────────────────────────────────────────────────────── */
.m-contacts { display: flex; flex-direction: column; gap: .5rem; }
.m-contacts-title {
  font-size: .78rem; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .04em; margin: .2rem 0 .1rem;
}
.m-contact {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .7rem .8rem;
}
/* Nom (+ structure) à gauche, crayon à droite sur la même ligne. */
.m-contact-head { display: flex; align-items: flex-start; gap: .5rem; }
/* min-width:0 : sans lui, un nom long pousserait le crayon hors de la carte au lieu
   de passer à la ligne. */
.m-contact-id { flex: 1; min-width: 0; }
.m-contact-name { font-weight: 600; font-size: .95rem; }
.m-contact-company { font-size: .8rem; color: var(--text-muted); margin-top: .1rem; }
.m-contact-nonum { color: var(--text-muted); font-size: .8rem; }
.m-contact-edit {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; margin: -.3rem -.35rem 0 0;
  background: none; border: none; border-radius: 8px;
  color: var(--text-muted); cursor: pointer;
}
/* Marges négatives ci-dessus : la zone tactile déborde dans le rembourrage de la carte,
   ce qui donne 34px sous le doigt sans écarter le texte. */
.m-contact-edit:active { background: var(--surface2); color: var(--accent); }
.m-contact-numbers { display: flex; flex-direction: column; gap: .35rem; margin-top: .55rem; }
.m-contacts-hint {
  font-size: .78rem; color: var(--text-muted); line-height: 1.35; margin: 0 0 .2rem;
}
/* Ajout d'un contact : sous la recherche, donc visible aussi quand une recherche n'a
   rien donné — c'est précisément le moment où l'on veut créer la fiche. */
.m-contacts-add {
  display: flex; align-items: center; justify-content: center; gap: .4rem;
  width: 100%; margin-bottom: .8rem;
}
/* Bouton (rappel VIGIE) pour un cadre, lien tel: pour un opérateur : même apparence. */
.m-contact-call {
  display: flex; align-items: center; gap: .5rem; width: 100%; text-align: left;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 9px;
  padding: .6rem .7rem; color: var(--text); font-size: .95rem; font-weight: 600;
  font-family: inherit; text-decoration: none; cursor: pointer;
}
.m-contact-call:active { border-color: var(--accent); color: var(--accent); }
.m-contact-call:disabled { opacity: .5; }

/* ── Ajustements des briques partagées ───────────────────────────────────── */
/* Champs à 16px, et pas moins. iOS zoome d'autorité sur tout champ dont la police est
   sous ce seuil au moment où on le touche, puis laisse la page décalée : c'est ce qui
   donne l'impression que l'application « part en zoom » toute seule dès qu'on tape dans
   la recherche de l'annuaire ou dans un filtre d'historique. Le style commun
   (style.css) descend à .9rem, soit 12,6px sur un corps de 14px — bien assez pour
   déclencher le zoom. 16px est un seuil technique, pas un choix esthétique : le baisser
   ne serait-ce qu'à 15px ramènerait le problème. Le pincement, lui, reste possible —
   c'est délibéré (accessibilité). */
.m-body input, .m-body select, .m-body textarea { font-size: 16px; }
/* Modales : pleine largeur, hauteur bornée (le clavier virtuel mange l'écran).
   Sous 640px, style.css les ancre déjà en bas (align-items: flex-end) avec des boutons
   pleine largeur empilés — c'est une feuille de bas d'écran, pas une boîte flottante.
   D'où l'importance du dvh : `vh` vaut la hauteur de l'écran SANS tenir compte du
   clavier (iOS ne la réduit jamais), si bien qu'une modale haute voyait son pied — donc
   « Créer » et « Enregistrer » — passer derrière le clavier. `dvh` suit la hauteur
   réellement visible ; la ligne en `vh` reste comme repli pour les vieux navigateurs. */
.m-body .modal-box {
  width: 100%; max-width: none; margin: 0 .5rem;
  max-height: 88vh;
  max-height: 88dvh;
  overflow-y: auto;
}
/* Le toast doit passer au-dessus de la barre d'onglets. */
.m-body #toast { bottom: calc(var(--m-nav-h) + env(safe-area-inset-bottom) + 1rem); }
