/**
 * BakeDeco.com - Custom Consent Management Platform (CMP) Styles
 * File: cmp.css
 * 
 * Features:
 * - Fully isolated namespace (`bd-cmp-*`) to eliminate CSS collisions.
 * - Mobile-first responsive architecture (desktop floating bar, mobile bottom-sheet).
 * - High z-index (2147483640) ensures visibility above modals, chat widgets, and sticky headers.
 * - WCAG 2.1 AA accessible contrast ratios & focus rings.
 * - Smooth micro-animations for open/close and toggle transitions.
 */

/* ==========================================================================
   1. ROOT VARIABLES & TOKENS
   ========================================================================== */
:root {
  --bd-cmp-bg: #ffffff;
  --bd-cmp-surface: #f8fafc;
  --bd-cmp-border: #e2e8f0;
  --bd-cmp-text: #0f172a;
  --bd-cmp-muted: #64748b;
  --bd-cmp-primary: #1e293b;
  --bd-cmp-primary-hover: #0f172a;
  --bd-cmp-accent: #2563eb;
  --bd-cmp-reject-bg: #f1f5f9;
  --bd-cmp-reject-hover: #e2e8f0;
  --bd-cmp-reject-text: #334155;
  --bd-cmp-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --bd-cmp-shadow-banner: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1), 0 -2px 10px rgba(0, 0, 0, 0.05);
  --bd-cmp-shadow-modal: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --bd-cmp-radius: 8px;
  --bd-cmp-zindex: 2147483640;
}

/* ==========================================================================
   2. BOTTOM FLOATING BANNER
   ========================================================================== */
.bd-cmp-banner {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100%;
  z-index: var(--bd-cmp-zindex);
  background: var(--bd-cmp-bg);
  border-top: 1px solid var(--bd-cmp-border);
  box-shadow: var(--bd-cmp-shadow-banner);
  font-family: var(--bd-cmp-font);
  color: var(--bd-cmp-text);
  padding: 18px 24px;
  animation: bdCmpSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  box-sizing: border-box;
}

.bd-cmp-banner * {
  box-sizing: border-box;
}

.bd-cmp-fade-out {
  animation: bdCmpFadeOut 0.25s ease forwards !important;
}

.bd-cmp-container {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
}

.bd-cmp-content {
  flex: 1 1 auto;
}

.bd-cmp-header {
  margin-bottom: 6px;
}

.bd-cmp-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--bd-cmp-text);
  display: inline-block;
  letter-spacing: -0.01em;
}

.bd-cmp-desc {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--bd-cmp-muted);
  margin: 0;
}

.bd-cmp-link {
  color: var(--bd-cmp-text);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
  transition: color 0.15s ease;
}

.bd-cmp-link:hover {
  color: var(--bd-cmp-accent);
}

.bd-cmp-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.bd-cmp-btn-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ==========================================================================
   3. BUTTONS
   ========================================================================== */
.bd-cmp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--bd-cmp-font);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  padding: 11px 18px;
  border-radius: var(--bd-cmp-radius);
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  text-align: center;
  white-space: nowrap;
  outline: none;
  border: 1px solid transparent;
}

.bd-cmp-btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}

.bd-cmp-btn-accept {
  background-color: var(--bd-cmp-primary);
  color: #ffffff;
  border-color: var(--bd-cmp-primary);
}

.bd-cmp-btn-accept:hover {
  background-color: var(--bd-cmp-primary-hover);
  border-color: var(--bd-cmp-primary-hover);
  transform: translateY(-1px);
}

.bd-cmp-btn-reject {
  background-color: var(--bd-cmp-reject-bg);
  color: var(--bd-cmp-reject-text);
  border-color: var(--bd-cmp-border);
}

.bd-cmp-btn-reject:hover {
  background-color: var(--bd-cmp-reject-hover);
  color: var(--bd-cmp-text);
}

.bd-cmp-btn-secondary {
  background-color: transparent;
  color: var(--bd-cmp-muted);
  border-color: var(--bd-cmp-border);
}

.bd-cmp-btn-secondary:hover {
  background-color: var(--bd-cmp-surface);
  color: var(--bd-cmp-text);
  border-color: #cbd5e1;
}

/* ==========================================================================
   4. PREFERENCE CENTER MODAL
   ========================================================================== */
.bd-cmp-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: var(--bd-cmp-zindex);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: bdCmpFadeIn 0.2s ease forwards;
  box-sizing: border-box;
}

.bd-cmp-modal-overlay * {
  box-sizing: border-box;
}

.bd-cmp-modal-dialog {
  background: var(--bd-cmp-bg);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  border-radius: 12px;
  box-shadow: var(--bd-cmp-shadow-modal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: bdCmpScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.bd-cmp-modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--bd-cmp-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bd-cmp-surface);
}

.bd-cmp-modal-title {
  font-family: var(--bd-cmp-font);
  font-size: 18px;
  font-weight: 700;
  color: var(--bd-cmp-text);
  margin: 0;
}

.bd-cmp-modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--bd-cmp-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.bd-cmp-modal-close:hover {
  background: #e2e8f0;
  color: var(--bd-cmp-text);
}

.bd-cmp-modal-body {
  padding: 24px;
  overflow-y: auto;
  font-family: var(--bd-cmp-font);
}

.bd-cmp-modal-intro {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--bd-cmp-muted);
  margin: 0 0 20px 0;
}

/* GPC Alert Box */
.bd-cmp-gpc-alert {
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 20px;
}

.bd-cmp-gpc-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #1e40af;
  background-color: #dbeafe;
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
}

.bd-cmp-gpc-alert p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #1e3a8a;
}

/* Category Toggle Rows */
.bd-cmp-toggle-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bd-cmp-toggle-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  background: var(--bd-cmp-surface);
  border: 1px solid var(--bd-cmp-border);
  border-radius: 8px;
}

.bd-cmp-toggle-info {
  flex: 1;
}

.bd-cmp-category-title {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--bd-cmp-text);
  margin-bottom: 4px;
}

.bd-cmp-category-desc {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--bd-cmp-muted);
  margin: 0;
}

.bd-cmp-badge-locked {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  color: #047857;
  background-color: #d1fae5;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

/* Accessible Toggle Switch */
.bd-cmp-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.bd-cmp-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.bd-cmp-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 24px;
}

.bd-cmp-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.bd-cmp-switch input:checked + .bd-cmp-slider {
  background-color: var(--bd-cmp-primary);
}

.bd-cmp-switch input:focus-visible + .bd-cmp-slider {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}

.bd-cmp-switch input:checked + .bd-cmp-slider:before {
  transform: translateX(20px);
}

.bd-cmp-switch.bd-cmp-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.bd-cmp-switch.bd-cmp-disabled .bd-cmp-slider {
  cursor: not-allowed;
}

.bd-cmp-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--bd-cmp-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background: var(--bd-cmp-surface);
}

/* ==========================================================================
   5. FOOTER LINK INJECTION & CCPA ICON
   ========================================================================== */
.bd-cmp-footer-optout {
  display: inline-block;
  margin: 8px 0;
}

.bd-cmp-footer-sep {
  display: inline;
  color: inherit;
  opacity: 0.8;
  margin: 0 4px;
}

.bd-cmp-footer-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  padding: 2px 0;
  margin: 0;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
  transition: opacity 0.15s ease, color 0.15s ease;
  vertical-align: baseline;
  line-height: inherit;
}

.bd-cmp-footer-btn:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.bd-cmp-ccpa-icon {
  display: inline-block;
  vertical-align: -2px;
  flex-shrink: 0;
  width: 30px;
  height: 14px;
}

footer .termly-display-preferences,
footer a.termly-display-preferences,
#termly-code-snippet-support {
  display: none !important;
}

/* ==========================================================================
   6. ANIMATIONS
   ========================================================================== */
@keyframes bdCmpSlideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes bdCmpFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes bdCmpScaleIn {
  from {
    transform: scale(0.96);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes bdCmpFadeOut {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(100%);
    opacity: 0;
  }
}

/* ==========================================================================
   7. RESPONSIVE BREAKPOINTS
   ========================================================================== */
@media (max-width: 768px) {
  .bd-cmp-banner {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 8px 12px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    box-sizing: border-box !important;
  }

  .bd-cmp-container {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    box-sizing: border-box !important;
  }

  .bd-cmp-content {
    line-height: 1.32;
    width: 100%;
  }

  .bd-cmp-header {
    display: inline;
    margin: 0;
  }

  .bd-cmp-title {
    display: inline;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--bd-cmp-text);
    margin-right: 3px;
  }

  .bd-cmp-title::after {
    content: ":";
  }

  .bd-cmp-desc {
    display: inline;
    font-size: 10.5px;
    line-height: 1.32;
    color: var(--bd-cmp-muted);
  }

  .bd-cmp-link {
    font-size: 10.5px;
  }

  .bd-cmp-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    margin-top: 3px;
    box-sizing: border-box;
  }

  /* Compact text link for Preferences on mobile (matches B&H) */
  .bd-cmp-actions .bd-cmp-btn-secondary {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    font-size: 10px;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 2px;
    color: var(--bd-cmp-muted);
    text-align: left;
    white-space: normal;
    line-height: 1.2;
    max-width: 76px;
    width: auto;
    flex-shrink: 0;
    cursor: pointer;
    border-radius: 0;
    min-height: auto;
  }

  .bd-cmp-actions .bd-cmp-btn-secondary:hover {
    color: var(--bd-cmp-text);
    background: transparent !important;
  }

  /* Compact button group on the right */
  .bd-cmp-btn-group {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
  }

  /* Compact Accept & Reject buttons side-by-side */
  .bd-cmp-btn-group .bd-cmp-btn {
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1;
    padding: 6px 8px;
    border-radius: 4px;
    min-height: 28px;
    height: 28px;
    width: auto;
    text-align: center;
    white-space: nowrap;
    box-sizing: border-box;
  }

  .bd-cmp-modal-dialog {
    max-height: 95vh;
    border-radius: 12px 12px 0 0;
  }

  .bd-cmp-modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .bd-cmp-modal-footer {
    flex-direction: column-reverse;
  }

  .bd-cmp-modal-footer .bd-cmp-btn {
    width: 100%;
    padding: 11px;
    font-size: 13px;
    min-height: 40px;
  }
}

/* Fallback for ultra-narrow devices under 340px */
@media (max-width: 340px) {
  .bd-cmp-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }

  .bd-cmp-btn-group {
    width: 100%;
  }

  .bd-cmp-btn-group .bd-cmp-btn {
    flex: 1;
  }

  .bd-cmp-btn-secondary {
    text-align: center;
    max-width: none;
  }
}

