/* ═══════════════════════════════════════════════════════════════════════════
   KRITEXA LABS — CONSENT POPUP STYLES
   css/consent.css

   Cookie/Tracking Consent Banner & Preferences Panel
   Matches Kritexa Labs dark/neon visual language.

   STRUCTURE:
     #kl-consent-popup          — outer overlay container (fixed, full screen)
       #kl-consent-banner       — main banner panel (bottom-of-screen card)
       #kl-consent-prefs        — preferences panel (centred modal card)
         .kl-prefs-category     — each toggle row (Essential / Analytics / Marketing)
           .kl-consent-toggle   — checkbox input styled as toggle switch

   ACCESSIBILITY:
     - Uses aria-hidden, role=dialog, aria-modal, aria-labelledby
     - Focus trap managed by consent-manager.js
     - Keyboard: Tab/Shift+Tab within popup, Escape to close (if already chosen)
     - High-contrast toggle states
     - Minimum 44×44 px touch targets

   RESPONSIVE:
     - Desktop: banner slides in from bottom, max-width 960px, centred
     - Mobile (≤ 600px): banner takes full-width bottom bar, prefs goes full-screen
═══════════════════════════════════════════════════════════════════════════ */

/* ─── Popup overlay ──────────────────────────────────────────────────────── */
#kl-consent-popup {
  position: fixed;
  inset: 0;
  z-index: 99999;
  pointer-events: none;   /* allow clicks through when showing banner only */
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 16px 20px;
  /* Smooth in */
  animation: kl-consent-fadein 0.3s ease both;
}

#kl-consent-popup[hidden] {
  display: none !important;
}

/* When preferences panel is visible we need the overlay backdrop
   .kl-prefs-open class is toggled by JS (consent-manager.js) for
   browsers without :has() support. The :has() rule covers modern browsers. */
#kl-consent-popup:has(#kl-consent-prefs:not([hidden])),
#kl-consent-popup.kl-prefs-open {
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  align-items: center;
  padding: 16px;
}

@keyframes kl-consent-fadein {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Shared card base ───────────────────────────────────────────────────── */
.kl-consent-card {
  background: rgba(16, 12, 28, 0.97);
  border: 1px solid rgba(139, 92, 246, 0.28);
  border-radius: 16px;
  box-shadow:
    0 0 0 1px rgba(139, 92, 246, 0.10),
    0 8px 40px rgba(0, 0, 0, 0.6),
    0 0 80px rgba(139, 92, 246, 0.06);
  color: #e2dff7;
  font-family: -apple-system, 'Inter', 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  pointer-events: auto;
  width: 100%;
  max-width: 820px;
  position: relative;
}

/* ─── Banner panel ───────────────────────────────────────────────────────── */
#kl-consent-banner {
  padding: 22px 24px 20px;
}

#kl-consent-banner[hidden] {
  display: none !important;
}

.kl-consent-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.kl-consent-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, rgba(139,92,246,0.25) 0%, rgba(236,72,153,0.18) 100%);
  border: 1px solid rgba(139,92,246,0.30);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #a78bfa;
}

.kl-consent-title {
  font-size: 15px;
  font-weight: 700;
  color: #f0eafe;
  letter-spacing: 0.01em;
}

.kl-consent-text {
  color: rgba(226, 223, 247, 0.72);
  font-size: 13px;
  line-height: 1.65;
  margin: 0 0 18px;
}

.kl-consent-text a {
  color: #a78bfa;
  text-decoration: none;
}

.kl-consent-text a:hover {
  text-decoration: underline;
}

/* Banner buttons row */
.kl-consent-btns {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* ─── Button styles ──────────────────────────────────────────────────────── */
.kl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 20px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  outline: none;
  transition: opacity 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  white-space: nowrap;
  min-height: 40px;
  min-width: 44px;
}

.kl-btn:focus-visible {
  box-shadow: 0 0 0 2px #a78bfa, 0 0 0 4px rgba(139, 92, 246, 0.25);
}

/* Primary — Accept All */
.kl-btn-primary {
  background: linear-gradient(135deg, #7c3aed 0%, #a21caf 100%);
  color: #fff;
  box-shadow: 0 2px 12px rgba(124, 58, 237, 0.35);
}

.kl-btn-primary:hover {
  opacity: 0.88;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.45);
}

/* Secondary — Reject Non-Essential */
.kl-btn-secondary {
  background: rgba(139, 92, 246, 0.08);
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.30);
}

.kl-btn-secondary:hover {
  background: rgba(139, 92, 246, 0.16);
  color: #e4d9ff;
}

/* Ghost — Manage Preferences */
.kl-btn-ghost {
  background: transparent;
  color: rgba(196, 181, 253, 0.7);
  border: 1px solid rgba(139, 92, 246, 0.18);
  padding: 9px 16px;
}

.kl-btn-ghost:hover {
  color: #c4b5fd;
  border-color: rgba(139, 92, 246, 0.40);
}

/* Save / Confirm */
.kl-btn-save {
  background: linear-gradient(135deg, #7c3aed 0%, #a21caf 100%);
  color: #fff;
}

.kl-btn-save:hover {
  opacity: 0.88;
}

/* ─── Preferences panel ──────────────────────────────────────────────────── */
#kl-consent-prefs {
  padding: 24px;
  max-width: 620px;
  position: relative;
}

#kl-consent-prefs[hidden] {
  display: none !important;
}

.kl-prefs-title {
  font-size: 16px;
  font-weight: 700;
  color: #f0eafe;
  margin: 0 0 6px;
}

.kl-prefs-desc {
  font-size: 13px;
  color: rgba(226, 223, 247, 0.65);
  margin: 0 0 20px;
  line-height: 1.6;
}

/* Category rows */
.kl-prefs-categories {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 20px;
  border: 1px solid rgba(139, 92, 246, 0.18);
  border-radius: 10px;
  overflow: hidden;
}

.kl-prefs-category {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(139, 92, 246, 0.12);
}

.kl-prefs-category:last-child {
  border-bottom: none;
}

.kl-prefs-category-info {
  flex: 1;
  min-width: 0;
}

.kl-prefs-category-name {
  font-size: 13px;
  font-weight: 600;
  color: #e2dff7;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.kl-prefs-always-on {
  font-size: 10px;
  font-weight: 600;
  color: #6ee7b7;
  background: rgba(110, 231, 183, 0.12);
  border: 1px solid rgba(110, 231, 183, 0.22);
  border-radius: 4px;
  padding: 1px 7px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kl-prefs-category-desc {
  font-size: 12px;
  color: rgba(226, 223, 247, 0.50);
  line-height: 1.5;
}

/* ─── Toggle switch ──────────────────────────────────────────────────────── */
.kl-toggle-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding-top: 2px;
}

/* Hide the actual checkbox */
.kl-consent-toggle {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* The visual toggle — built as a label next to the input */
.kl-toggle-label {
  display: inline-block;
  width: 40px;
  height: 22px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: 11px;
  cursor: pointer;
  position: relative;
  transition: background 0.2s ease, border-color 0.2s ease;
  /* Ensure minimum touch target */
  min-width: 40px;
  min-height: 22px;
}

.kl-toggle-label::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  transition: transform 0.2s ease, background 0.2s ease;
}

.kl-consent-toggle:checked + .kl-toggle-label {
  background: rgba(139, 92, 246, 0.70);
  border-color: rgba(139, 92, 246, 0.70);
}

.kl-consent-toggle:checked + .kl-toggle-label::after {
  transform: translateX(18px);
  background: #fff;
}

.kl-consent-toggle:focus-visible + .kl-toggle-label {
  box-shadow: 0 0 0 2px #a78bfa, 0 0 0 4px rgba(139, 92, 246, 0.25);
}

/* Disabled / Essential toggle — not interactive */
.kl-toggle-label.kl-toggle-disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

/* ─── Preferences action row ─────────────────────────────────────────────── */
.kl-prefs-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.kl-prefs-back {
  margin-right: auto;
  color: rgba(196, 181, 253, 0.55);
  font-size: 13px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 0;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.18s ease;
}

.kl-prefs-back:hover {
  color: #c4b5fd;
}

.kl-prefs-back:focus-visible {
  outline: 2px solid #a78bfa;
  outline-offset: 3px;
  border-radius: 4px;
}

/* ─── Responsive — mobile ────────────────────────────────────────────────── */
@media (max-width: 600px) {
  #kl-consent-popup {
    padding: 0 8px 12px;
    align-items: flex-end;
  }

  #kl-consent-popup:has(#kl-consent-prefs:not([hidden])) {
    align-items: flex-end;
    padding: 0;
  }

  .kl-consent-card {
    border-radius: 14px 14px 0 0;
    max-width: 100%;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }

  #kl-consent-prefs {
    max-width: 100%;
    max-height: 92dvh;
    overflow-y: auto;
    border-radius: 14px 14px 0 0;
  }

  .kl-consent-btns {
    flex-direction: column;
    gap: 8px;
  }

  .kl-btn {
    width: 100%;
  }

  .kl-prefs-actions {
    flex-direction: column;
    gap: 8px;
  }

  .kl-prefs-actions .kl-btn {
    width: 100%;
  }

  .kl-prefs-back {
    margin-right: 0;
  }
}

/* ─── Reduced motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #kl-consent-popup {
    animation: none;
  }
  .kl-btn,
  .kl-toggle-label,
  .kl-toggle-label::after {
    transition: none;
  }
}
