/* ════════════════════════════════════════════════════════════════════
   lm-consent.css — GDPR/TTDSG cookie-consent banner + options sheet.

   Replaces lm-cookie.css, which restyled the old cookieconsent2 library's
   .cc-* elements. That library is gone; this is our own markup
   (_lm_cookie_consent.tpl) driven by lm-consent.js.

   Keep "Reject all" and "Accept all" the same size and weight. Only the
   colour differs (filled vs outlined) — shrinking or greying out the refusal
   is the dark pattern the EDPB guidance explicitly names.
   ════════════════════════════════════════════════════════════════════ */

:root {
  --lm-consent-bg: #e9f6f0;
  --lm-consent-fg: #233039;
  --lm-consent-muted: #536069;
  --lm-consent-border: rgba(15, 111, 79, 0.18);
  --lm-consent-accent: #0f6f4f;
  --lm-consent-accent-hover: #0a5439;
  --lm-consent-sheet-bg: #ffffff;
  --lm-consent-shadow: 0 18px 40px -12px rgba(15, 111, 79, 0.22);
}

/* Night mode. Three selectors because this component is global and the theme
   flag differs by subsystem: body[data-bs-theme] / body.night-mode site-wide,
   html[data-lm-theme] on profile + messenger. */
body[data-bs-theme="dark"],
body.night-mode,
html[data-lm-theme="dark"] body {
  --lm-consent-bg: #16232b;
  --lm-consent-fg: #e8eef2;
  --lm-consent-muted: #9fb0bb;
  --lm-consent-border: rgba(255, 255, 255, 0.12);
  --lm-consent-accent: #21976c;
  --lm-consent-accent-hover: #2bb082;
  --lm-consent-sheet-bg: #16232b;
  --lm-consent-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.55);
}

.lm-consent[hidden],
.lm-consent-banner[hidden],
.lm-consent-modal[hidden] { display: none !important; }

.lm-consent {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ── Bottom banner ──────────────────────────────────────────────────── */

.lm-consent-banner {
  position: fixed;
  z-index: 10000;
  left: 50%;
  transform: translateX(-50%);
  bottom: 16px;
  width: calc(100% - 32px);
  max-width: 620px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--lm-consent-bg);
  color: var(--lm-consent-fg);
  border: 1px solid var(--lm-consent-border);
  border-radius: 12px;
  box-shadow: var(--lm-consent-shadow);
}

.lm-consent-copy { flex: 1 1 auto; min-width: 0; }

.lm-consent-title {
  margin: 0 0 2px;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--lm-consent-fg);
}

.lm-consent-text {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--lm-consent-muted);
}

.lm-consent-text a,
.lm-consent-link {
  color: var(--lm-consent-accent);
  text-decoration: underline;
  white-space: nowrap;
}
.lm-consent-text a:hover,
.lm-consent-link:hover { color: var(--lm-consent-accent-hover); }

/* "Manage options" — a real button for keyboard/AT, styled as an inline link
   so it doesn't add a third item to the action row. */
.lm-consent-link {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin-left: 2px;
  font: inherit;
  cursor: pointer;
}
.lm-consent-link:focus-visible {
  outline: 2px solid var(--lm-consent-accent);
  outline-offset: 2px;
}

.lm-consent-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Buttons ────────────────────────────────────────────────────────── */

.lm-consent-btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 36px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.lm-consent-btn-primary {
  background: var(--lm-consent-accent);
  color: #fff;
}
.lm-consent-btn-primary:hover { background: var(--lm-consent-accent-hover); }

/* Same footprint as primary — outlined, not shrunk. */
.lm-consent-btn-secondary {
  background: transparent;
  color: var(--lm-consent-accent);
  border-color: var(--lm-consent-accent);
}
.lm-consent-btn-secondary:hover {
  background: var(--lm-consent-accent);
  color: #fff;
}

.lm-consent-btn-ghost {
  background: transparent;
  color: var(--lm-consent-muted);
  text-decoration: underline;
  padding: 0 8px;
}
.lm-consent-btn-ghost:hover { color: var(--lm-consent-fg); }

.lm-consent-btn:focus-visible {
  outline: 2px solid var(--lm-consent-accent);
  outline-offset: 2px;
}

/* ── Options sheet ──────────────────────────────────────────────────── */

/* 100dvh rather than inset:0 — on iOS Safari the address bar changes the
   viewport and a bottom-anchored sheet lands in the wrong place. */
.lm-consent-modal {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100dvh;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.lm-consent-scrim {
  position: absolute;
  inset: 0;
  background: rgba(12, 22, 28, 0.55);
}

.lm-consent-sheet {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--lm-consent-sheet-bg);
  color: var(--lm-consent-fg);
  border: 1px solid var(--lm-consent-border);
  border-radius: 16px;
  box-shadow: var(--lm-consent-shadow);
  overflow: hidden;
}

.lm-consent-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--lm-consent-border);
}

.lm-consent-sheet-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.lm-consent-close {
  appearance: none;
  background: transparent;
  border: 0;
  font-size: 26px;
  line-height: 1;
  color: var(--lm-consent-muted);
  cursor: pointer;
  padding: 0 4px;
}
.lm-consent-close:hover { color: var(--lm-consent-fg); }

.lm-consent-sheet-body {
  padding: 4px 20px;
  overflow-y: auto;
}

.lm-consent-cat {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--lm-consent-border);
}
.lm-consent-cat:last-child { border-bottom: 0; }

.lm-consent-cat-copy { flex: 1 1 auto; min-width: 0; }

.lm-consent-cat-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 3px;
  cursor: pointer;
}

.lm-consent-cat-text {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--lm-consent-muted);
}

.lm-consent-sheet-foot {
  display: flex;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--lm-consent-border);
}
.lm-consent-sheet-foot .lm-consent-btn { flex: 1 1 0; padding: 0 10px; }

/* ── Switch ─────────────────────────────────────────────────────────── */

.lm-consent-switch {
  position: relative;
  flex: 0 0 auto;
  display: inline-block;
  width: 44px;
  height: 25px;
  margin-top: 2px;
}

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

.lm-consent-slider {
  position: absolute;
  inset: 0;
  background: #c3ccd2;
  border-radius: 25px;
  transition: background 140ms ease;
  pointer-events: none;
}

.lm-consent-slider::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 19px;
  height: 19px;
  background: #fff;
  border-radius: 50%;
  transition: transform 140ms ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.lm-consent-switch input:checked ~ .lm-consent-slider { background: var(--lm-consent-accent); }
.lm-consent-switch input:checked ~ .lm-consent-slider::before { transform: translateX(19px); }
.lm-consent-switch input:focus-visible ~ .lm-consent-slider { outline: 2px solid var(--lm-consent-accent); outline-offset: 2px; }

.lm-consent-switch.is-locked { opacity: 0.55; }
.lm-consent-switch.is-locked input { cursor: not-allowed; }

/* The footer "Cookies" trigger is styled in lm-profile.css, not here: this
   stylesheet is skipped in the AdminCP, and a half-styled button leaked out.
   It belongs with the footer-link rules it has to match anyway. */

/* ── Small screens (reference width 360px) ──────────────────────────── */

@media (max-width: 640px) {
  .lm-consent-banner {
    bottom: 10px;
    width: calc(100% - 20px);
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px;
  }
  /* Reject and Accept share the row evenly — equal weight, per the note above. */
  .lm-consent-actions .lm-consent-btn { flex: 1 1 0; }

  .lm-consent-sheet-foot { flex-wrap: wrap; }
  .lm-consent-sheet-foot .lm-consent-btn { flex: 1 1 46%; }
}
