/** 
 * Application MAP et SOS SISL
 *
 * @author André Cavegn <andre.cavegn@sisl.ch>
 * @version 2.1.0
 * @since 2026-02-15
 **/

:root {
  --bg: #ffffff;
  --bgcolorapp: #0b1220;
  --appcolormenu: #e5e7eb;
  --card: #ffffff;
  --muted: #6b7280; /* gris 500 */
  --text: #111827; /* gris 900 */
  --accent: #22c55e; /* vert */
  --accent-2: #2563eb; /* bleu focus */
  --danger: #dc2626; /* rouge */
  --border: #e5e7eb; /* gris 200 */
  --shadow: 0 6px 24px rgba(17, 24, 39, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --radius: 14px;
  --colorsuccess: #065f46; /* vert */
  --colorerror: #b91c1c; /* rouge */




}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    "Helvetica Neue",
    Arial;
  color: var(--text);
  background-color: var(--bgcolorapp);
}

.wrap {
  padding: 10px;
  min-height: 100svh; /* svh = viewport stable, top pour mobile */
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* **************
 * Layout page login
 * **************/

.login_panel {
  background: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  padding: 16px;
}
.login_panel button {
  margin: 2px;
  padding: 0px;
  cursor: pointer;
  opacity: 1;
  background-color: #1677ff;
  color: white;
  border: 1px solid gray;
  border-radius: 10px;
  font-size: 16px;
  height: 30px;
  font-weight: 600;
  width: 250px;
}

.login_panel button:active {
  transform: translateY(1px);
  box-shadow: 0 2px 6px rgba(84, 121, 231, 0.25);
}

/* **************
 * Layout de base  carte et panneau SOS
 * **************/

.panel {
  background: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* 1er panneau en entete, garde sa taille, le reste s’étire */
.panel:first-of-type {
  display: flex;
  flex: 0 0 auto;
}

/* Le 2e panneau (celui qui contient la grille + la map) prend tout le reste */
.panel:nth-of-type(2) {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0; /* crucial pour éviter l’overflow en flex */
}

/* La grille à l’intérieur doit aussi grandir */
.panel:nth-of-type(2) > .grid {
  display: flex;
  flex: 1 1 auto; /* prend tout l’espace restant */
  flex-wrap: wrap; /* permet de passer en vertical sur petit écran */
  min-height: 0; /* IMPORTANT: permet de rétrécir si besoin */
}

/* Colonne gauche */
.left {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 16px;
  border-right: 1px solid var(--border);
  border-bottom-left-radius: var(--radius);
  min-height: 0;
  overflow: auto;
  background: transparent;
}
@media (max-width: 900px) {
  .left {
    border-right: none;
  }
}

/* Colonne droite - Carte */
.right {
  padding: 16px;
  border-bottom-right-radius: var(--radius);
  display: flex; /* Colonne droite en flex pour que la carte grandisse */
  flex: 1 1 300px; /* Carte pren espace dispo mais 300 au minimum */
  min-height: 0; /* pour éviter l’overflow */
}

.row {
  display: grid;
  gap: 8px;
}

/* ---- Sur smartphone, Réserver de la place à la carte en mobile ---- */
@media (max-width: 900px) {
  /* La colonne droite (carte) doit pouvoir grandir */
  .right {
    padding-top: 0px;
  }
  /* Garantir un plancher de hauteur à la carte */
  .map-wrap,
  #map {
    min-height: 90svh;
    flex: 1 1 auto;
  }
}

/*  sur petits écrans très bas (clavier ouvert, split view…), évite carte trop petite */
@media (max-height: 540px) {
  .map-wrap,
  #map {
    min-height: 90svh;
  }
}

/* ****************
* Layout SOS 
* saisie s'un nouveau point SOS 
* choix et detail du point SOS choisi
* Distance et cap vers le point SOS 
***************** */

.subtitle {
  color: var(--muted);
  font-size: clamp(14px, 2.4vw, 16px);
}

.addsossection {
  display: grid;
  grid-template-rows: 0fr 0fr;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: end;
  padding: 16px;
  position: relative;
  top: 0;
  z-index: 5;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-radius: var(--radius);
}

.addsossection_hide {
  display: none;
}
.addsossection_show {
  display: inline;
}

.addsospills {
  border: 0;
  padding: 0;
  margin: 0;
  display: inline-flex;
  gap: 8px;
  font:
    14px/1.3 system-ui,
    sans-serif;
  align-items: center;
}

.addsospills input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.addsospills label {
  padding: 8px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 9999px;
  background: #fff;
  cursor: pointer;
}

.addsospills input[type="radio"]:focus-visible + label {
  outline: 3px solid #93c5fd; /* focus */
  outline-offset: 2px;
}

.addsospills input[type="radio"]:checked + label {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15) inset;
  font-weight: 600;
}

.field {
  display: grid;
  gap: 8px;
}
.field label {
  font-size: 12px;
  color: var(--muted);
}

.phone-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

input[type="tel"],
input[id="sosLatLon"]{
  width: 150px;
  height: 38px;
  padding: 0px;
  text-align: center;
  font-size: 16px; /* Important, car en dessous ios "Zoom" */
  line-height: 1.3;
  background: #ffffff;
  border: 1px solid #d1d5db; /* gris 300 */
  color: var(--text);
  border-radius: 8px;
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
input[type="tel"]::placeholder,
input[id="sosLatLon"]::placeholder,
input[type="loginPW"]::placeholder {
  color: #9ca3af;
}
input[type="tel"]:focus,
input[id="sosLatLon"]:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

input[id="sosLatLon"] {
  width: 205px;
 
}

input[id="loginPW"].loginPW {
  width: 150px;
  height: 38px;
  padding: 0px;
  text-align: center;
  font-size: 1em;
  background: #ffffff;
  border: 1px solid #d1d5db; 
  color: var(--text);
  border-radius: 1px;
  outline: none;
  margin: 5px 0px 10px 20px;
}

.hint {
  font-size: 12px;
  color: var(--muted);
}
.hint.is-error {
  color: var(--colorerror);
}
.hint.is-ok {
  color: var(--colorsuccess);
}


/* Bouton principal */
button.primary {
  padding: 12px 16px;
  cursor: not-allowed;
  opacity: 0.3;
  background-color: #1677ff;
  color: white;
  border: 1px none gray;
  border-radius: 10px;
  font-size: 13px;
  /*height: 30px;*/
  font-weight: bold;
}
button.primary.enabled {
  cursor: pointer;
  opacity: 1;
}
button.primary.enabled:active {
  transform: translateY(1px);
  box-shadow: 0 2px 6px rgba(84, 121, 231, 0.25);
}
button.secondary {
  padding: 12px 16px;
  cursor: not-allowed;
  opacity: 1;
  background-color: #ff1616;
  color: white;
  border: 1px none gray;
  border-radius: 10px;
  font-size: 13px;
  /*height: 30px;*/
  font-weight: bold;
}
button.secondary {
  cursor: pointer;
}
button.secondary:active {
  transform: translateX(2px);
  transform: translateY(2px);
  box-shadow: 0 2px 6px rgba(255, 255, 255, 0.8);
}

#reloadBtn {
  height: 36px;
  width: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  border: 1px none gray;
  font-size: 13px;
  /*height: 30px;*/
  font-weight: bold;
  background-color: #1677ff;
  cursor: pointer;
  opacity: 1;
  padding: 0;
  line-height: 1;
  position: relative;
  content: "";
  background-repeat: no-repeat;
  background-position: center;
  background-size: 75% 75%;
  /*background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M21 12a9 9 0 1 1-2.64-6.36' fill='none' stroke='white' stroke-width='3' stroke-linecap='round'/%3E%3Cpath d='M21 3v6h-6' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20.966 11.216 A9 9 0 1 1 18.364 5.636' fill='none' stroke='white' stroke-width='3' stroke-linecap='round'/%3E%3Cpath d='M21 3v6h-6' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

select {
  -webkit-appearance: none; /* Pour Safari et Chrome */
  appearance: none; /* Standard */

  width: 100%;
  padding: 10px 12px;
  background: #ffffff;
  color: var(--text);
  border: 1px solid #d1d5db;
  border-radius: 10px;
  outline: none;
}
select:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

/* Bloc détailsdu point SOS*/
.details {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 8px;
}
.details h3 {
  margin: 0;
  font-size: 16px;
  color: #0f172a;
}
.detailItems {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 5px 0px;
  font-size: 14px;
}
.detailItems .actionitem {
  grid-column: 1 / -1; /* occupe toute la largeur de la grille */
  display: grid;
  grid-template-columns: 100px 4fr 1fr; /* 3 colonnes personnalisées */
  gap: 5px 0px;
}

.detailItems .label {
  color: var(--muted);
}
.detailItems .value {
  color: var(--text);
  word-break: break-word;
}
.detailItems #detailCoords.value {
  /* Place pour coordonée est long text */
  margin-right: -10px;
}

.detailItems .action {
  /* Les boutons action lié à un item de détail., p.e. la poubelle pour supprimer le SOS*/
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
}

.detailItems .action:disabled {
  opacity: 0.2;
  cursor: not-allowed;
  pointer-events: none; /* empêche les hover et clics */
}

/* ****************
/* La carte openlayer (carte + bordures) occupe tout l’espace dispo
****************** */
.map-wrap {
  flex: 1 1 auto;
  display: flex;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden; /* fin d'avoir les coins de OL arrondi, */
}

/* La carte remplit son conteneur */
#map {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  width: 100%;
}

/* Badge statut */
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff 0%, #f3f4f6 100%);
  font-size: 12px;
  color: #374151;
  width: fit-content;
}

.pill {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 1px;
  font-size: 0.85rem;
  border: 1px solid #2f5167;
  box-shadow: 2px 2px 6px rgba(253, 253, 253, 0.99);
}

.ok {
  color: green;
  background: rgba(31, 169, 113, 0.12);
  border-color: #205c46;
}

.warn {
  color: orange;
  background: rgba(230, 165, 0, 0.14);
  border-color: #6b5211;
}

.bad {
  color: red;
  background: rgb(251, 228, 228);
  border-color: red;
}

.ol-zoom {
  top: 12px; /* distance du haut */
  left: 12px; /* distance de la gauche */
}

/* Boutons + et - */
#map .ol-zoom button {
  background: #1677ff; /* bleu */
  color: #fff; /* texte/icône blanc */
  border: none;
  border-radius: 10px; /* arrondi : mets 9999px pour circulaire */
  width: 36px;
  height: 36px;
  line-height: 36px; /* centre le “+”/“−” verticalement */
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition:
    transform 0.05s ease,
    filter 0.15s ease,
    background-color 0.15s ease;
}

/* Survol / focus / actif */
.ol-zoom button:hover {
  filter: brightness(1.05);
}
.ol-zoom button:focus {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.ol-zoom button:active {
  transform: translateY(1px);
}

.ol-zoom-in,
.ol-zoom-out {
  border-radius: 10px;
}

/* espacement entre + et - */
.ol-zoom .ol-zoom-in {
  margin-bottom: 6px;
}

/* changer le fond du conteneur lui-même */
.ol-zoom.ol-control {
  background: transparent; 
  box-shadow: none;
}

/* ********
Pour le popup dans OpenLayer
*/
.mapIcon-popup {
  position: absolute;
  transform: translate(-50%, -8px);
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 10px;
  box-shadow:
    0 6px 24px rgba(17, 24, 39, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.08);
  padding: 10px 12px 10px 12px;
  width: 300px;
  max-width: 350px;
  min-width: 180px;
  z-index: 10000;
  display: none;
}
.mapIcon-popup.open {
  display: block;
}
.mapIcon-popup .mapIcon-popup-close {
  position: absolute;
  right: 6px;
  top: 4px;
  border: 0;
  background: transparent;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.mapIcon-popup .mapIcon-popup-content {
  /* Contenu du popup */
  font:
    14px/1.35 system-ui,
    sans-serif;
  color: #111827;
  padding-right: 18px;
}

.mapIcon-popup .mapIcon-popup-content span.oldposition {
  /* couleur du label si position trop ancienne */
  color: red;
}
.mapIcon-popup .mapIcon-popup-content span.smallinfo {
  /* info secondaire */
  color: var(--muted);
  font-size: smaller;
}

.mapIcon-popup .mapIcon-popup-content hr {
  /* séparateur dans la boite d'info, ligne grise légère */
  border: none;
  border-top: 0.5px solid #8e8d8d;
}

.mapIcon-popup .mapIcon-popup-content .row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 0px 0;
}

.mapIcon-popup .mapIcon-popup-content .row input[type="checkbox"] {
  accent-color: #2563eb; /* blue focus */
}

.mapIcon-hover-tooltip {
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  transform: translateY(-2px);
}

/* Position the settings control at top-right, above OL buttons */
.ol-settings {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000; /* above default controls */
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Gear button */
.ol-settings .settings-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 8px;
  background: #1677ff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  color: #fff;
}

/* Popup panel */
.ol-settings .settings-panel {
  min-width: 220px;
  padding: 10px 12px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.16);
  border: 1px solid #e5e7eb;
  display: none;
}
.ol-settings .settings-panel.open {
  display: block;
}

.ol-settings .settings-title {
  font-weight: 600;
  margin-top: 5px;
  margin-bottom: 1px;
}

.ol-settings .row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 0px 0;
}

.ol-settings .row input[type="radio"] {
  accent-color: #2563eb; /* blue focus */
}

.ol-settings .row input[type="checkbox"] {
  accent-color: #2563eb; /* blue focus */
}
.ol-settings .row input[type="checkbox"]:disabled + span {
  color: var(
    --muted
  ); /*le label de checkbox déactivée (p.e. si user readonly)*/
}
.ol-settings .row input[type="checkbox"]:disabled + span::after {
  content: " (accès restreint)";
  font-size: 0.8em;
}

/* ***********************
  * Bare de titre et menu hamburger
  *************************/

/* Le header garde sa taille, le reste s’étire */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0px 0px;
  position: sticky;
  top: 0;
  background: var(--bgcolorapp);
  backdrop-filter: blur(10px);
  z-index: 50;
}

/* Page Title */
.topbar .title {
  font-size: clamp(22px, 4vw, 34px);
  font-weight: 800;
  letter-spacing: 0.3px;
  color: var(--appcolormenu);
}

/* icon monitoring status  */
.topbar .system-status {
  display: flex;
  align-items: center;
  gap: 2px;
  font-family: system-ui, sans-serif;
  font-size: 14px;
}
.topbar .status-ok {
  color: #28a22e;
  font-size: 18px;
}
.topbar .status-warning {
  color: #fbc635db;
  font-weight: 700;
  font-size: 18px;
}
.topbar .status-error {
  color: #ff2727;
  font-weight: 700;
  font-size: 20px;
}
.topbar .status-text {
  font-size: 11px;
  opacity: 0.8;
  color: var(--appcolormenu);
}

/* menu-toggle button */
.menu-toggle {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 0px;
  background: var(--bgcolorapp);
  cursor: pointer;
  color: var(--appcolormenu);
}
.menu-toggle:hover {
  background: rgba(255, 255, 255, 0.7);
}

/* Backdrop */
.menu-backdrop {
  position: fixed;
  top: 40px;
  left: 0px;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(2px);
  z-index: 1000;
}

/* Drawer vertical (toujours) */
.menu-panel {
  list-style: none;
  margin: 0;
  padding: 0.75rem;
  position: fixed;
  top: 40px;
  right: 0px;
  height: 100dvh;
  width: min(240px, 86vw);
  background: var(--bgcolorapp);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transform: translateX(105%);
  transition: transform 0.18s ease;
  z-index: 1001;
}
.menu-panel.open {
  transform: translateX(0);
}

.menu-panel .menu-item {
  color: var(--appcolormenu);
  font-size: 12px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid transparent;
  background: transparent;
  padding: 0.65rem 0.75rem;
  border-radius: 0.9rem;
  cursor: pointer;
  text-align: left;
  transition:
    background-color 0.12s ease,
    border-color 0.12s ease,
    transform 0.06s ease;
}

.menu-panel .menu-item:hover,
.menu-panel .menu-item:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  border-color: #4da3ff;
  outline: none;
}
.menu-panel .menu-item:active {
  transform: translateY(1px);
}

/* Disabled: pas cliquable */
.menu-panel .menu-item[disabled] {
  cursor: not-allowed;
  pointer-events: none;
}

.menu-panel .menu-item i {
  font-size: 20px;
  width: 20px;
  text-align: center;
}

.menu-panel .menu-item .section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.menu-panel .menu-item .section .label {
  color: var(--muted);
}
.menu-panel .menu-item .section .value {
  font-size: 14px;
  font-weight: 650;
}

.menu-panel .menu-item.disconnect {
  color: var(--danger);
}

/* *********
   Modal Popup 
   pour afficher lees infomations, documents et  outils du menu 
   basé sur hystmodal
********** */

.hystmodal {
  padding : 20px; /*afin de pas toucher les bord sur smarthone */ 
  max-width: 90%
}

 .hystmodal__shadow { backdrop-filter: blur(2px);}
 .hystmodal__shadow--show {
  opacity:0.7;}

.hystmodal .popupWindow {
  min-width: 220px;
  padding: 0;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.16);
  border: 1px solid #e5e7eb;
}

.hystmodal .popupCloseButton {
  position: absolute;
  z-index: 10;
  top: 5px;
  right: 5px;
  display: block;
  width: 20;
  height: 20;
  background-color: transparent;
  border: none;
  font-size: 15px;
  cursor: pointer;
  outline: none;
  color: var(--appcolormenu);
}

.hystmodal .popupTitle {
  position: relative;
  margin: -1px -1px 0px -1px;
  background-color: var(--bgcolorapp);
  border-radius: 10px 10px 0px 0px;
  border: 1px 1px 0px 1px solid #e5e7eb;
  color: var(--appcolormenu);
  line-height: 1.8rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-align: center;
}
.hystmodal .popupContent {
  margin: 10px;
}

.hystmodal .popupContent h3 {
  padding: 5px 0px 10px 0px;
  font-size: 1.2em;
  font-weight: bold;
  margin-block: 0px;
}
.hystmodal .popupContent h4 {
  margin: 5px 0px 10px 0px;
  font-size: 1em;
  font-weight: bold;
  margin-block: 0px;
}

.hystmodal .popupContent .convert-gps {
  display: grid;
  gap: 6px;
}

.hystmodal .popupContent .convert-label {
  font-weight: 600;
}

.hystmodal .popupContent .convert-input {
  width: 205px;
  padding: 10px 12px;
  border: 1px solid #cfd6dd;
  border-radius: 8px;
  font-size: 16px; /* Important, car en dessous ios "Zoom" */
  line-height: 1.3;
}

.hystmodal .popupContent .convert-input:focus {
  outline: none;
  border-color: #7aa6c2;
  box-shadow: 0 0 0 3px rgba(122, 166, 194, 0.25);
}

.hystmodal .popupContent .convert-help {
  display:block;
  min-height: 80px; /* garde la place même vide */
  font-size: 16px;
  color: #4b5563;
}

.hystmodal .popupContent .convert-help.is-error {
  color: var(--colorerror);
}

.hystmodal .popupContent .convert-help.is-ok {
  color: var(--colorsuccess);
}

