/* ==========================================================================
   ShieldConsent — UI v3 (Sprint 6) — Complete redesign
   Design system: neutral palette + single configurable accent color
   Corners: sharp (border-radius: 0)
   Typography: inherits from theme
   ========================================================================== */

:root {
  --sc-accent: #2563EB;
  --sc-accent-hover: #1d4ed8;
  --sc-bg: #FFFFFF;
  --sc-text: #1A1A1A;
  --sc-text-secondary: #6B7280;
  --sc-border: #E5E7EB;
  --sc-border-dark: #D1D5DB;
  --sc-surface: #F9FAFB;
  --sc-overlay: rgba(0,0,0,0.4);
  --sc-toggle-w: 44px;
  --sc-toggle-h: 24px;
}

/* ==========================================================================
   ACCESSIBILITY (WCAG 2.1 AA)
   ========================================================================== */

/* Screen-reader only — visually hidden, accessible to AT */
.sc-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link — visible only on focus */
.sc-skip-link {
  position: absolute;
  left: -9999px;
  top: -9999px;
  z-index: 100002;
  padding: 8px 16px;
  background: var(--sc-text);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 4px 0;
}
.sc-skip-link:focus {
  left: 0;
  top: 0;
}

/* Focus visible ring — all interactive elements */
.sc-btn:focus-visible,
.sc-tab:focus-visible,
.sc-floating-btn:focus-visible,
.sc-category-header:focus-visible,
.sc-toggle input:focus-visible + .sc-toggle-track {
  outline: 2px solid var(--sc-accent);
  outline-offset: 2px;
}

/* Toggle focus — ensure keyboard users see focus */
.sc-toggle input:focus-visible + .sc-toggle-track {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

/* ==========================================================================
   BANNER
   ========================================================================== */

.sc-banner {
  position: fixed;
  z-index: 99999;
  width: auto;
  min-width: 340px;
  max-width: min(520px, calc(100vw - 48px));
  background: var(--sc-bg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
  padding: 28px 28px 24px;
  font-family: inherit;
  animation: sc-slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes sc-slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Banner positions --- */

.sc-banner--bottom-left {
  bottom: 24px;
  left: 24px;
}

.sc-banner--bottom-right {
  bottom: 24px;
  right: 24px;
}

.sc-banner--bottom-center {
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  animation-name: sc-slide-up-center;
}

@keyframes sc-slide-up-center {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.sc-banner--top-left {
  top: 24px;
  bottom: auto;
  left: 24px;
  animation-name: sc-slide-down;
}

.sc-banner--top-right {
  top: 24px;
  bottom: auto;
  right: 24px;
  animation-name: sc-slide-down;
}

.sc-banner--top-center {
  top: 24px;
  bottom: auto;
  left: 50%;
  transform: translateX(-50%);
  animation-name: sc-slide-down-center;
}

@keyframes sc-slide-down-center {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes sc-slide-down {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Banner content --- */

.sc-banner-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--sc-text);
  margin: 0 0 8px;
}

.sc-banner-links {
  margin-bottom: 20px;
}

.sc-banner-links a {
  font-size: 13px;
  color: var(--sc-text-secondary);
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-right: 16px;
}

.sc-banner-links a:hover {
  color: var(--sc-text);
}

.sc-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.sc-btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 20px;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  letter-spacing: -0.01em;
  line-height: 1;
  white-space: nowrap;
  border-radius: 0;
}

/* Primary (Accept) */
.sc-btn-primary {
  background: var(--sc-btn-accept-bg, var(--sc-accent));
  color: var(--sc-btn-accept-text, #fff);
}
.sc-btn-primary:hover {
  filter: brightness(0.9);
}

/* Secondary (Decline / Save) */
.sc-btn-secondary {
  background: var(--sc-btn-decline-bg, transparent);
  color: var(--sc-btn-decline-text, var(--sc-text));
  border: 1px solid var(--sc-border-dark);
}
.sc-btn-secondary:hover {
  filter: brightness(0.9);
  border-color: var(--sc-text);
}

/* Tertiary */
.sc-btn-tertiary {
  background: transparent;
  color: var(--sc-text-secondary);
  padding: 12px;
  font-weight: 500;
}
.sc-btn-tertiary:hover {
  color: var(--sc-text);
}

/* ==========================================================================
   MODAL OVERLAY
   ========================================================================== */

.sc-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: var(--sc-overlay);
  display: none;
  align-items: center;
  justify-content: center;
  animation: sc-fade-in 0.2s ease;
}

/*
 * cbrgpd-script.js opens modal via: modal.style.display = 'block'
 * Override to flex so the inner .sc-modal stays centered.
 */
.sc-overlay.is-visible,
#shieldconsent-modal[style*="display: block"],
#shieldconsent-modal[style*="display:block"] {
  display: flex !important;
}

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

/* ==========================================================================
   MODAL
   ========================================================================== */

.sc-modal {
  background: var(--sc-bg);
  width: 560px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--sc-border);
  animation: sc-modal-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: inherit;
}

@keyframes sc-modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* --- Modal header --- */

.sc-modal-header {
  padding: 24px 28px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.sc-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--sc-text);
  letter-spacing: -0.02em;
}

.sc-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sc-text-secondary);
  padding: 4px;
  line-height: 1;
  font-size: 20px;
  transition: color 0.15s;
}
.sc-modal-close:focus {
  outline: none;
}
.sc-modal-close:focus-visible {
  outline: 2px solid var(--sc-accent);
  outline-offset: 2px;
}
.sc-modal-close:hover {
  color: var(--sc-text);
}

/* --- Tabs --- */

.sc-tabs {
  display: flex;
  border-bottom: 1px solid var(--sc-border);
  margin: 16px 28px 0;
  gap: 0;
}

.sc-tab {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--sc-text-secondary);
  background: none;
  border: none;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
  outline: none;
}
.sc-tab:hover {
  color: var(--sc-text);
}
.sc-tab:focus {
  outline: none;
  box-shadow: none;
}
.sc-tab.is-active {
  color: var(--sc-text);
  border-bottom-color: var(--sc-accent);
  font-weight: 600;
}

/* --- Modal body --- */

.sc-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px;
}

.sc-modal-intro {
  font-size: 14px;
  color: var(--sc-text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}

/* --- Tab panels --- */

.sc-tab-panel {
  display: none;
}
.sc-tab-panel.is-active {
  display: block;
}

/* ==========================================================================
   CATEGORY ACCORDION
   ========================================================================== */

.sc-category {
  border: 1px solid var(--sc-border);
  margin-bottom: 8px;
}

.sc-category-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  gap: 12px;
  transition: background 0.1s;
}
.sc-category-header:hover {
  background: var(--sc-surface);
}

.sc-category-chevron {
  color: var(--sc-text-secondary);
  transition: transform 0.2s;
  flex-shrink: 0;
  width: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sc-category-chevron svg {
  display: block;
  fill: var(--sc-text-secondary);
}
.sc-category.is-open .sc-category-chevron {
  transform: rotate(90deg);
}

.sc-category-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--sc-text);
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sc-category-badge {
  font-size: 11px;
  font-weight: 600;
  background: var(--sc-surface);
  color: var(--sc-text-secondary);
  border: 1px solid var(--sc-border);
  padding: 1px 7px;
  line-height: 1.5;
  letter-spacing: 0.02em;
}

.sc-category-status {
  font-size: 12px;
  font-weight: 500;
  color: var(--sc-accent);
  flex-shrink: 0;
}

/* --- Toggle switch --- */

.sc-toggle {
  position: relative;
  width: var(--sc-toggle-w);
  height: var(--sc-toggle-h);
  flex-shrink: 0;
}
.sc-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.sc-toggle-track {
  position: absolute;
  inset: 0;
  background: #8B95A5;
  cursor: pointer;
  transition: background 0.2s;
}
.sc-toggle-track::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.sc-toggle input:checked + .sc-toggle-track {
  background: var(--sc-accent);
}
.sc-toggle input:checked + .sc-toggle-track::after {
  transform: translateX(20px);
}
.sc-toggle input:disabled + .sc-toggle-track {
  background: var(--sc-accent);
  opacity: 0.6;
  cursor: default;
}
.sc-toggle input:disabled:checked + .sc-toggle-track {
  opacity: 1;
}

/* --- Category detail (accordion body) --- */

.sc-category-detail {
  display: none;
  padding: 0 16px 14px 44px;
}
.sc-category.is-open .sc-category-detail {
  display: block;
}

/* Consent tab: description visible in accordion, no cookie list */

.sc-category-desc {
  font-size: 13px;
  color: var(--sc-text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
}

/* ==========================================================================
   COOKIE LIST (inside accordions)
   ========================================================================== */

.sc-cookie-list {
  border-top: 1px solid var(--sc-border);
}

.sc-cookie-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--sc-border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.sc-cookie-item:last-child {
  border-bottom: none;
}

.sc-cookie-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--sc-text);
  font-family: "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

.sc-cookie-provider {
  font-size: 12px;
  color: var(--sc-text-secondary);
}

.sc-cookie-duration {
  font-size: 11px;
  color: var(--sc-text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ==========================================================================
   ABOUT TAB
   ========================================================================== */

.sc-about-section {
  margin-bottom: 16px;
}
.sc-about-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--sc-text);
  margin-bottom: 6px;
}
.sc-about-section p {
  font-size: 13px;
  color: var(--sc-text-secondary);
  line-height: 1.5;
}
.sc-about-section a {
  color: var(--sc-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Attribution — protected, do not override */
.sc-attribution[data-sc-integrity] {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  position: static !important;
  height: auto !important;
  overflow: visible !important;
  clip: auto !important;
  clip-path: none !important;
  pointer-events: auto !important;
  font-size: 12px !important;
  transform: none !important;
}

/* ==========================================================================
   MODAL FOOTER
   ========================================================================== */

.sc-modal-footer {
  padding: 16px 28px 20px;
  border-top: 1px solid var(--sc-border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.sc-modal-footer .sc-btn {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   FLOATING BUTTON
   ========================================================================== */

.sc-floating-btn {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 99998;
  width: 40px;
  height: 40px;
  background: var(--sc-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: transform 0.15s;
}
.sc-floating-btn:hover {
  transform: scale(1.05);
}
.sc-floating-btn.is-visible {
  display: flex;
}

/* ==========================================================================
   BOOT VISIBILITY OVERRIDES
   Source of truth:
   - <html>.sc-show-banner  => banner visible, FAB hidden
   - <html>.sc-show-fab     => FAB visible, banner hidden
   Safe default: show banner if no class yet.
   ========================================================================== */

/* SAFE DEFAULT */
html:not(.sc-show-banner):not(.sc-show-fab) .sc-banner,
html:not(.sc-show-banner):not(.sc-show-fab) #shieldconsent-banner {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}
html:not(.sc-show-banner):not(.sc-show-fab) .sc-floating-btn,
html:not(.sc-show-banner):not(.sc-show-fab) #cbrgpd-floating-button {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* BANNER MODE */
html.sc-show-banner .sc-banner,
html.sc-show-banner #shieldconsent-banner {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}
html.sc-show-banner .sc-floating-btn,
html.sc-show-banner #cbrgpd-floating-button {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* FAB MODE */
html.sc-show-fab .sc-floating-btn,
html.sc-show-fab #cbrgpd-floating-button {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}
html.sc-show-fab .sc-banner,
html.sc-show-fab #shieldconsent-banner {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Hidden states — must beat [style] overrides */
.sc-banner.is-hidden,
.sc-overlay.is-hidden,
#shieldconsent-modal.is-hidden,
.sc-floating-btn.is-hidden {
  display: none !important;
}

/* ==========================================================================
   RESPONSIVE — Mobile
   ========================================================================== */

@media (max-width: 480px) {
  .sc-banner {
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
    padding: 24px 20px 20px;
  }

  .sc-banner-actions {
    flex-direction: column;
  }
  .sc-banner-actions .sc-btn {
    width: 100%;
    text-align: center;
  }

  .sc-modal {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    height: 100vh;
  }

  .sc-modal-header {
    padding: 20px 20px 0;
  }
  .sc-tabs {
    margin: 12px 20px 0;
  }
  .sc-modal-body {
    padding: 16px 20px;
  }
  .sc-modal-footer {
    padding: 14px 20px 18px;
    flex-wrap: wrap;
  }
  .sc-modal-footer .sc-btn {
    flex: 1 1 auto;
  }
}
