/*
 * Consent Mode v2 — styles de la bannière ET du panneau « Gestion des cookies ».
 * Les couleurs/bordures/arrondis viennent des options admin via les
 * variables CSS (--cmv2-*).
 *
 * Spécificité volontairement élevée (prefixe .cmv2-banner / .cmv2-panel)
 * pour résister aux styles globaux de thème ("button", "input", "h2"...) qui,
 * à spécificité égale, gagnent car imprimés plus tôt. Le plugin enregistre
 * aussi son CSS avec une priorité tardive (100) pour s'imprimer après le thème.
 */

/* ============================================================
   BANNIÈRE — socle (format barre, bas de page)
   ============================================================ */

.cmv2-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99999;
  padding: 12px;
  box-sizing: border-box;
  font-family: inherit;
}

@media (min-width: 768px) {
  .cmv2-banner {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: 860px;
    margin: 0 auto;
  }
}

.cmv2-banner[hidden] {
  display: none !important;
}

.cmv2-banner .cmv2-box {
  background: var(--cmv2-bg, #fff);
  color: var(--cmv2-text, #1f2937);
  border: var(--cmv2-border-width, 1px) solid var(--cmv2-border-color, rgba(0, 0, 0, 0.08));
  border-radius: var(--cmv2-radius, 16px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  padding: 18px;
  max-height: calc(100vh - 24px);
  overflow: auto;
  font-family: inherit;
}

/* ============================================================
   BANNIÈRE — format modale (voile plein écran + boîte centrée)
   ============================================================ */

.cmv2-banner.cmv2-banner--modal {
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: none;
  margin: 0;
  padding: 20px;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cmv2-banner.cmv2-banner--modal .cmv2-box {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  max-height: calc(100vh - 40px);
}

@media (min-width: 768px) {
  .cmv2-banner.cmv2-banner--modal {
    left: 0;
    right: 0;
    bottom: 0;
    max-width: none;
  }
}

/* ============================================================
   BANNIÈRE — en-tête avec lien de refus
   ============================================================ */

.cmv2-banner .cmv2-head {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}

.cmv2-banner .cmv2-refuse {
  background: none;
  border: 0;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 4px 6px;
  opacity: 0.75;
  appearance: none;
  -webkit-appearance: none;
}

.cmv2-banner .cmv2-refuse:hover {
  opacity: 1;
}

.cmv2-banner .cmv2-refuse:focus-visible {
  outline: 2px solid var(--cmv2-accept-bg, #ea580c);
  outline-offset: 2px;
}

.cmv2-banner .cmv2-title {
  margin: 0 0 10px;
  font-size: 1.05rem;
  font-weight: 700;
  outline: none;
}

.cmv2-banner .cmv2-text {
  margin: 0 0 12px;
  font-size: 0.9rem;
  line-height: 1.55;
  opacity: 0.92;
}

.cmv2-banner .cmv2-text:last-of-type {
  margin-bottom: 16px;
}

.cmv2-banner .cmv2-link {
  color: inherit;
  text-decoration: underline;
}

.cmv2-banner .cmv2-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center; /* bouton unique centré */
  gap: 8px;
}

/* ============================================================
   BOUTONS (spécificité haute + background-image:none contre les
   gradients/dégradés de thème)
   ============================================================ */

.cmv2-banner .cmv2-btn,
.cmv2-panel .cmv2-btn {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--cmv2-btn-radius, 999px);
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease;
  display: inline-block;
  box-sizing: border-box;
  text-decoration: none;
  line-height: 1.3;
  appearance: none;
  -webkit-appearance: none;
}

.cmv2-banner .cmv2-btn:focus-visible,
.cmv2-panel .cmv2-btn:focus-visible {
  outline: 2px solid var(--cmv2-accept-bg, #ea580c);
  outline-offset: 2px;
}

.cmv2-banner .cmv2-btn--accept,
.cmv2-panel .cmv2-btn--accept {
  background-color: var(--cmv2-accept-bg, #ea580c);
  background-image: none;
  color: var(--cmv2-accept-text, #fff);
  border-color: var(--cmv2-accept-bg, #ea580c);
}

.cmv2-banner .cmv2-btn--accept:hover,
.cmv2-panel .cmv2-btn--accept:hover {
  filter: brightness(0.92);
}

.cmv2-banner .cmv2-btn--more {
  background-color: transparent;
  background-image: none;
  color: inherit;
  border-color: rgba(128, 128, 128, 0.5);
}

.cmv2-banner .cmv2-btn--more:hover {
  background: rgba(128, 128, 128, 0.12);
}

.cmv2-btn[hidden] {
  display: none;
}

/* ============================================================
   PANNEAU « GESTION DES COOKIES » — voile plein écran
   ============================================================ */

.cmv2-panel {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  box-sizing: border-box;
  font-family: inherit;
}

.cmv2-panel[hidden] {
  display: none !important;
}

.cmv2-panel .cmv2-panel-box {
  background: var(--cmv2-bg, #fff);
  color: var(--cmv2-text, #1f2937);
  width: 100%;
  max-width: 880px;
  margin: auto;
  border: var(--cmv2-border-width, 1px) solid var(--cmv2-border-color, rgba(0, 0, 0, 0.08));
  border-radius: var(--cmv2-radius, 16px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  padding: 28px 32px;
  box-sizing: border-box;
}

.cmv2-panel .cmv2-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.cmv2-panel .cmv2-panel-title {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.2;
  outline: none;
}

.cmv2-panel .cmv2-panel-close {
  background: none;
  border: 0;
  color: inherit;
  font-size: 1.9rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
  opacity: 0.55;
  flex: none;
  appearance: none;
  -webkit-appearance: none;
}

.cmv2-panel .cmv2-panel-close:hover {
  opacity: 1;
}

.cmv2-panel .cmv2-panel-close:focus-visible {
  outline: 2px solid var(--cmv2-accept-bg, #ea580c);
  outline-offset: 2px;
}

.cmv2-panel .cmv2-panel-intro {
  margin: 16px 0 4px;
  font-size: 0.92rem;
  line-height: 1.6;
  opacity: 0.9;
}

.cmv2-panel .cmv2-panel-intro p {
  margin: 0 0 10px;
}

.cmv2-panel .cmv2-panel-sub {
  margin: 22px 0 2px;
  font-size: 1.2rem;
  font-weight: 700;
}

/* ---------- Catégories (lignes) ---------- */

.cmv2-panel .cmv2-cat {
  padding: 15px 0;
  border-top: 1px solid rgba(128, 128, 128, 0.25);
}

.cmv2-panel .cmv2-cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.cmv2-panel .cmv2-cat-title {
  font-size: 0.98rem;
  font-weight: 700;
}

.cmv2-panel .cmv2-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.cmv2-panel .cmv2-state {
  display: inline-block;
  min-width: 34px;
  text-align: right;
  font-size: 0.78rem;
  font-weight: 600;
  opacity: 0.65;
}

.cmv2-panel .cmv2-cat-desc {
  margin: 8px 0 0;
  font-size: 0.86rem;
  line-height: 1.55;
  opacity: 0.8;
}

/* ---------- Toggle (interrupteur) ---------- */

.cmv2-panel .cmv2-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex: none;
}

.cmv2-panel .cmv2-switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

.cmv2-panel .cmv2-switch input:disabled {
  cursor: not-allowed;
}

.cmv2-panel .cmv2-slider {
  position: absolute;
  inset: 0;
  background: rgba(128, 128, 128, 0.45);
  border-radius: 999px;
  transition: background 0.15s ease;
  pointer-events: none;
}

.cmv2-panel .cmv2-slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease;
}

.cmv2-panel .cmv2-switch input:checked + .cmv2-slider {
  background: var(--cmv2-accept-bg, #ea580c);
}

.cmv2-panel .cmv2-switch input:checked + .cmv2-slider::after {
  transform: translateX(20px);
}

.cmv2-panel .cmv2-switch input:focus-visible + .cmv2-slider {
  outline: 2px solid var(--cmv2-accept-bg, #ea580c);
  outline-offset: 2px;
}

.cmv2-panel .cmv2-switch input:disabled + .cmv2-slider {
  opacity: 0.6;
}

.cmv2-panel .cmv2-panel-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 22px;
}

@media (max-width: 600px) {
  .cmv2-panel {
    padding: 12px;
  }
  .cmv2-panel .cmv2-panel-box {
    padding: 20px 16px;
  }
  .cmv2-panel .cmv2-panel-title {
    font-size: 1.35rem;
  }
  .cmv2-panel .cmv2-cat-row {
    flex-wrap: wrap;
  }
}

/* ============================================================
   BOUTON FLOTTANT « GÉRER LES COOKIES »
   Spécificité body .cmv2-manage = (0,1,1), au-dessus de .button de thème.
   ============================================================ */

body .cmv2-manage {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 99998;
  font: inherit;
  font-size: 0.78rem;
  padding: 7px 12px;
  border-radius: var(--cmv2-btn-radius, 999px);
  border: var(--cmv2-border-width, 1px) solid rgba(128, 128, 128, 0.4);
  background-color: var(--cmv2-bg, #fff);
  background-image: none;
  color: var(--cmv2-text, #1f2937);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  opacity: 0.85;
  appearance: none;
  -webkit-appearance: none;
}

body .cmv2-manage:hover {
  opacity: 1;
}

body .cmv2-manage[hidden] {
  display: none;
}
