/* =========================================================================
   Thème de l'intranet HPSM — à charger APRÈS bootstrap.min.css
   Couleurs et typographie issues de la charte graphique (Itada Studio, 2021).
   Pour changer l'apparence, modifier d'abord les variables ci-dessous.
   ========================================================================= */

/* --- Police Montserrat (fichiers locaux, pas de dépendance à Google) --- */
@font-face { font-family: "Montserrat"; font-weight: 400; font-display: swap; src: url("../fonts/montserrat-400.a46fb7aae992.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-weight: 500; font-display: swap; src: url("../fonts/montserrat-500.1032e86f9b5d.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-weight: 600; font-display: swap; src: url("../fonts/montserrat-600.abb0e70f5165.woff2") format("woff2"); }

:root {
  /* Charte HPSM */
  --hpsm-navy: #002348;        /* bleu principal */
  --hpsm-navy-dark: #0D1B2C;   /* bleu nuit */
  --hpsm-mist: #DDE5EB;        /* gris-bleu clair */
  --hpsm-mist-light: #EEF2F5;  /* fond des pages (dérivé du gris-bleu) */
  --hpsm-taupe: #A28D7E;       /* accent (Bistrot 1954) */

  /* Formes */
  --hpsm-radius: 0.75rem;
  --hpsm-radius-tile: 1.25rem;
  --hpsm-shadow: 0 1px 2px rgba(13, 27, 44, 0.06), 0 4px 12px rgba(13, 27, 44, 0.06);
  --hpsm-shadow-hover: 0 2px 4px rgba(13, 27, 44, 0.08), 0 10px 24px rgba(13, 27, 44, 0.12);
  --hpsm-topbar-height: 56px;
  --hpsm-touch: 44px;          /* taille minimale d'une cible tactile */

  /* Surcharge des variables Bootstrap */
  --bs-primary: var(--hpsm-navy);
  --bs-primary-rgb: 0, 35, 72;
  --bs-body-font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-body-color: var(--hpsm-navy-dark);
  --bs-body-color-rgb: 13, 27, 44;
  --bs-body-bg: #fff;           /* fond des cartes et des champs */
  --bs-link-color: var(--hpsm-navy);
  --bs-link-color-rgb: 0, 35, 72;
  --bs-link-hover-color: #000f1f;
  --bs-border-radius: 0.5rem;
  --bs-focus-ring-color: rgba(0, 35, 72, 0.25);
}

body { background-color: var(--hpsm-mist-light); }  /* fond des pages */

/* --- Boutons et champs aux couleurs HPSM --- */
.btn-primary {
  --bs-btn-bg: var(--hpsm-navy);
  --bs-btn-border-color: var(--hpsm-navy);
  --bs-btn-hover-bg: #001a36;
  --bs-btn-hover-border-color: #001a36;
  --bs-btn-active-bg: var(--hpsm-navy-dark);
  --bs-btn-active-border-color: var(--hpsm-navy-dark);
  --bs-btn-disabled-bg: var(--hpsm-navy);
  --bs-btn-disabled-border-color: var(--hpsm-navy);
  --bs-btn-focus-shadow-rgb: 0, 35, 72;
}
.btn-outline-primary {
  --bs-btn-color: var(--hpsm-navy);
  --bs-btn-border-color: var(--hpsm-navy);
  --bs-btn-hover-bg: var(--hpsm-navy);
  --bs-btn-hover-border-color: var(--hpsm-navy);
  --bs-btn-active-bg: var(--hpsm-navy-dark);
  --bs-btn-focus-shadow-rgb: 0, 35, 72;
}
.btn { min-height: var(--hpsm-touch); display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.btn-sm { min-height: 0; }
.form-control, .form-select { min-height: var(--hpsm-touch); }
.form-control:focus, .form-select:focus, .form-check-input:focus {
  border-color: #5b7a99;
  box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color);
}
.form-check-input:checked { background-color: var(--hpsm-navy); border-color: var(--hpsm-navy); }
.dropdown-menu { --bs-dropdown-link-active-bg: var(--hpsm-navy); }
.form-label { font-weight: 500; }

/* Titres : Montserrat en majuscules espacées, comme les intertitres de la charte */
.hpsm-title {
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--hpsm-navy);
}

.trisquel { width: 2.25rem; height: auto; display: block; }

/* =========================================================================
   Barre du haut (accueil et applications)
   ========================================================================= */
.topbar {
  background: var(--hpsm-navy);
  color: #fff;
  min-height: var(--hpsm-topbar-height);
  position: sticky;
  top: 0;
  /* Au-dessus du fond grisé du panneau latéral (1040), sinon le menu serait recouvert */
  z-index: 1041;
}
.topbar a, .topbar .btn-topbar { color: #fff; text-decoration: none; }
.topbar-brand { display: flex; align-items: center; gap: .6rem; font-weight: 500; letter-spacing: .15em; text-transform: uppercase; font-size: .85rem; }
.btn-topbar {
  background: transparent;
  border: 0;
  min-width: var(--hpsm-touch);
  min-height: var(--hpsm-touch);
  border-radius: .5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  position: relative;
}
.btn-topbar:hover, .btn-topbar:focus-visible { background: rgba(255, 255, 255, .12); }
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--hpsm-mist);
  color: var(--hpsm-navy);
  font-size: .8rem; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}

/* =========================================================================
   Écran d'accueil : grille de tuiles
   ========================================================================= */
.home-greeting { color: var(--hpsm-navy); }
/* Tuiles centrées (comme un écran d'accueil de téléphone), --per-row tuiles par ligne */
.app-grid {
  --per-row: 3;                            /* téléphone : 3 par ligne */
  --gap-x: .75rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem var(--gap-x);
  max-width: 1040px;
  margin: 0 auto;
}
.app-grid > * { width: calc((100% - (var(--per-row) - 1) * var(--gap-x)) / var(--per-row)); }
@media (min-width: 576px) { .app-grid { --per-row: 4; --gap-x: 1.25rem; row-gap: 2rem; } }   /* tablette */
@media (min-width: 992px) { .app-grid { --per-row: 6; --gap-x: 1.5rem; row-gap: 2.25rem; } } /* ordinateur */

.app-tile {
  display: flex; flex-direction: column; align-items: center; gap: .55rem;
  text-decoration: none; color: var(--hpsm-navy-dark);
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.app-tile-icon {
  position: relative;
  width: 100%; max-width: 96px; aspect-ratio: 1;
  border-radius: var(--hpsm-radius-tile);
  background: var(--tile-color, var(--hpsm-navy));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(1.8rem, 9vw, 2.6rem);
  box-shadow: var(--hpsm-shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.app-tile:hover .app-tile-icon, .app-tile:focus-visible .app-tile-icon { transform: translateY(-3px); box-shadow: var(--hpsm-shadow-hover); }
.app-tile:active .app-tile-icon { transform: scale(.96); }
.app-tile-name { font-size: .82rem; font-weight: 500; line-height: 1.2; }
.app-badge {
  position: absolute; top: -.4rem; right: -.4rem;
  min-width: 1.5rem; height: 1.5rem; padding: 0 .4rem;
  border-radius: 1rem;
  background: #C2410C; color: #fff;
  font-size: .75rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--hpsm-mist-light);
}

/* =========================================================================
   Gabarit d'application : menu, fil d'Ariane, barre d'actions
   ========================================================================= */
.app-title { display: flex; align-items: center; gap: .5rem; font-weight: 600; white-space: nowrap; }
.app-title-icon {
  width: 30px; height: 30px; border-radius: .5rem;
  background: var(--tile-color, var(--hpsm-mist));
  display: inline-flex; align-items: center; justify-content: center; font-size: 1rem;
}
/* Menu de l'application : en ligne sur ordinateur, panneau latéral sur téléphone */
.app-menu .nav-link { color: rgba(255, 255, 255, .85); padding: .5rem .8rem; border-radius: .5rem; }
.app-menu .nav-link:hover, .app-menu .nav-link.active { color: #fff; background: rgba(255, 255, 255, .12); }
@media (max-width: 991.98px) {
  .app-menu.offcanvas-lg { background: var(--hpsm-navy); color: #fff; width: 280px; }
  .app-menu .nav-link { min-height: var(--hpsm-touch); display: flex; align-items: center; }
  .app-menu .dropdown-menu { position: static !important; transform: none !important; background: transparent; border: 0; padding-left: 1rem; }
  .app-menu .dropdown-item { color: rgba(255, 255, 255, .85); min-height: var(--hpsm-touch); display: flex; align-items: center; border-radius: .5rem; }
  .app-menu .dropdown-item:hover { background: rgba(255, 255, 255, .12); color: #fff; }
}
.action-bar {
  background: #fff;
  border-bottom: 1px solid var(--hpsm-mist);
}
.breadcrumb { --bs-breadcrumb-margin-bottom: 0; font-size: .85rem; }
.breadcrumb a { text-decoration: none; }

/* =========================================================================
   Composants communs
   ========================================================================= */
.card { border: 0; border-radius: var(--hpsm-radius); box-shadow: var(--hpsm-shadow); }

/* Liste : tableau sur ordinateur, cartes empilées sur téléphone.
   Usage : <table class="table table-cards"> et <td data-label="Statut"> sur chaque cellule. */
.table-cards { --bs-table-bg: #fff; border-radius: var(--hpsm-radius); overflow: hidden; box-shadow: var(--hpsm-shadow); }
.table-cards th { font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #5b6b7a; }
.table-cards td, .table-cards th { vertical-align: middle; padding: .8rem 1rem; }
.table-cards tbody tr.row-link { cursor: pointer; }
.table-cards tbody tr.row-link:hover td { background: #f7f9fb; }
@media (max-width: 767.98px) {
  .table-cards { background: transparent; box-shadow: none; border-radius: 0; overflow: visible; }
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { background: #fff; border-radius: var(--hpsm-radius); box-shadow: var(--hpsm-shadow); margin-bottom: .75rem; padding: .6rem .9rem; }
  .table-cards td { border: 0; padding: .3rem 0; display: flex; justify-content: space-between; align-items: center; gap: 1rem; text-align: right; }
  .table-cards td::before { content: attr(data-label); font-size: .75rem; font-weight: 600; color: #5b6b7a; text-transform: uppercase; letter-spacing: .05em; text-align: left; }
  .table-cards td.card-title-cell { font-weight: 600; text-align: left; }
  .table-cards td.card-title-cell::before { content: none; }
}

/* Bouton d'action flottant (téléphone) */
.fab {
  position: fixed; right: 1.25rem; bottom: calc(1.25rem + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--hpsm-navy); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  box-shadow: 0 6px 18px rgba(0, 35, 72, .35);
  z-index: 1020;
  text-decoration: none;
}
.fab:hover, .fab:focus-visible { color: #fff; background: #001a36; }
/* Laisse de la place en bas de page pour que le bouton flottant ne cache rien */
.has-fab { padding-bottom: 6rem; }
@media (min-width: 768px) { .has-fab { padding-bottom: 0; } }

/* =========================================================================
   Pages de connexion
   ========================================================================= */
.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--hpsm-navy);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: var(--hpsm-radius); padding: 2rem 1.5rem; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
@media (min-width: 576px) { .auth-card { padding: 2.5rem; } }
.auth-logo { display: block; width: 150px; height: auto; margin: 0 auto 1.75rem; }
.auth-footer { color: rgba(255, 255, 255, .6); font-size: .75rem; letter-spacing: .15em; text-transform: uppercase; }

/* =========================================================================
   Notifications (cloche)
   ========================================================================= */
.notif-badge {
  position: absolute; top: 4px; right: 2px;
  min-width: 1.15rem; height: 1.15rem; padding: 0 .3rem;
  border-radius: 1rem;
  background: #C2410C; color: #fff;
  font-size: .65rem; font-weight: 600; line-height: 1.15rem; text-align: center;
  border: 2px solid var(--hpsm-navy);
  box-sizing: content-box;
}
.notif-menu { width: min(360px, calc(100vw - 1rem)); overflow: hidden; }
.notif-list { max-height: min(420px, 60vh); overflow-y: auto; }
.notif-item { display: flex; gap: .65rem; align-items: flex-start; padding: .75rem 1rem; }
.notif-dot { flex: 0 0 .5rem; height: .5rem; margin-top: .45rem; border-radius: 50%; background: transparent; }
.notif-item.unread { background: #f3f6f9; }
.notif-item.unread .notif-dot { background: #C2410C; }
.notif-item.unread .notif-title { font-weight: 600; }
/* Les menus déroulants de droite (cloche, compte) sont dans la barre bleue : on y annule le texte blanc */
.topbar .dropdown-menu-end a { color: var(--hpsm-navy-dark); }
.topbar .dropdown-menu-end a.dropdown-item:active { color: #fff; }
/* Téléphone : le menu de la cloche occupe toute la largeur sous la barre (jamais coupé) */
@media (max-width: 575.98px) {
  .notif-menu.show {
    position: fixed !important;
    inset: var(--hpsm-topbar-height) .5rem auto .5rem !important;
    transform: none !important;
    width: auto;
  }
}

/* =========================================================================
   Pastilles colorées (statuts, priorités) — composant core/components/badge.html
   ========================================================================= */
.badge-soft {
  display: inline-block;
  padding: .3em .7em;
  border-radius: 1rem;
  font-size: .75rem; font-weight: 600; line-height: 1.2;
  white-space: nowrap;
}
.badge-soft-blue   { background: #DBEAFE; color: #1E40AF; }
.badge-soft-indigo { background: #E0E7FF; color: #3730A3; }
.badge-soft-orange { background: #FFEDD5; color: #9A3412; }
.badge-soft-amber  { background: #FEF3C7; color: #92400E; }
.badge-soft-green  { background: #DCFCE7; color: #166534; }
.badge-soft-red    { background: #FEE2E2; color: #991B1B; }
.badge-soft-gray   { background: #E5E7EB; color: #374151; }

/* Ligne de liste entièrement cliquable (avec un lien .stretched-link dans la ligne) */
.table-cards tbody tr { position: relative; }
.table-cards tbody tr:hover td { background: #f7f9fb; }

/* =========================================================================
   Grille de photos (vignettes carrées) et fil d'activité
   ========================================================================= */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; }
.photo-tile {
  aspect-ratio: 1; border-radius: .5rem; overflow: hidden;
  background: var(--hpsm-mist-light); border: 1px solid var(--hpsm-mist);
  display: flex; align-items: center; justify-content: center;
  color: var(--hpsm-navy); text-decoration: none;
}
.photo-tile img { width: 100%; height: 100%; object-fit: cover; }
.photo-file { display: flex; flex-direction: column; align-items: center; gap: .25rem; padding: .5rem; font-size: 1.8rem; max-width: 100%; }
.photo-file small { font-size: .7rem; max-width: 100%; }

.timeline > li + li { margin-top: .75rem; }
.timeline-comment { background: var(--hpsm-mist-light); border-radius: .75rem; padding: .75rem 1rem; }
.timeline-comment.internal { background: #FEF9C3; border: 1px dashed #EAB308; }
.timeline-event { padding-left: .25rem; }

/* Fiche : informations en liste libellé / valeur */
.ticket-info { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; }
.ticket-info dt { font-weight: 500; color: #5b6b7a; font-size: .85rem; }
.ticket-info dd { margin: 0; }

/* Compteur cliquable de tableau de bord (chiffre + libellé) */
.stat-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  height: 100%; padding: 1rem .5rem;
  background: #fff; border-radius: var(--hpsm-radius); box-shadow: var(--hpsm-shadow);
  color: var(--hpsm-navy-dark); text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card:hover, .stat-card:focus-visible { transform: translateY(-2px); box-shadow: var(--hpsm-shadow-hover); color: var(--hpsm-navy-dark); }
.stat-value { font-size: 1.9rem; font-weight: 600; line-height: 1.1; color: var(--hpsm-navy); }
.stat-label { font-size: .78rem; font-weight: 500; color: #5b6b7a; }
.stat-card.stat-alert .stat-value { color: #B91C1C; }
