/* Consentimiento de cookies — spec: specs/legal/cookie-consent-v1.md */

/* --- Banner (primera capa) ------------------------------------------------ */

.bb-consent-banner {
  position: fixed;
  left: max(var(--bb-space-3), env(safe-area-inset-left, 0px));
  right: max(var(--bb-space-3), env(safe-area-inset-right, 0px));
  bottom: calc(var(--bb-space-3) + env(safe-area-inset-bottom, 0px));
  z-index: 190;
  max-width: 960px;
  margin: 0 auto;
  padding: var(--bb-space-3);
  border: 1px solid var(--bb-glass-border-strong);
  border-radius: var(--bb-radius-lg);
  background: var(--bb-glass-gradient);
  box-shadow: var(--bb-glass-shadow);
  color: var(--bb-color-text-primary);
  -webkit-backdrop-filter: blur(var(--bb-glass-blur));
  backdrop-filter: blur(var(--bb-glass-blur));
}

.bb-consent-banner[hidden] {
  display: none;
}

.bb-consent-banner__inner {
  display: flex;
  flex-direction: column;
  gap: var(--bb-space-3);
}

.bb-consent-banner__title {
  margin: 0 0 var(--bb-space-1);
  font-family: var(--bb-font-heading);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bb-consent-banner__text {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--bb-color-text-secondary);
}

.bb-consent-banner__text a,
.bb-consent-dialog__intro a {
  color: var(--bb-color-text-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.bb-consent-banner__actions,
.bb-consent-dialog__actions {
  display: grid;
  gap: var(--bb-space-2);
}

/* Banner: los tres botones siempre en una fila, con el mismo peso (AEPD). */
.bb-consent-banner__actions {
  grid-template-columns: repeat(3, 1fr);
}

.bb-consent-dialog__actions {
  grid-template-columns: 1fr;
}

.bb-consent-banner__actions .bb-cta,
.bb-consent-dialog__actions .bb-cta {
  width: 100%;
  min-width: 0;
  justify-content: center;
}

@media (max-width: 719px) {
  .bb-consent-banner {
    padding: var(--bb-space-2) var(--bb-space-3);
  }

  .bb-consent-banner__inner {
    gap: var(--bb-space-2);
  }

  .bb-consent-banner__text {
    font-size: 0.8125rem;
  }

  .bb-consent-banner__actions .bb-cta {
    padding-inline: var(--bb-space-1);
    font-size: 0.6875rem;
  }
}

@media (min-width: 720px) {
  .bb-consent-banner__inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .bb-consent-banner__actions {
    grid-template-columns: repeat(3, auto);
    flex-shrink: 0;
  }

  .bb-consent-dialog__actions {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* El botón flotante de WhatsApp se oculta mientras el banner está visible (quedaría debajo). */
.has-consent-banner .bb-whatsapp-float {
  opacity: 0;
  pointer-events: none;
}

/* --- Panel (segunda capa) ------------------------------------------------- */

.bb-consent-dialog {
  width: min(94vw, 560px);
  max-height: 92vh;
  padding: 0;
  border: 1px solid var(--bb-glass-border-strong);
  border-radius: var(--bb-radius-lg);
  background: var(--bb-glass-gradient);
  background-color: var(--bb-color-surface-1);
  box-shadow: var(--bb-glass-shadow);
  color: var(--bb-color-text-primary);
  overflow: auto;
}

.bb-consent-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.bb-consent-dialog__form {
  display: flex;
  flex-direction: column;
  gap: var(--bb-space-3);
  padding: var(--bb-space-4);
}

.bb-consent-dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--bb-space-2);
}

.bb-consent-dialog__title {
  margin: 0;
  font-family: var(--bb-font-heading);
  font-size: 1.25rem;
  text-transform: uppercase;
}

.bb-consent-dialog__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--bb-glass-border);
  border-radius: var(--bb-radius-pill);
  background: transparent;
  color: var(--bb-color-text-primary);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.bb-consent-dialog__intro {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--bb-color-text-secondary);
}

.bb-consent-dialog__categories {
  display: flex;
  flex-direction: column;
  gap: var(--bb-space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.bb-consent-category {
  padding: var(--bb-space-3);
  border: 1px solid var(--bb-glass-border);
  border-radius: var(--bb-radius-md);
  background: var(--bb-color-surface-2);
}

.bb-consent-category__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--bb-space-2);
}

.bb-consent-category__title {
  margin: 0;
  font-family: var(--bb-font-body);
  font-size: 0.9375rem;
  font-weight: 700;
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
}

.bb-consent-category__always {
  font-size: 0.75rem;
  color: var(--bb-color-text-secondary);
  white-space: nowrap;
}

.bb-consent-category__text {
  margin: var(--bb-space-1) 0 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--bb-color-text-secondary);
}

/* Interruptor accesible: checkbox nativo con aspecto de switch. */
.bb-consent-switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 2.75rem;
  height: 1.5rem;
  margin: 0;
  border: 1px solid var(--bb-glass-border-strong);
  border-radius: var(--bb-radius-pill);
  background: var(--bb-color-surface-3);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.bb-consent-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.5rem - 6px);
  height: calc(1.5rem - 6px);
  border-radius: 50%;
  background: var(--bb-color-text-primary);
  transition: transform 0.2s ease;
}

.bb-consent-switch:checked {
  background: var(--bb-color-action);
}

.bb-consent-switch:checked::after {
  transform: translateX(1.25rem);
}

.bb-consent-switch:focus-visible,
.bb-consent-dialog__close:focus-visible {
  outline: 2px solid var(--bb-color-text-primary);
  outline-offset: 2px;
}

/* --- Mapas bloqueados hasta consentimiento ------------------------------- */

.bb-map-embed__consent {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--bb-space-2);
  padding: var(--bb-space-3);
  text-align: center;
}

.bb-map-embed.is-blocked .bb-map-embed__consent {
  display: flex;
}

.bb-map-embed.is-blocked .bb-map-embed__status::after {
  animation: none;
}

.bb-map-embed__consent-text {
  margin: 0;
  max-width: 28ch;
  font-size: 0.9375rem;
  color: var(--bb-color-text-primary);
}

.bb-map-embed__consent-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--bb-space-2);
}

.bb-map-embed__consent-link {
  font-size: 0.8125rem;
  color: var(--bb-color-text-secondary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .bb-consent-switch,
  .bb-consent-switch::after {
    transition: none;
  }
}
