/* ============================================================
   COOKIE CONSENT BANNER V2 — DESIGN SYSTEM COMPATIBLE
   (Google Consent Mode v2 & RODO/GDPR)
   ============================================================ */

:root {
  /* Dynamiczne mapowanie na zmienne motywu strony z bezpiecznymi fallbackami */
  --cb-accent:       var(--orange-accent, var(--accent-blue, var(--primary, #F4743B)));
  --cb-accent-hover: var(--orange-dark, var(--accent-blue-hover, var(--primary-hover, #df5d24)));
  --cb-success:      var(--accent-green, var(--success, #30d158));
  --cb-bg-dark:      rgba(9, 9, 11, 0.95);
  --cb-bg-light:     rgba(255, 255, 255, 0.96);
  --cb-radius:       var(--radius-2xl, var(--r-xl, 20px));
  --cb-font:         var(--sans, var(--font-system, -apple-system, BlinkMacSystemFont, 'Plus Jakarta Sans', Roboto, sans-serif));
}

.cookie-banner {
  position: fixed;
  bottom: 24px;
  left: 24px;
  right: 24px;
  max-width: 580px;
  margin: 0 auto;
  background: var(--cb-bg-dark);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--cb-radius);
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
  z-index: 99999;
  color: #f5f5f7;
  display: none;
  font-family: var(--cb-font);
  animation: cookieSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] .cookie-banner,
body.light-theme .cookie-banner,
body:not([data-theme="dark"]) .cookie-banner {
  background: var(--cb-bg-light);
  border-color: rgba(0, 0, 0, 0.12);
  color: #1d1d1f;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

@keyframes cookieSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.cookie-banner-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.cookie-banner-icon {
  font-size: 1.35rem;
  line-height: 1;
}

.cookie-banner-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
  color: inherit;
}

.cookie-banner-text {
  font-size: 0.86rem;
  color: rgba(245, 245, 247, 0.8);
  line-height: 1.55;
  margin-bottom: 1.15rem;
}

[data-theme="light"] .cookie-banner-text,
body.light-theme .cookie-banner-text,
body:not([data-theme="dark"]) .cookie-banner-text {
  color: rgba(29, 29, 31, 0.8);
}

.cookie-banner-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.btn-cookie {
  padding: 0.55rem 1.15rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-cookie-accept {
  background: var(--cb-accent);
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(244, 116, 59, 0.35);
}

.btn-cookie-accept:hover {
  background: var(--cb-accent-hover);
  transform: translateY(-1px);
}

.btn-cookie-essential {
  background: rgba(255, 255, 255, 0.1);
  color: #f5f5f7;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

[data-theme="light"] .btn-cookie-essential,
body.light-theme .btn-cookie-essential,
body:not([data-theme="dark"]) .btn-cookie-essential {
  background: rgba(0, 0, 0, 0.05);
  color: #1d1d1f;
  border-color: rgba(0, 0, 0, 0.1);
}

.btn-cookie-essential:hover {
  background: rgba(0, 0, 0, 0.08);
}

.btn-cookie-customize {
  background: transparent;
  color: var(--cb-accent);
  font-size: 0.82rem;
  padding: 0.55rem 0.8rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 600;
}

.btn-cookie-customize:hover {
  color: var(--cb-accent-hover);
}

/* Panel preferencji szczegółowych */
.cookie-preferences-panel {
  display: none;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-direction: column;
  gap: 0.85rem;
}

[data-theme="light"] .cookie-preferences-panel,
body.light-theme .cookie-preferences-panel,
body:not([data-theme="dark"]) .cookie-preferences-panel {
  border-top-color: rgba(0, 0, 0, 0.08);
}

.cookie-pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .cookie-pref-row,
body.light-theme .cookie-pref-row,
body:not([data-theme="dark"]) .cookie-pref-row {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.05);
}

.cookie-pref-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.cookie-pref-name {
  font-size: 0.88rem;
  font-weight: 600;
}

.cookie-pref-desc {
  font-size: 0.76rem;
  color: rgba(245, 245, 247, 0.65);
}

[data-theme="light"] .cookie-pref-desc,
body.light-theme .cookie-pref-desc,
body:not([data-theme="dark"]) .cookie-pref-desc {
  color: rgba(29, 29, 31, 0.65);
}

.cookie-pref-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--cb-success);
  background: rgba(48, 209, 88, 0.15);
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  white-space: nowrap;
}

/* Przełącznik Toggle Switch */
.cookie-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.cookie-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.cookie-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.2);
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 24px;
}

[data-theme="light"] .cookie-slider,
body.light-theme .cookie-slider,
body:not([data-theme="dark"]) .cookie-slider {
  background-color: rgba(0, 0, 0, 0.15);
}

.cookie-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.cookie-switch input:checked + .cookie-slider {
  background-color: var(--cb-accent);
}

.cookie-switch input:checked + .cookie-slider:before {
  transform: translateX(20px);
}

.cookie-save-btn-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

/* Link w stopce do ponownego otwarcia ustawień */
.cookie-settings-link {
  background: none;
  border: none;
  color: inherit;
  font-size: inherit;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  font-family: inherit;
  opacity: 0.8;
  transition: opacity 0.2s, color 0.2s;
}

.cookie-settings-link:hover {
  opacity: 1;
  color: var(--cb-accent);
}

@media (max-width: 640px) {
  .cookie-banner {
    bottom: 12px;
    left: 12px;
    right: 12px;
    padding: 1.25rem;
  }
  .cookie-banner-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-cookie {
    text-align: center;
    width: 100%;
  }
}
