/* PulseCONSENT banner. Colours come from --pc-brand and the data-theme on the root. */

.pulse-consent-root {
  --pc-brand: #6d28d9;
  --pc-bg: #ffffff;
  --pc-ink: #16161d;
  --pc-ink-2: #4b4a5c;
  --pc-ink-3: #78768c;
  --pc-line: #e4e1ee;
  --pc-ghost: #ffffff;
  --pc-ghost-hover: #f2f0f7;
  --pc-shadow: 0 12px 40px rgba(16, 24, 40, 0.18);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.pulse-consent-root[data-theme="dark"] {
  --pc-bg: #1c1b24;
  --pc-ink: #f4f2fa;
  --pc-ink-2: #c9c5d8;
  --pc-ink-3: #9a96ad;
  --pc-line: #33313f;
  --pc-ghost: #26242f;
  --pc-ghost-hover: #302d3c;
  --pc-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

/* ---- Banner ---- */
.pulse-consent-banner {
  position: fixed;
  z-index: 2147483600;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  width: min(920px, calc(100% - 32px));
  background: var(--pc-bg);
  color: var(--pc-ink);
  border: 1px solid var(--pc-line);
  border-radius: 16px;
  box-shadow: var(--pc-shadow);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 13.5px;
  line-height: 1.5;
  animation: pc-rise .35s ease;
}

.pulse-consent-root[data-position="bottom-left"] .pulse-consent-banner {
  left: 20px; transform: none; width: min(460px, calc(100% - 40px));
}
.pulse-consent-root[data-position="bottom-right"] .pulse-consent-banner {
  left: auto; right: 20px; transform: none; width: min(460px, calc(100% - 40px));
}
.pulse-consent-root[data-position="bar"] .pulse-consent-banner {
  left: 0; right: 0; bottom: 0; transform: none; width: 100%;
  border-radius: 0; border-width: 1px 0 0;
  padding: 16px max(20px, calc((100% - 1200px) / 2));
}
.pulse-consent-root[data-position="bottom-left"] .pulse-consent-banner,
.pulse-consent-root[data-position="bottom-right"] .pulse-consent-banner { flex-direction: column; align-items: stretch; }
.pulse-consent-root[data-position="bottom-left"] .pc-actions,
.pulse-consent-root[data-position="bottom-right"] .pc-actions { width: 100%; }
.pulse-consent-root[data-position="bottom-left"] .pc-actions .pc-btn,
.pulse-consent-root[data-position="bottom-right"] .pc-actions .pc-btn { flex: 1 1 auto; }

@keyframes pc-rise { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }
.pulse-consent-root:not([data-position="bottom-center"]) .pulse-consent-banner { animation: pc-fade .35s ease; }
@keyframes pc-fade { from { opacity: 0; } to { opacity: 1; } }

.pulse-consent-banner .pc-text { flex: 1 1 360px; min-width: 240px; color: var(--pc-ink-2); }
.pulse-consent-banner .pc-text strong { color: var(--pc-ink); font-size: 14.5px; }
.pc-link { color: var(--pc-brand); text-decoration: none; font-weight: 600; }
.pc-link:hover { text-decoration: underline; }

.pc-actions { display: flex; gap: 10px; flex: 0 0 auto; flex-wrap: wrap; }
.pc-btn {
  font: inherit;
  font-weight: 600;
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
  white-space: nowrap;
}
.pc-btn:active { transform: translateY(1px); }
.pc-btn:focus-visible { outline: 2px solid var(--pc-brand); outline-offset: 2px; }
.pc-btn-primary { background: var(--pc-brand); color: #fff; }
.pc-btn-primary:hover { filter: brightness(1.08); }
.pc-btn-ghost { background: var(--pc-ghost); color: var(--pc-ink-2); border-color: var(--pc-line); }
.pc-btn-ghost:hover { background: var(--pc-ghost-hover); }

/* ---- Preferences panel ---- */
.pulse-consent-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483601;
  background: rgba(16, 24, 40, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.pulse-consent-modal.open { display: flex; }
.pc-panel {
  width: min(560px, 100%);
  max-height: 86vh;
  overflow: auto;
  background: var(--pc-bg);
  color: var(--pc-ink);
  border-radius: 18px;
  padding: 26px;
  box-shadow: var(--pc-shadow);
  animation: pc-pop .25s ease;
}
@keyframes pc-pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: scale(1); } }
.pc-panel-head h2 { margin: 0 0 6px; font-size: 19px; color: var(--pc-ink); font-family: inherit; }
.pc-panel-head p { margin: 0 0 18px; font-size: 13px; color: var(--pc-ink-3); line-height: 1.5; }

.pc-cat {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-top: 1px solid var(--pc-line);
}
.pc-cat-title { display: block; font-weight: 600; font-size: 14px; color: var(--pc-ink); margin-bottom: 3px; cursor: pointer; }
.pc-cat-desc { font-size: 12.5px; color: var(--pc-ink-3); line-height: 1.45; }

.pc-switch { position: relative; width: 44px; height: 26px; flex: 0 0 auto; margin-top: 2px; }
.pc-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.pc-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: #cbd2da; border-radius: 999px; transition: background .2s;
}
.pulse-consent-root[data-theme="dark"] .pc-slider { background: #4a475a; }
.pc-slider::before {
  content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.pc-switch input:checked + .pc-slider { background: var(--pc-brand); }
.pc-switch input:checked + .pc-slider::before { transform: translateX(18px); }
.pc-switch input:focus-visible + .pc-slider { outline: 2px solid var(--pc-brand); outline-offset: 2px; }
.pc-switch.locked .pc-slider { background: var(--pc-brand); opacity: .55; cursor: not-allowed; }

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

/* ---- Reopen button ---- */
.pulse-consent-fab {
  position: fixed; left: 16px; bottom: 16px; z-index: 2147483599;
  display: none;
  font: 600 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--pc-bg); color: var(--pc-ink-2); border: 1px solid var(--pc-line);
  border-radius: 999px; padding: 9px 14px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(16,24,40,.12);
}
.pulse-consent-root[data-position="bottom-right"] .pulse-consent-fab { left: auto; right: 16px; }
.pulse-consent-fab:hover { background: var(--pc-ghost-hover); }
.pulse-consent-fab[hidden] { display: none !important; }

.pulse-consent-root.decided .pulse-consent-banner { display: none; }
.pulse-consent-root.decided .pulse-consent-fab { display: inline-flex; }

@media (max-width: 560px) {
  .pulse-consent-banner { padding: 16px; gap: 12px; }
  .pc-actions { width: 100%; }
  .pc-actions .pc-btn { flex: 1 1 auto; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .pulse-consent-banner, .pc-panel { animation: none; }
}

/* ---- Admin preview: same banner, pinned inside a stage instead of the viewport ---- */
.pulse-consent-root.pc-preview .pulse-consent-banner,
.pulse-consent-root.pc-preview .pulse-consent-modal,
.pulse-consent-root.pc-preview .pulse-consent-fab { position: absolute; animation: none; }
.pulse-consent-root.pc-preview .pulse-consent-modal { border-radius: 8px; }
.pulse-consent-root.pc-preview .pc-panel { max-height: 100%; }
.pulse-consent-root.pc-preview .pulse-consent-banner { z-index: 3; }
.pulse-consent-root.pc-preview .pulse-consent-modal { z-index: 4; }
