/* ============================================================
   Portail HER - charte graphique
   Rouge #E2001A / blanc / texte gris fonce - Arial
   ============================================================ */

:root {
  --her-red:        #E2001A;
  --her-red-dark:   #B30015;
  --her-ink:        #2B2B2B;   /* texte gris fonce */
  --her-ink-soft:   #6B6B6B;   /* texte secondaire */
  --her-bg:         #F4F4F5;   /* fond de page */
  --her-line:       #E3E3E5;   /* filets / bordures */
  --her-white:      #FFFFFF;
  --her-radius:     10px;
  --her-shadow:     0 2px 14px rgba(0, 0, 0, .07);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  color: var(--her-ink);
  background: var(--her-bg);
  line-height: 1.55;
}

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

/* ---------- En-tete ---------- */
.her-header { position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  height: 64px;
  background: var(--her-red);
  color: var(--her-white);
  box-shadow: var(--her-shadow);
}
.her-header__brand { display: flex; align-items: center; gap: 14px; }
.her-logo { height: 38px; width: auto; display: block; background: #fff; padding: 3px 6px; border-radius: 6px; }
.her-title { font-size: 19px; font-weight: bold; letter-spacing: .2px; }
.her-nav { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.her-nav a { color: var(--her-white); font-weight: bold; }
.her-user { color: rgba(255, 255, 255, .9); font-size: 13px; }

/* ---------- Zone principale ---------- */
.her-main {
  max-width: 1400px;
  margin: 40px auto;
  padding: 0 20px;
}
/* Variante pleine largeur pour les pages a tableaux denses (parametres, apps, fiche app). */
.her-main--wide { max-width: none; }

/* ---------- Cartes ---------- */
.her-card {
  background: var(--her-white);
  border: 1px solid var(--her-line);
  border-top: 4px solid var(--her-red);
  border-radius: var(--her-radius);
  box-shadow: var(--her-shadow);
  padding: 30px 32px;
}
.her-card h1 {
  margin: 0 0 6px;
  font-size: 23px;
  color: var(--her-ink);
}
.her-card h3 {
  margin: 22px 0 6px;
  font-size: 15px;
  color: var(--her-red-dark);
}
.lead  { color: var(--her-ink-soft); margin: 0 0 22px; }
.muted { color: var(--her-ink-soft); font-size: 14px; }

/* ---------- Formulaires ---------- */
label {
  display: block;
  margin: 16px 0 6px;
  font-weight: bold;
  font-size: 14px;
}
input[type=text],
input[type=email],
input[type=password],
select {
  width: 100%;
  padding: 11px 13px;
  font-size: 15px;
  font-family: inherit;
  color: var(--her-ink);
  border: 1px solid var(--her-line);
  border-radius: 8px;
  background: #fff;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--her-red);
  box-shadow: 0 0 0 3px rgba(226, 0, 26, .12);
}

/* ---------- Boutons ---------- */
.btn {
  display: inline-block;
  margin-top: 22px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: bold;
  font-family: inherit;
  color: var(--her-white);
  background: var(--her-red);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s ease;
}
.btn:hover { background: var(--her-red-dark); text-decoration: none; }
.btn--ghost {
  margin: 0;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--her-red);
  background: transparent;
  border: 1px solid var(--her-red);
}
.btn--ghost:hover { color: #fff; background: var(--her-red); }

/* ---------- Messages flash ---------- */
.her-flash {
  margin-bottom: 22px;
  padding: 13px 16px;
  border-radius: 8px;
  border-left: 4px solid;
  font-size: 14px;
}
.her-flash--error   { background: #FDEAEC; border-color: var(--her-red);  color: #8A0012; }
.her-flash--success { background: #EAF6EC; border-color: #2E7D32;         color: #1B5E20; }
.her-flash--info    { background: #EAF1FB; border-color: #1565C0;         color: #0D3F87; }

/* ---------- Tableaux ---------- */
table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 14px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--her-line); vertical-align: top; }
th { color: var(--her-ink-soft); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }

/* ---------- Charte / consentement ---------- */
.charte {
  max-height: 320px;
  overflow-y: auto;
  padding: 6px 18px;
  margin: 10px 0;
  border: 1px solid var(--her-line);
  border-radius: 8px;
  background: #FAFAFB;
  font-size: 14px;
}
.charte p { margin: 4px 0 12px; color: var(--her-ink); }

/* ---------- Cle TOTP ---------- */
.totp-key {
  display: inline-block;
  padding: 8px 12px;
  font-family: "Courier New", monospace;
  font-size: 16px;
  letter-spacing: 2px;
  background: #FAFAFB;
  border: 1px dashed var(--her-red);
  border-radius: 6px;
  color: var(--her-ink);
  word-break: break-all;
}

/* ---------- Pied de page ---------- */
.her-footer {
  max-width: 680px;
  margin: 26px auto 50px;
  padding: 0 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  justify-content: space-between;
  font-size: 12px;
  color: var(--her-ink-soft);
}

/* ---------- Menu hamburger ---------- */
.her-burger { display: none; background: none; border: 0; cursor: pointer; padding: 8px; flex-direction: column; gap: 5px; }
.her-burger span { display: block; width: 24px; height: 2px; background: #fff; border-radius: 2px; transition: transform .2s, opacity .2s; }
.her-burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.her-burger.open span:nth-child(2) { opacity: 0; }
.her-burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Grille d'applications (style iOS) ---------- */
.dash-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 24px 10px; margin-top: 16px; }
.app-tile { display: flex; flex-direction: column; align-items: center; user-select: none; -webkit-user-select: none; }
.app-tile__link { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; color: inherit; text-decoration: none; }
.app-ico { width: 64px; height: 64px; border-radius: 16px; background-size: cover; background-position: center; background-color: #fff; border: 1px solid var(--her-line); box-shadow: 0 4px 12px rgba(0,0,0,.14); display: flex; align-items: center; justify-content: center; transition: transform .12s; }
.app-tile__link:hover .app-ico { transform: translateY(-2px); }
.app-ico--ph { border: none; color: #fff; font-weight: 700; font-size: 22px; letter-spacing: .5px; background-image: linear-gradient(145deg, hsl(var(--ph-h), 62%, 52%), hsl(var(--ph-h), 62%, 38%)); }
.app-tile__name { font-size: 12.5px; line-height: 1.25; text-align: center; color: var(--her-ink); max-width: 86px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.app-tile--off { opacity: .5; }
.app-tile--off .app-ico { filter: grayscale(1); box-shadow: 0 2px 6px rgba(0,0,0,.1); }
.app-tile--off .app-tile__link { cursor: not-allowed; }
.app-tile--off .app-tile__name { color: var(--her-ink-soft); }

/* mode reorganisation */
.app-grid.editing .app-tile { touch-action: none; cursor: grab; animation: her-wiggle .25s infinite alternate ease-in-out; }
.app-grid.editing .app-tile__link { pointer-events: none; }
.app-tile.dragging { z-index: 999; cursor: grabbing; opacity: .95; transform: scale(1.06); animation: none; box-shadow: 0 10px 24px rgba(0,0,0,.22); }
.app-tile--ph { animation: none !important; }
.app-tile--ph .app-ico, .app-tile--ph .app-tile__name { visibility: hidden; }
.app-tile--ph { border: 2px dashed var(--her-line); border-radius: 16px; box-sizing: border-box; }
@keyframes her-wiggle { from { transform: rotate(-1.3deg); } to { transform: rotate(1.3deg); } }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .her-burger { display: flex; }
  .her-header { padding: 0 16px; }
  .her-nav {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 900;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--her-red); box-shadow: var(--her-shadow);
    padding: 4px 0; display: none;
  }
  .her-nav.open { display: flex; }
  .her-nav a { padding: 12px 18px; width: 100%; }
  .her-user { display: block; padding: 10px 18px; border-bottom: 1px solid rgba(255,255,255,.2); }
  .her-card { padding: 22px 18px; }
}
@media (max-width: 560px) {
  .app-grid { gap: 22px 6px; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
}

/* Bandeau d'environnement de test */
.her-testbar{display:block;background:#E2001A;color:#fff;text-align:center;
  font-weight:bold;padding:8px 12px;text-decoration:none;font-size:14px;
  position:sticky;top:0;z-index:1000;letter-spacing:.2px}
.her-testbar:hover{background:#C8102E;color:#fff}

/* ---------- Console de catalogue : formulaire d'accès ---------- */
.access-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.access-form select,
.access-form input[type="date"],
.access-form input[type="url"] {
  padding: 9px 11px; font-size: 14px; color: var(--her-ink);
  border: 1px solid var(--her-line); border-radius: 8px; background: #fff;
}
.access-form select:focus,
.access-form input[type="date"]:focus,
.access-form input[type="url"]:focus { outline: none; border-color: var(--her-red); }

/* ---------- Codes de récupération TOTP ---------- */
.recovery-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; max-width: 360px; }
.recovery-code {
  font-family: "Courier New", monospace; font-size: 17px; letter-spacing: 2px;
  text-align: center; padding: 10px 8px; color: var(--her-ink);
  background: #FAFAFB; border: 1px dashed var(--her-red); border-radius: 8px; user-select: all;
}
@media (max-width: 460px) { .recovery-grid { grid-template-columns: 1fr; } }

/* ---------- Tableaux responsives (cartes empilées sur mobile) ---------- */
@media (max-width: 760px) {
  .responsive-table thead { display: none; }
  .responsive-table,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td { display: block; width: 100%; }
  .responsive-table tr {
    border: 1px solid var(--her-line); border-radius: 12px;
    padding: 14px 16px; margin-bottom: 14px; background: #fff;
    box-shadow: var(--her-shadow);
  }
  .responsive-table td { border: none; padding: 7px 0; text-align: left; }
  .responsive-table td + td { border-top: 1px solid #F1F1F3; padding-top: 11px; }
  .responsive-table td::before {
    content: attr(data-label); display: block;
    font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .3px;
    color: var(--her-ink-soft); margin-bottom: 4px;
  }
  /* Cellule "Utilisateur" : en-tête de la carte, sans label ni séparateur. */
  .responsive-table td[data-label="Utilisateur"] { padding-top: 0; }
  .responsive-table td[data-label="Utilisateur"]::before { display: none; }
  .responsive-table td[data-label="Utilisateur"] strong { font-size: 16px; }
  /* Cellule d'action finale (lien "Gérer les accès") : pleine largeur, sans label. */
  .responsive-table td[data-label=""]::before { display: none; }
  .responsive-table td[data-label=""] .btn { display: block; text-align: center; }
  /* Champs confortables au doigt. */
  .responsive-table td[data-label="Profil"] form { flex-wrap: wrap; }
  .responsive-table td[data-label="Profil"] select { flex: 1 1 auto; min-width: 150px; }
}

/* ===== Menu « Favoris » du bandeau portail ===== */
.her-fav { position: relative; }
.her-fav-btn {
  background: transparent; border: 1px solid rgba(255,255,255,.55);
  color: #fff; border-radius: 999px; padding: 4px 12px; cursor: pointer;
  font: inherit; font-size: 14px; line-height: 1.4; white-space: nowrap;
}
.her-fav-btn:hover { background: rgba(255,255,255,.15); }
.her-fav-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 240px; max-width: 320px; background: #fff; color: #2B2B2B;
  border: 1px solid #ececec; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.16);
  padding: 6px; z-index: 60;
}
.her-fav.open .her-fav-menu { display: block; }
.her-fav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 8px; color: #2B2B2B !important; text-decoration: none;
}
.her-fav-item:hover { background: #f6f6f6; }
.her-fav-item.is-off { opacity: .5; pointer-events: none; }
.her-fav-item .app-ico {
  width: 26px; height: 26px; border-radius: 7px; background-size: cover;
  background-position: center; flex: 0 0 auto;
}
@media (max-width: 760px) {
  .her-fav { width: 100%; }
  .her-fav-btn { width: 100%; text-align: left; }
  .her-fav-menu {
    position: static; min-width: 0; max-width: none; box-shadow: none;
    border: none; padding: 4px 0 4px 12px;
  }
}

/* ---------- Éditeur RichText (page Paramètres) ---------- */
.rte { border: 1px solid var(--her-line); border-radius: 8px; overflow: hidden; }
.rte-toolbar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 6px; background: #f6f7f9; border-bottom: 1px solid var(--her-line); }
.rte-b { border: 1px solid var(--her-line); background: #fff; border-radius: 6px; padding: 4px 9px; font: inherit; line-height: 1; cursor: pointer; }
.rte-b:hover { background: #eef0f2; }
.rte-sep { width: 1px; height: 20px; background: var(--her-line); margin: 0 2px; }
.rte-color { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--her-line); border-radius: 6px; padding: 2px 8px; background: #fff; cursor: pointer; font-weight: bold; }
.rte-color input[type=color] { width: 22px; height: 22px; border: 0; padding: 0; background: none; cursor: pointer; }
.rte-editor { min-height: 260px; max-height: 60vh; overflow: auto; padding: 14px 16px; font: inherit; line-height: 1.5; background: #fff; }
.rte-editor:focus { outline: 2px solid rgba(226,0,26,.25); outline-offset: -2px; }
.rte-editor h2 { color: #E2001A; }
.rte-editor h3 { margin: 14px 0 6px; }

/* ---------- Page Mentions règlementaires (/consentement) ---------- */
.consent-card { max-width: none; width: 100%; min-height: 60vh; }
.consent-card .charte { line-height: 1.55; }
.consent-card .charte h2 { color: #E2001A; }
.consent-card .charte h3 { margin: 18px 0 6px; }
@media (max-width: 820px) {
  .consent-card { padding: 16px; }
  .rte-editor { min-height: 200px; }
}
