/**
 * Apex SEO Cookie Consent — Frontend Styles
 * BEM naming: .eca-cb (banner), .eca-cp (preferences), .eca-cm (manage button)
 */

/* ── Reset scoped to banner elements ── */
#eca-consent-gate,
#eca-cookie-banner,
#eca-cookie-banner *,
#eca-cookie-prefs,
#eca-cookie-prefs *,
#eca-cookie-manage {
  box-sizing: border-box;
  margin: 0;
  padding: 10px 30px;
  line-height: 1.5;
  font-family: var(--eca-cb-font, inherit);
}

/* ── Consent gate — full-screen overlay, blocks all interaction ── */
.eca-gate {
  position: fixed;
  inset: 0;
  z-index: var(--eca-cb-z, 999999);
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: eca-fade-in 0.2s ease-out;
}

/* Prevent the page behind from scrolling while gate is open */
body.eca-consent-pending {
  overflow: hidden;
}

/* ── Banner (always rendered as a centred modal inside the gate) ── */
.eca-cb {
  position: relative;
  background: var(--eca-cb-bg, #ffffff);
  color: var(--eca-cb-text, #1f2937);
  border-radius: var(--eca-cb-radius, 16px);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.25), 0 2px 8px rgba(0, 0, 0, 0.1);
  max-width: 520px;
  width: 100%;
  padding: 30px 25px;
  overflow: hidden;
  animation: eca-fade-scale 0.25s ease-out;
}

.eca-cb__inner {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 0 !important;
}

.eca-cb__content {
  flex: 1;
  min-width: 0;
  padding: 0 !important;
}

.eca-cb__title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}

.eca-cb__message {
  font-size: 14px;
  opacity: 0.72;
  margin-bottom: 8px;
  line-height: 1.6;
}

.eca-cb__link {
  display: inline-block;
  margin-top: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--eca-cb-primary, #2563eb);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

.eca-cb__link:hover {
  border-bottom-color: var(--eca-cb-primary, #2563eb);
  opacity: 0.9;
}

/* ── Buttons ── */
.eca-cb__actions {
  display: flex;
  gap: 10px;
}

.eca-cb__actions .eca-cb__btn {
  flex: 1;
  padding: 10px 0;
}

.eca-cb__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, opacity 0.15s, transform 0.1s, box-shadow 0.15s;
  font-family: inherit;
  line-height: 1.4;
}

.eca-cb__btn:hover {
  opacity: 0.92;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.eca-cb__btn:active {
  transform: scale(0.97);
}

.eca-cb__btn:focus-visible {
  outline: 2px solid var(--eca-cb-primary, #2563eb);
  outline-offset: 2px;
}

/* Accept — primary colour */
.eca-cb__btn--accept {
  background: var(--eca-cb-primary, #2563eb);
  color: #fff;
}

/* Reject — EQUAL PROMINENCE per ICO guidance (same size, visible colour) */
.eca-cb__btn--reject {
  background: var(--eca-cb-secondary, #4b5563);
  color: #fff;
}

/* Manage / Save — outlined */
.eca-cb__btn--manage,
.eca-cb__btn--save {
  background: transparent;
  color: var(--eca-cb-text, #1f2937);
  border: 2px solid rgba(0, 0, 0, 0.15);
}

.eca-cb__btn--manage:hover,
.eca-cb__btn--save:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.25);
}

/* ── Preferences Modal ── */
.eca-cp {
  position: fixed;
  inset: 0;
  z-index: calc(var(--eca-cb-z, 999999) + 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.eca-cp__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.eca-cp__panel {
  position: relative;
  background: var(--eca-cb-bg, #ffffff);
  color: var(--eca-cb-text, #1f2937);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.25), 0 2px 8px rgba(0, 0, 0, 0.1);
  max-width: 560px;
  width: calc(100% - 32px);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.eca-cp__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 18px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.eca-cp__header h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

.eca-cp__close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--eca-cb-text, #1f2937);
  opacity: 0.6;
  padding: 4px 8px;
  line-height: 1;
  font-family: inherit;
}

.eca-cp__close:hover {
  opacity: 1;
}

.eca-cp__body {
  padding: 16px 28px;
  overflow-y: auto;
  flex: 1;
}

.eca-cp__category {
  padding: 14px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.eca-cp__category:last-child {
  border-bottom: none;
}

.eca-cp__category-header {
  display: flex;
  align-items: center;
}

.eca-cp__toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
}

.eca-cp__category-name {
  flex: 1;
}

.eca-cp__badge {
  font-size: 11px;
  font-weight: 600;
  background: #d1fae5;
  color: #065f46;
  padding: 2px 8px;
  border-radius: 99px;
  white-space: nowrap;
}

/* Toggle switch styling */
.eca-cp__toggle {
  appearance: none;
  -webkit-appearance: none;
  width: 44px;
  height: 24px;
  background: #d1d5db;
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
  border: none;
}

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

.eca-cp__toggle:checked {
  background: var(--eca-cb-primary, #2563eb);
}

.eca-cp__toggle:checked::after {
  transform: translateX(20px);
}

.eca-cp__toggle:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.eca-cp__toggle:focus-visible {
  outline: 2px solid var(--eca-cb-primary, #2563eb);
  outline-offset: 2px;
}

.eca-cp__category-desc {
  font-size: 13px;
  opacity: 0.7;
  margin-top: 6px;
  line-height: 1.5;
}

.eca-cp__footer {
  display: flex;
  gap: 10px;
  padding: 18px 28px 24px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

/* ── Floating Manage Button ── */
.eca-cm {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: var(--eca-cb-z, 999999);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: var(--eca-cb-bg, #ffffff);
  color: var(--eca-cb-text, #1f2937);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 99px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  transition: box-shadow 0.15s, transform 0.1s;
}

.eca-cm:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.eca-cm:active {
  transform: scale(0.97);
}

.eca-cm svg {
  flex-shrink: 0;
}

/* ── Cookie Policy Shortcode Table ── */
.eca-cookie-policy__table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 14px;
}

.eca-cookie-policy__table th,
.eca-cookie-policy__table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.eca-cookie-policy__table th {
  font-weight: 600;
  background: rgba(0, 0, 0, 0.03);
}

.eca-cookie-policy__table code {
  font-size: 12px;
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 3px;
}

/* ── Animations ── */
.eca-cp__panel {
  animation: eca-fade-scale 0.25s ease-out;
}

.eca-cp__overlay {
  animation: eca-fade-in 0.2s ease-out;
}

@keyframes eca-fade-scale {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes eca-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .eca-gate,
  .eca-cb,
  .eca-cp__panel,
  .eca-cp__overlay {
    animation: none;
  }
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .eca-gate {
    padding: 12px;
    align-items: flex-end;
  }

  .eca-cb {
    border-radius: 16px 16px 0 0;
    max-width: 100%;
  }

  .eca-cb__inner {
    padding: 28px 20px 24px;
  }

  .eca-cb__actions {
    flex-direction: column;
  }

  .eca-cb__actions .eca-cb__btn {
    flex: none;
  }

  .eca-cp__panel {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    border-radius: 16px 16px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
  }

  .eca-cp {
    align-items: flex-end;
  }

  .eca-cp__footer {
    flex-direction: column;
  }

  .eca-cp__footer .eca-cb__btn {
    width: 100%;
  }

  .eca-cm span {
    display: none;
  }
}

/* ── Print ── */
@media print {
  #eca-consent-gate,
  #eca-cookie-banner,
  #eca-cookie-prefs,
  #eca-cookie-manage {
    display: none !important;
  }
}
