/* V6.0 — Bandeau cookies, modal préférences, toggle iOS-style, bouton flottant.
   Réutilise les CSS vars portail.css : --alm-blue, --alm-orange, --cta-bg, --tr, --gutter, --container.
   Préserve le design V2 du bandeau (slide-up bottom-0, ombre, layout grid 1fr auto, responsive < 1024px).
*/

/* ===== BANDEAU (compatibilité V2 conservée) ===== */
.alm-cookie-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  box-shadow: 0 -8px 32px rgba(0, 72, 153, 0.15);
  padding: 14px var(--gutter, 24px); /* hauteur compacte (une-ligne desktop) */
  z-index: 9998;
  transform: translateY(100%);
  transition: transform var(--tr, 0.3s ease);
}
@media (min-width: 961px) {
  /* Réserve la largeur du bouton accessibilité flottant (fixed bottom-right,
     ~72px) pour que « Tout accepter » ne passe jamais dessous (point 5). */
  .alm-cookie-banner { padding-right: 96px; }
}
.alm-cookie-banner.open { transform: translateY(0); }
.alm-cookie-banner[hidden] { display: none; }
.alm-cookie-banner:not([hidden]) { display: block; }

/* Layout : bloc empilé ≤960px, UNE ligne horizontale ≥961px
   (marque | texte flex | boutons). */
.alm-cookie-inner {
  max-width: var(--container, 1280px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
@media (min-width: 961px) {
  .alm-cookie-inner {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 24px;
  }
}

/* Marque (logo + titre) : à gauche, jamais compressée. */
.alm-cookie-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  margin: 0;
}
.alm-cookie-brand strong {
  color: var(--alm-blue, #004899);
  font-size: 1rem;
  white-space: nowrap;
}
.alm-cookie-banner__logo { max-height: 30px; width: auto; flex-shrink: 0; }
@media (max-width: 960px) { .alm-cookie-banner__logo { display: none; } }

/* Texte : gris lisible, liens bleus soulignés. */
.alm-cookie-text {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--alm-gray-700, #4a5568);
  line-height: 1.5;
}
.alm-cookie-text a { color: var(--alm-blue, #004899); text-decoration: underline; }
.alm-cookie-text__sep { color: var(--alm-gray-500, #9ca3af); margin: 0 6px; }

/* Desktop : texte au centre (flex:1). Le lead se tronque en ellipsis si besoin,
   mais les 2 liens légaux restent TOUJOURS visibles (flex-shrink:0). */
@media (min-width: 961px) {
  .alm-cookie-text {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 6px;
  }
  .alm-cookie-text__lead {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .alm-cookie-text__links { flex-shrink: 0; white-space: nowrap; }
}

.alm-cookie-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
@media (min-width: 961px) {
  /* Groupe [Personnaliser][Refuser][Accepter] à droite, jamais compressé. */
  .alm-cookie-actions { flex-shrink: 0; flex-wrap: nowrap; }
}
.alm-cookie-actions .alm-btn {
  padding: 12px 20px;
  font-size: 0.9375rem;
  min-height: 44px; /* cible tactile CNIL/WCAG 2.5.5 */
  text-align: center;
  justify-content: center;
}

/* ===== V6.5-fix — Hiérarchie CNIL (anti dark pattern) =====
   « Tout refuser » et « Tout accepter » = MÊME poids visuel : plein, bleu
   #004899, texte blanc, taille identique. Couleur via var(--alm-blue) → DA-aware :
   devient bordeaux #6b1f3a sous body.subbrand-maternite (comme a11y/langue).
   JAMAIS d'orange (--cta-bg) sur ce bandeau : ce serait rendre « accepter »
   plus attractif que « refuser » = dark pattern. */
.alm-cookie-actions [data-cookie-action="reject"],
.alm-cookie-actions [data-cookie-action="accept"] {
  background: var(--alm-blue, #004899);
  color: #fff;
  border: 2px solid var(--alm-blue, #004899);
  font-weight: 600;
  min-width: 150px;
}
.alm-cookie-actions [data-cookie-action="reject"]:hover,
.alm-cookie-actions [data-cookie-action="accept"]:hover {
  background: var(--alm-blue-dark, #003a7a);
  border-color: var(--alm-blue-dark, #003a7a);
  color: #fff;
  transform: translateY(-1px);
}
.alm-cookie-actions [data-cookie-action="reject"]:focus-visible,
.alm-cookie-actions [data-cookie-action="accept"]:focus-visible {
  outline: 2px solid var(--alm-blue, #004899);
  outline-offset: 2px;
}

/* « Personnaliser » = action TERTIAIRE discrète : lien souligné bleu (ghost),
   jamais un bouton plein coloré. Séparé à gauche des 2 boutons de choix. */
.alm-cookie-actions [data-cookie-action="customize"] {
  background: transparent;
  border: 2px solid transparent;
  color: var(--alm-blue, #004899);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
  min-width: 0;
  padding-left: 6px;
  padding-right: 6px;
  order: -1;          /* Personnaliser en tête du groupe (DOM: reject,customize,accept) */
}
.alm-cookie-actions [data-cookie-action="customize"]:hover {
  background: transparent;
  color: var(--alm-blue-dark, #003a7a);
  text-decoration: underline;
  transform: none;
  box-shadow: none;
}
.alm-cookie-actions [data-cookie-action="customize"]:focus-visible {
  outline: 2px solid var(--alm-blue, #004899);
  outline-offset: 2px;
}

@media (max-width: 960px) {
  /* ≤960px (repli bloc) : boutons empilés pleine largeur ; refuser/accepter
     même largeur. Personnaliser en dernier, lien discret centré dessous. */
  .alm-cookie-actions { flex-direction: column; gap: 10px; }
  .alm-cookie-actions .alm-btn { width: 100%; min-width: 0; }
  .alm-cookie-actions [data-cookie-action="customize"] {
    order: 3;
    margin-right: 0;
    width: 100%;
    text-align: center;
  }
}

/* ===== MODAL PERSONNALISATION ===== */
.alm-cookie-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.alm-cookie-modal[hidden] { display: none; }

.alm-cookie-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 25, 60, 0.6);
  backdrop-filter: blur(2px);
  animation: alm-cookie-fadein 0.2s ease-out;
}

.alm-cookie-modal__inner {
  position: relative;
  background: #fff;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0, 25, 60, 0.4);
  overflow: hidden;
  animation: alm-cookie-modal-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.alm-cookie-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #eaecef;
}
.alm-cookie-modal__header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--alm-blue, #004899);
}
.alm-cookie-modal__close {
  background: none;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: #646970;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.alm-cookie-modal__close:hover { background: #f0f2f4; color: var(--alm-blue, #004899); }
.alm-cookie-modal__close:focus-visible { outline: 2px solid var(--alm-blue, #004899); outline-offset: 2px; }

.alm-cookie-modal__body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}
.alm-cookie-modal__intro {
  margin: 0 0 20px;
  font-size: 0.9375rem;
  color: var(--alm-gray-700, #4a5568);
  line-height: 1.5;
}
.alm-cookie-modal__legal {
  margin: 16px 0 0;
  font-size: 0.8125rem;
  color: var(--alm-gray-600, #6b7280);
}
.alm-cookie-modal__legal a { color: var(--alm-blue, #004899); text-decoration: underline; }

.alm-cookie-modal__footer {
  padding: 16px 24px;
  border-top: 1px solid #eaecef;
  background: #fafbfc;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.alm-cookie-modal__footer .alm-btn {
  padding: 10px 18px;
  font-size: 0.9375rem;
  min-width: 140px;
  justify-content: center;
}

/* ===== V6.5-fix — Footer modale : mêmes tokens que le bandeau (CNIL) =====
   « Tout refuser » et « Tout accepter » = MÊME poids : plein bleu, texte BLANC.
   Zéro orange (accept n'est plus .alm-btn-primary). Couleur via var(--alm-blue)
   → DA-aware bordeaux #6b1f3a sous body.subbrand-maternite. */
.alm-cookie-modal__footer [data-cookie-action="reject"],
.alm-cookie-modal__footer [data-cookie-action="accept"] {
  background: var(--alm-blue, #004899);
  color: #fff;
  border: 2px solid var(--alm-blue, #004899);
  font-weight: 600;
}
.alm-cookie-modal__footer [data-cookie-action="reject"]:hover,
.alm-cookie-modal__footer [data-cookie-action="accept"]:hover {
  background: var(--alm-blue-dark, #003a7a);
  border-color: var(--alm-blue-dark, #003a7a);
  color: #fff;
}
.alm-cookie-modal__footer [data-cookie-action="reject"]:focus-visible,
.alm-cookie-modal__footer [data-cookie-action="accept"]:focus-visible {
  outline: 2px solid var(--alm-blue, #004899);
  outline-offset: 2px;
}
/* « Enregistrer mes choix » = même niveau, neutre & légèrement distinct :
   outline bleu (jamais orange, jamais plein pour ne pas rivaliser avec les 2
   choix). Texte bleu sur blanc (AA) ; au survol, plein bleu + texte blanc. */
.alm-cookie-modal__footer [data-cookie-action="save"] {
  background: transparent;
  color: var(--alm-blue, #004899);
  border: 2px solid var(--alm-blue, #004899);
  font-weight: 600;
}
.alm-cookie-modal__footer [data-cookie-action="save"]:hover {
  background: var(--alm-blue, #004899);
  border-color: var(--alm-blue, #004899);
  color: #fff;
}
.alm-cookie-modal__footer [data-cookie-action="save"]:focus-visible {
  outline: 2px solid var(--alm-blue, #004899);
  outline-offset: 2px;
}

/* V6.0.1 — Bouton retrait consentement (RGPD art. 7§3) : discret mais accessible */
.alm-cookie-withdraw[hidden] { display: none; }
.alm-cookie-withdraw {
  margin-right: auto; /* repousse à gauche pour séparer des 3 boutons principaux */
}
.alm-btn-text.alm-btn-danger {
  background: transparent !important;
  color: #a63b3b !important;
  border: none !important;
  text-decoration: underline;
  padding: 10px 8px;
  min-width: 0;
  font-weight: 500;
  box-shadow: none;
}
.alm-btn-text.alm-btn-danger:hover {
  color: #7a2b2b !important;
  background: rgba(166, 59, 59, 0.06) !important;
}
.alm-btn-text.alm-btn-danger:focus-visible {
  outline: 2px solid #a63b3b;
  outline-offset: 2px;
}
@media (max-width: 600px) {
  .alm-cookie-withdraw { margin-right: 0; order: 99; }
}
@media (max-width: 600px) {
  .alm-cookie-modal__footer { flex-direction: column; }
  .alm-cookie-modal__footer .alm-btn { width: 100%; min-width: 0; }
}

/* ===== CATÉGORIES ===== */
.alm-cookie-category {
  padding: 14px 0;
  border-bottom: 1px solid #eaecef;
}
.alm-cookie-category:last-of-type { border-bottom: none; }

.alm-cookie-category__head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.alm-cookie-category__title {
  margin: 0;
  font-size: 1rem;
  color: var(--alm-blue, #004899);
  flex: 1;
}
.alm-cookie-required {
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  background: #f0f2f4;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
  vertical-align: middle;
}

.alm-cookie-category__desc {
  margin: 4px 0 0 56px;
  font-size: 0.875rem;
  color: var(--alm-gray-700, #4a5568);
  line-height: 1.5;
}
.alm-cookie-category__services {
  margin: 8px 0 0 56px;
  font-size: 0.8125rem;
}
.alm-cookie-category__services summary {
  cursor: pointer;
  color: var(--alm-blue, #004899);
  font-weight: 500;
}
.alm-cookie-category__services ul {
  margin: 6px 0 0;
  padding-left: 20px;
  color: #6b7280;
}

/* ===== TOGGLE iOS-STYLE ===== */
.alm-cookie-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.alm-cookie-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.alm-cookie-toggle__slider {
  position: absolute;
  inset: 0;
  background: #cbd5e0;
  border-radius: 24px;
  transition: background 0.2s ease;
  cursor: pointer;
}
.alm-cookie-toggle__slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}
.alm-cookie-toggle input:checked + .alm-cookie-toggle__slider {
  background: var(--alm-blue, #004899);
}
.alm-cookie-toggle input:checked + .alm-cookie-toggle__slider::before {
  transform: translateX(20px);
}
.alm-cookie-toggle input:disabled + .alm-cookie-toggle__slider {
  opacity: 0.6;
  cursor: not-allowed;
}
/* Essentiels (checked + disabled) : l'état ON doit rester clairement LISIBLE —
   bleu franc + pastille blanche, sans désaturation. Le « verrou » est signalé par
   le curseur not-allowed et le libellé « (toujours actifs) », pas par un fondu qui
   rendrait l'état ambigu. DA-aware : bordeaux sous body.subbrand-maternite. */
.alm-cookie-toggle input:checked:disabled + .alm-cookie-toggle__slider {
  opacity: 1;
  cursor: not-allowed;
  background: var(--alm-blue, #004899);
}
.alm-cookie-toggle input:focus-visible + .alm-cookie-toggle__slider {
  outline: 2px solid var(--alm-blue, #004899);
  outline-offset: 2px;
}

/* ===== BOUTON FLOTTANT (FAB) ===== */
.alm-cookie-fab {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff;
  color: var(--alm-blue, #004899);
  border: 1px solid rgba(0, 72, 153, 0.15);
  box-shadow: 0 4px 16px rgba(0, 72, 153, 0.15);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 9997;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.alm-cookie-fab[hidden] { display: none; }
.alm-cookie-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0, 72, 153, 0.25);
}
.alm-cookie-fab:focus-visible {
  outline: 2px solid var(--alm-blue, #004899);
  outline-offset: 2px;
}
.alm-cookie-fab svg {
  width: 24px;
  height: 24px;
}
@media (max-width: 600px) {
  .alm-cookie-fab { bottom: 16px; left: 16px; width: 44px; height: 44px; }
}

.alm-cookie-toast {
  position: fixed;
  bottom: 24px;
  left: 88px;
  right: 96px;
  max-width: 640px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--alm-grey, #DDDDD5);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 72, 153, 0.15);
  padding: 12px 16px;
  z-index: 9996;
}
.alm-cookie-toast[hidden] { display: none; }
.alm-cookie-toast__text {
  margin: 0;
  color: var(--alm-blue, #004899);
  font-size: 0.9375rem;
  line-height: 1.4;
}
.alm-cookie-toast .alm-cookie-toast__close:not(:disabled) {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  margin: -6px -8px -6px 0;
  padding: 0;
  background: transparent;
  color: var(--alm-blue, #004899);
  border: 0;
  border-radius: 4px;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.alm-cookie-toast .alm-cookie-toast__close:not(:disabled):hover {
  background: var(--alm-grey, #DDDDD5);
  color: #003674;
}
.alm-cookie-toast .alm-cookie-toast__close:not(:disabled):focus-visible {
  outline: 2px solid var(--alm-blue, #004899);
  outline-offset: 2px;
}
@media (max-width: 600px) {
  .alm-cookie-toast { left: 76px; right: 16px; bottom: 16px; }
}

/* ===== ANIMATIONS ===== */
@keyframes alm-cookie-fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes alm-cookie-modal-in {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes alm-cookie-slideup {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .alm-cookie-banner,
  .alm-cookie-modal__overlay,
  .alm-cookie-modal__inner,
  .alm-cookie-toggle__slider,
  .alm-cookie-toggle__slider::before,
  .alm-cookie-fab {
    transition: none !important;
    animation: none !important;
  }
}

/* ===== TABLEAU COOKIES (page /cookies/) ===== */
.alm-cookies-page-table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 0.9375rem;
}
.alm-cookies-page-table th,
.alm-cookies-page-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid #eaecef;
  vertical-align: top;
}
.alm-cookies-page-table th {
  background: #f6f7f9;
  font-weight: 600;
  color: var(--alm-blue, #004899);
}
.alm-cookies-page-table tr.alm-cat-heading td {
  background: rgba(0, 72, 153, 0.06);
  font-weight: 600;
  color: var(--alm-blue, #004899);
  font-size: 1rem;
}
.alm-cookies-page-table .alm-required {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  background: #fff3e0;
  color: #a05a00;
  font-size: 0.75rem;
  font-weight: 600;
}

/* V6.0.1 — Notice admin sur /cookies/ (visible aux super-admins uniquement) */
.alm-admin-notice {
  margin: 20px 0;
  padding: 14px 18px;
  border-left: 4px solid #6b7280;
  background: #f6f7f9;
  font-size: 0.875rem;
  line-height: 1.5;
  border-radius: 4px;
}
.alm-admin-notice--warning {
  border-left-color: #e6a23c;
  background: #fff8e6;
}
.alm-admin-notice strong { display: block; margin-bottom: 6px; }
.alm-admin-notice a { color: var(--alm-blue, #004899); text-decoration: underline; font-weight: 500; }

/* Bouton "modifier mes préférences" sur page politique */
.alm-cookie-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  background: var(--cta-bg, var(--alm-orange));
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.2s ease;
}
.alm-cookie-trigger-btn:hover {
  background: var(--alm-orange);
  transform: translateY(-1px);
  color: #fff;
}
.alm-cookie-trigger-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

@media (max-width:960px){
  .alm-cookie-banner .alm-cookie-actions{flex-direction:row}
  .alm-cookie-banner .alm-cookie-actions .alm-btn{width:auto;flex:1 1 0;min-width:150px}
}
