/* Bandeau / préférences cookies — PROGEDEV
   z-index au-dessus du chat (bouton 100000, popup 100001, fenêtre 99998)
   pour que le consentement reste toujours accessible. */
.pgd-cookie-banner {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 100110;
  max-width: 640px;
  margin: 0 auto;
  background: #0b1220;
  color: #f5f7fb;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  padding: 1.15rem 1.25rem 1.25rem;
  font-family: 'Open Sans', system-ui, sans-serif;
  font-size: 0.92rem;
  line-height: 1.55;
  max-height: min(70vh, calc(100vh - 32px - env(safe-area-inset-bottom, 0px)));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.pgd-cookie-banner[hidden],
.pgd-cookie-prefs[hidden] {
  display: none !important;
}

.pgd-cookie-banner__title {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
}

.pgd-cookie-banner__text {
  margin: 0 0 1rem;
  color: rgba(245, 247, 251, 0.88);
}

.pgd-cookie-banner__text a {
  color: #4da6ff;
  text-decoration: underline;
}

.pgd-cookie-banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.pgd-cookie-btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.55rem 0.95rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.2;
}

.pgd-cookie-btn--accept {
  background: #1a8bdb;
  color: #fff;
}

.pgd-cookie-btn--accept:hover {
  background: #1678bf;
}

.pgd-cookie-btn--refuse {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

.pgd-cookie-btn--refuse:hover {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.pgd-cookie-btn--prefs {
  background: transparent;
  color: #4da6ff;
  border-color: transparent;
  padding-left: 0.35rem;
  padding-right: 0.35rem;
}

.pgd-cookie-btn--prefs:hover {
  text-decoration: underline;
}

.pgd-cookie-prefs-overlay {
  position: fixed;
  inset: 0;
  z-index: 100120;
  background: rgba(11, 18, 32, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.pgd-cookie-prefs-overlay[hidden] {
  display: none !important;
}

.pgd-cookie-prefs {
  width: 100%;
  max-width: 520px;
  max-height: min(85vh, calc(100vh - 32px - env(safe-area-inset-bottom, 0px)));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
  color: #212529;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.2);
  padding: 1.25rem 1.25rem 1.4rem;
}

@media (min-width: 640px) {
  .pgd-cookie-prefs-overlay {
    align-items: center;
  }

  .pgd-cookie-prefs {
    border-radius: 12px;
  }
}

.pgd-cookie-prefs__title {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: #0b1220;
}

.pgd-cookie-prefs__intro {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: #495057;
}

.pgd-cookie-pref {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  padding: 0.85rem 0;
  border-top: 1px solid #e9ecef;
}

.pgd-cookie-pref:last-of-type {
  border-bottom: 1px solid #e9ecef;
  margin-bottom: 1rem;
}

.pgd-cookie-pref__meta {
  flex: 1;
  min-width: 0;
}

.pgd-cookie-pref__name {
  font-weight: 700;
  margin: 0 0 0.2rem;
  font-size: 0.95rem;
}

.pgd-cookie-pref__desc {
  margin: 0;
  font-size: 0.85rem;
  color: #6c757d;
  line-height: 1.45;
}

.pgd-cookie-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  margin-top: 2px;
}

.pgd-cookie-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.pgd-cookie-switch__ui {
  position: absolute;
  inset: 0;
  background: #ced4da;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.pgd-cookie-switch__ui::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.pgd-cookie-switch input:checked + .pgd-cookie-switch__ui {
  background: #1a8bdb;
}

.pgd-cookie-switch input:checked + .pgd-cookie-switch__ui::after {
  transform: translateX(20px);
}

.pgd-cookie-switch input:disabled + .pgd-cookie-switch__ui {
  opacity: 0.55;
  cursor: not-allowed;
}

.pgd-cookie-prefs__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: flex-end;
}

.pgd-cookie-btn--save {
  background: #1a8bdb;
  color: #fff;
}

.pgd-cookie-btn--save:hover {
  background: #1678bf;
}

.pgd-cookie-btn--close {
  background: #f1f3f5;
  color: #212529;
}

.pgd-cookie-btn--close:hover {
  background: #e9ecef;
}

.pgd-cookie-switch .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Tant que le bandeau cookies est affiché : masquer le chat
   (évite superposition / auto-open qui bloque le consentement sur mobile). */
body.pgd-cookie-banner-open #chat-widget {
  visibility: hidden !important;
  pointer-events: none !important;
}

@media (max-width: 480px) {
  .pgd-cookie-banner {
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    padding: 1rem;
  }

  .pgd-cookie-banner__actions {
    flex-direction: column;
  }

  .pgd-cookie-btn {
    width: 100%;
    text-align: center;
  }

  .pgd-cookie-btn--prefs {
    width: auto;
    align-self: flex-start;
  }

  .pgd-cookie-prefs__actions {
    flex-direction: column-reverse;
  }

  .pgd-cookie-prefs__actions .pgd-cookie-btn {
    width: 100%;
    text-align: center;
  }
}
