/* GMG Consent Manager – Banner & Modal Styles */
/*
 * THEMING: colors/radius/font below read from CSS custom properties
 * (--gmg-*) with a fallback value equal to the plugin's original design.
 * That means: if no theme settings are saved and no filter overrides them,
 * this file renders IDENTICALLY to before theming support was added.
 *
 * The vars are scoped (see class-gmg-consent-frontend.php build_theme_css())
 * to #gmg-consent-banner, #gmg-pref-modal, #gmg-reopen-btn — so they can't
 * leak onto the rest of the page, and the rest of the page's CSS vars can't
 * leak in here either.
 *
 * Admin-configurable (Settings > Consent Manager > Appearance):
 *   --gmg-bg, --gmg-text, --gmg-text-muted, --gmg-title,
 *   --gmg-accent, --gmg-accent-hover, --gmg-radius,
 *   --gmg-font-heading, --gmg-fontsize-heading,
 *   --gmg-font-body, --gmg-fontsize-body,
 *   --gmg-font-button, --gmg-fontsize-button
 *
 * Note: --gmg-accent-hover also drives the hover state of the
 * Decline/Save Preferences buttons (border) and Manage Preferences (text) —
 * there's no separate "hover color" field, it reuses this one.
 *
 * Developer-only (override via the `gmg_consent_theme_vars` filter):
 *   --gmg-accent-light — used for links, the ghost button's resting
 *   (non-hover) color, and the category toggle's focus ring. Defaults to a
 *   lighter tint of the accent color.
 */

/* ── Reset/Base ─────────────────────────────────────────── */
#gmg-consent-banner *,
#gmg-pref-modal *,
.gmg-reopen * {
  box-sizing: border-box;
}

/* ── Banner ──────────────────────────────────────────────── */
.gmg-banner {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 99999;
  background: var(--gmg-bg, #1a1a2e);
  color: var(--gmg-text, #e8e8f0);
  font-family: var(--gmg-font-body, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  font-size: var(--gmg-fontsize-body, 14px);
  line-height: 1.5;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.35);
  padding: 0;
  animation: gmgSlideIn 0.3s ease;
}

.gmg-banner--bottom { bottom: 0; top: auto; border-top: 3px solid var(--gmg-accent, #4f46e5); }
.gmg-banner--top    { top: 0; bottom: auto; border-bottom: 3px solid var(--gmg-accent, #4f46e5); }

.gmg-banner--modal {
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translate(-50%, -50%);
  border-radius: calc(var(--gmg-radius, 6px) * 2);
  width: 90%;
  max-width: 560px;
  border: none;
  outline: 3px solid var(--gmg-accent, #4f46e5);
}

.gmg-banner__inner {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px;
}

.gmg-banner__content {
  flex: 1 1 150px;
}

.gmg-banner__title {
  font-size: var(--gmg-fontsize-heading, 16px);
  font-family: var(--gmg-font-heading, inherit);
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--gmg-title, #fff);
}

.gmg-banner__desc {
  margin: 0;
  color: var(--gmg-text-muted, #b0b0c8);
  font-size: var(--gmg-fontsize-body, 13px);
}

.gmg-banner__desc a {
  color: var(--gmg-accent-light, #818cf8);
  text-decoration: underline;
}

.gmg-banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.gmg-banner__powered {
  width: 100%;
  font-size: 11px;
  color: #606080;
  padding-top: 4px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.gmg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border-radius: var(--gmg-radius, 6px);
  font-size: var(--gmg-fontsize-button, 13px);
  font-weight: 600;
  font-family: var(--gmg-font-button, inherit);
  cursor: pointer;
  border: 2px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
  line-height: 1.3;
}

.gmg-btn--primary {
  background: var(--gmg-accent, #4f46e5);
  color: var(--gmg-accent-text, #fff);
  border-color: var(--gmg-accent, #4f46e5);
}
.gmg-btn--primary:hover {
  background: var(--gmg-accent-hover, #4338ca);
  border-color: var(--gmg-accent-hover, #4338ca);
}

.gmg-btn--secondary {
  background: transparent;
  color: var(--gmg-text, #e8e8f0);
  border-color: #4b5563;
}
.gmg-btn--secondary:hover {
  border-color: var(--gmg-accent-hover, #9ca3af);
  color: var(--gmg-title, #fff);
}

.gmg-btn--ghost {
  background: transparent;
  color: var(--gmg-accent-light, #818cf8);
  border-color: transparent;
  padding-left: 6px;
  padding-right: 6px;
}
.gmg-btn--ghost:hover {
  color: var(--gmg-accent-hover, #a5b4fc);
  text-decoration: underline;
}

/* ── Modal ───────────────────────────────────────────────── */
.gmg-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--gmg-font-body, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  font-size: var(--gmg-fontsize-body, 14px);
}

.gmg-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(2px);
}

.gmg-modal__box {
  position: relative;
  z-index: 1;
  background: var(--gmg-bg, #1a1a2e);
  color: var(--gmg-text, #e8e8f0);
  border-radius: calc(var(--gmg-radius, 6px) * 2);
  width: 90%;
  max-width: 580px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 48px rgba(0,0,0,0.55);
  border: 1px solid #2e2e50;
  outline: none;
}

.gmg-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #2e2e50;
}

.gmg-modal__header h2 {
  margin: 0;
  font-size: var(--gmg-fontsize-heading, 18px);
  font-family: var(--gmg-font-heading, inherit);
  font-weight: 700;
  color: var(--gmg-title, #fff);
}

.gmg-modal__close {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s;
}
.gmg-modal__close:hover { color: var(--gmg-title, #fff); }

.gmg-modal__body {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}

.gmg-modal__footer {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 16px 24px;
  border-top: 1px solid #2e2e50;
}

/* ── Cookie categories ───────────────────────────────────── */
.gmg-category {
  padding: 16px 24px;
  border-bottom: 1px solid #2e2e50;
}
.gmg-category:last-child { border-bottom: none; }

.gmg-category--required { opacity: 0.7; }

.gmg-category__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.gmg-category__info {
  flex: 1;
}

.gmg-category__info strong {
  display: block;
  font-size: var(--gmg-fontsize-heading, 14px);
  font-family: var(--gmg-font-heading, inherit);
  font-weight: 600;
  color: var(--gmg-title, #fff);
  margin-bottom: 4px;
}

.gmg-category__info p {
  margin: 0;
  font-size: var(--gmg-fontsize-body, 12px);
  color: #9ca3af;
  line-height: 1.5;
}

/* ── Toggle switch ───────────────────────────────────────── */
.gmg-toggle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.gmg-toggle--disabled {
  cursor: default;
}

.gmg-toggle__label {
  font-size: 11px;
  font-weight: 600;
  color: #4ade80;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gmg-toggle__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.gmg-toggle__slider {
  display: inline-block;
  width: 44px;
  height: 24px;
  background: #374151;
  border-radius: 12px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.gmg-toggle__slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.gmg-toggle__input:checked + .gmg-toggle__slider {
  background: var(--gmg-accent, #4f46e5);
}

.gmg-toggle__input:checked + .gmg-toggle__slider::after {
  transform: translateX(20px);
}

.gmg-toggle__input:disabled + .gmg-toggle__slider {
  background: #4ade80;
  opacity: 0.85;
}

.gmg-toggle__input:disabled + .gmg-toggle__slider::after {
  transform: translateX(20px);
}

.gmg-toggle__input:focus + .gmg-toggle__slider {
  outline: 2px solid var(--gmg-accent-light, #818cf8);
  outline-offset: 2px;
}

/* ── Reopen widget ───────────────────────────────────────── */
.gmg-reopen {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 99998;
  background: var(--gmg-bg, #1a1a2e);
  color: var(--gmg-accent-light, #818cf8);
  border: 1px solid #2e2e50;
  border-radius: calc(var(--gmg-radius, 6px) * 1.333);
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--gmg-fontsize-button, 12px);
  font-family: var(--gmg-font-button, inherit);
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.gmg-reopen:hover {
  background: #252545;
  border-color: var(--gmg-accent, #4f46e5);
  color: var(--gmg-accent-light, #a5b4fc);
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes gmgSlideIn {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

.gmg-banner--top {
  animation-name: gmgSlideInTop;
}

@keyframes gmgSlideInTop {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 640px) {
  .gmg-banner__inner {
    flex-direction: column;
    align-items: stretch;
  }

  .gmg-banner__actions {
    flex-direction: column;
  }

  .gmg-btn { width: 100%; text-align: center; justify-content: center; }

  .gmg-modal__footer {
    flex-direction: column;
  }

  .gmg-modal__footer .gmg-btn { width: 100%; }
}

/* ── [hidden] support ────────────────────────────────────── */
[hidden] { display: none !important; }

/* Production accessibility additions */
html.gmg-consent-modal-open,
html.gmg-consent-modal-open body {
  overflow: hidden;
}
.gmg-modal[hidden],
.gmg-banner[hidden],
.gmg-reopen[hidden] {
  display: none !important;
}
.gmg-btn:focus-visible,
.gmg-modal__close:focus-visible,
.gmg-reopen:focus-visible,
.gmg-toggle__input:focus-visible + .gmg-toggle__slider {
  outline: 3px solid currentColor;
  outline-offset: 3px;
}

/* ── Production style isolation and modal spacing (2.0.3) ─────────────── */
/* Keep host-theme button rules from changing the consent UI. */
#gmg-consent-banner .gmg-btn,
#gmg-pref-modal .gmg-btn,
#gmg-pref-modal .gmg-modal__close,
#gmg-reopen-btn {
  appearance: none;
  -webkit-appearance: none;
  text-transform: none;
  text-shadow: none;
  letter-spacing: normal;
  min-width: 0;
  min-height: 0;
  box-shadow: none;
}

#gmg-consent-banner .gmg-btn--primary,
#gmg-pref-modal .gmg-btn--primary {
  background-color: var(--gmg-accent, #4f46e5);
  color: var(--gmg-accent-text, #fff);
  border-color: var(--gmg-accent, #4f46e5);
}

#gmg-consent-banner .gmg-btn--primary:hover,
#gmg-consent-banner .gmg-btn--primary:focus,
#gmg-consent-banner .gmg-btn--primary:active,
#gmg-pref-modal .gmg-btn--primary:hover,
#gmg-pref-modal .gmg-btn--primary:focus,
#gmg-pref-modal .gmg-btn--primary:active {
  background-color: var(--gmg-accent-hover, #4338ca);
  color: var(--gmg-accent-text, #fff);
  border-color: var(--gmg-accent-hover, #4338ca);
}

/* Transparent buttons must stay transparent in every interactive state. */
#gmg-consent-banner .gmg-btn--secondary,
#gmg-consent-banner .gmg-btn--secondary:hover,
#gmg-consent-banner .gmg-btn--secondary:focus,
#gmg-consent-banner .gmg-btn--secondary:active,
#gmg-consent-banner .gmg-btn--ghost,
#gmg-consent-banner .gmg-btn--ghost:hover,
#gmg-consent-banner .gmg-btn--ghost:focus,
#gmg-consent-banner .gmg-btn--ghost:active,
#gmg-pref-modal .gmg-btn--secondary,
#gmg-pref-modal .gmg-btn--secondary:hover,
#gmg-pref-modal .gmg-btn--secondary:focus,
#gmg-pref-modal .gmg-btn--secondary:active,
#gmg-pref-modal .gmg-btn--ghost,
#gmg-pref-modal .gmg-btn--ghost:hover,
#gmg-pref-modal .gmg-btn--ghost:focus,
#gmg-pref-modal .gmg-btn--ghost:active,
#gmg-pref-modal .gmg-modal__close,
#gmg-pref-modal .gmg-modal__close:hover,
#gmg-pref-modal .gmg-modal__close:focus,
#gmg-pref-modal .gmg-modal__close:active {
  background: transparent !important;
  background-color: transparent !important;
  box-shadow: none !important;
}

#gmg-consent-banner .gmg-btn--secondary,
#gmg-pref-modal .gmg-btn--secondary {
  color: var(--gmg-text, #e8e8f0);
  border-color: #4b5563;
}

#gmg-consent-banner .gmg-btn--secondary:hover,
#gmg-consent-banner .gmg-btn--secondary:focus,
#gmg-consent-banner .gmg-btn--secondary:active,
#gmg-pref-modal .gmg-btn--secondary:hover,
#gmg-pref-modal .gmg-btn--secondary:focus,
#gmg-pref-modal .gmg-btn--secondary:active {
  color: var(--gmg-title, #fff);
  border-color: var(--gmg-accent-hover, #9ca3af);
}

#gmg-consent-banner .gmg-btn--ghost,
#gmg-pref-modal .gmg-btn--ghost {
  color: var(--gmg-accent-light, #818cf8);
  border-color: transparent;
}

#gmg-consent-banner .gmg-btn--ghost:hover,
#gmg-consent-banner .gmg-btn--ghost:focus,
#gmg-consent-banner .gmg-btn--ghost:active,
#gmg-pref-modal .gmg-btn--ghost:hover,
#gmg-pref-modal .gmg-btn--ghost:focus,
#gmg-pref-modal .gmg-btn--ghost:active {
  color: var(--gmg-accent-hover, #a5b4fc);
  border-color: transparent;
  text-decoration: underline;
}

/* The modal markup is intentionally divided into fixed header/footer and a
 * scrollable body so padding remains consistent at every viewport size. */
#gmg-pref-modal .gmg-modal__box {
  overflow: hidden;
}

#gmg-pref-modal .gmg-modal__header {
  flex: 0 0 auto;
  padding: 20px 24px 16px;
}

#gmg-pref-modal .gmg-modal__body {
  min-height: 0;
  overflow-y: auto;
  padding: 0;
}

#gmg-pref-modal .gmg-modal__intro {
  margin: 0;
  padding: 18px 24px 12px;
  color: var(--gmg-text-muted, #b0b0c8);
  font-family: var(--gmg-font-body, inherit);
  font-size: var(--gmg-fontsize-body, 14px);
  line-height: 1.5;
}

#gmg-pref-modal .gmg-category {
  padding: 16px 24px;
}

#gmg-pref-modal .gmg-modal__footer {
  flex: 0 0 auto;
  padding: 16px 24px 20px;
}

@media (max-width: 640px) {
  #gmg-pref-modal .gmg-modal__box {
    width: calc(100% - 24px);
    max-height: calc(100vh - 24px);
  }

  #gmg-pref-modal .gmg-modal__header {
    padding: 16px 18px 14px;
  }

  #gmg-pref-modal .gmg-modal__intro {
    padding: 16px 18px 10px;
  }

  #gmg-pref-modal .gmg-category {
    padding: 14px 18px;
  }

  #gmg-pref-modal .gmg-modal__footer {
    padding: 14px 18px 18px;
  }
}
