/* =========================================================
   PORTASOFT — COOKIE CONSENT
   Componente reutilizável, responsivo e acessível
   ========================================================= */

:root {
  --cc-bg: #071426;
  --cc-bg-strong: #020817;
  --cc-surface: rgba(11, 27, 51, 0.96);
  --cc-surface-soft: #f8fbff;
  --cc-primary: #2563eb;
  --cc-primary-hover: #1d4ed8;
  --cc-cyan: #22d3ee;
  --cc-text: #f8fafc;
  --cc-text-muted: #b7c4d8;
  --cc-ink: #0f172a;
  --cc-ink-muted: #64748b;
  --cc-border: rgba(148, 163, 184, 0.22);
  --cc-border-light: #dbe5f3;
  --cc-success: #059669;
  --cc-radius: 22px;
  --cc-shadow: 0 26px 80px rgba(2, 8, 23, 0.32);
  --cc-z-banner: 2200;
  --cc-z-modal: 2300;
}

.cookie-consent[hidden],
.cookie-preferences[hidden],
.cookie-toast[hidden] {
  display: none !important;
}

.cookie-consent,
.cookie-preferences,
.cookie-toast {
  font-family: Inter, Arial, sans-serif;
}

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

.cookie-consent {
  position: fixed;
  z-index: var(--cc-z-banner);
  right: 24px;
  bottom: 24px;
  width: min(620px, calc(100vw - 48px));
  color: var(--cc-text);
  background:
    radial-gradient(circle at 90% 0%, rgba(37, 99, 235, 0.30), transparent 38%),
    linear-gradient(145deg, rgba(7, 20, 38, 0.98), rgba(2, 8, 23, 0.99));
  border: 1px solid var(--cc-border);
  border-radius: var(--cc-radius);
  box-shadow: var(--cc-shadow);
  backdrop-filter: blur(24px);
  overflow: hidden;
  animation: ccSlideUp 420ms cubic-bezier(.2,.8,.2,1);
}

.cookie-consent::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--cc-primary), var(--cc-cyan));
}

.cookie-consent__inner {
  position: relative;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 18px;
  padding: 26px;
}

.cookie-consent__icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  color: #fff;
  background: linear-gradient(145deg, rgba(37,99,235,.95), rgba(34,211,238,.65));
  box-shadow: 0 14px 34px rgba(37, 99, 235, 0.28);
}

.cookie-consent__icon svg {
  width: 28px;
  height: 28px;
}

.cookie-consent__content h2 {
  margin: 0 0 8px;
  color: #fff;
  font: 700 21px/1.25 Sora, Inter, sans-serif;
  letter-spacing: -0.025em;
}

.cookie-consent__content p {
  margin: 0;
  color: var(--cc-text-muted);
  font-size: 14px;
  line-height: 1.65;
}

.cookie-consent__links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 12px;
}

.cookie-consent__links a {
  color: #93c5fd;
  font-size: 13px;
  font-weight: 700;
  text-underline-offset: 3px;
}

.cookie-consent__links a:hover,
.cookie-consent__links a:focus-visible {
  color: #fff;
  text-decoration: underline;
}

.cookie-consent__actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.cc-button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 11px 15px;
  font: 700 13px/1.2 Inter, Arial, sans-serif;
  cursor: pointer;
  transition: transform 220ms ease, border-color 220ms ease,
              background-color 220ms ease, box-shadow 220ms ease;
}

.cc-button:hover {
  transform: translateY(-1px);
}

.cc-button--primary {
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  box-shadow: 0 10px 26px rgba(37, 99, 235, 0.28);
}

.cc-button--primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.38);
}

.cc-button--secondary {
  color: #fff;
  border-color: rgba(148, 163, 184, 0.32);
  background: rgba(255, 255, 255, 0.06);
}

.cc-button--secondary:hover {
  border-color: rgba(147, 197, 253, 0.75);
  background: rgba(37, 99, 235, 0.12);
}

.cc-button--ghost {
  color: #cbd5e1;
  background: transparent;
}

.cc-button--ghost:hover {
  color: #fff;
  background: rgba(255,255,255,.06);
}

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

.cookie-preferences {
  position: fixed;
  z-index: var(--cc-z-modal);
  inset: 0;
}

.cookie-preferences__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 8, 23, 0.76);
  backdrop-filter: blur(8px);
  animation: ccFadeIn 220ms ease;
}

.cookie-preferences__dialog {
  position: relative;
  width: min(760px, calc(100vw - 32px));
  max-height: min(820px, calc(100vh - 32px));
  margin: 16px auto;
  display: flex;
  flex-direction: column;
  color: var(--cc-ink);
  background: #fff;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 24px;
  box-shadow: var(--cc-shadow);
  overflow: hidden;
  animation: ccScaleIn 280ms cubic-bezier(.2,.8,.2,1);
}

.cookie-preferences__header {
  position: relative;
  padding: 28px 72px 23px 28px;
  color: #fff;
  background:
    radial-gradient(circle at 90% 0%, rgba(37,99,235,.34), transparent 42%),
    linear-gradient(140deg, #071426, #020817);
}

.cookie-preferences__eyebrow {
  display: block;
  margin-bottom: 8px;
  color: #7dd3fc;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
}

.cookie-preferences__header h2 {
  margin: 0;
  font: 700 clamp(25px, 4vw, 34px)/1.15 Sora, Inter, sans-serif;
  letter-spacing: -0.04em;
}

.cookie-preferences__header p {
  max-width: 590px;
  margin: 10px 0 0;
  color: #b7c4d8;
  font-size: 14px;
  line-height: 1.6;
}

.cookie-preferences__close {
  position: absolute;
  top: 21px;
  right: 21px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #fff;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 12px;
  background: rgba(255,255,255,.06);
  cursor: pointer;
}

.cookie-preferences__close:hover {
  background: rgba(255,255,255,.12);
}

.cookie-preferences__body {
  padding: 24px 28px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.cookie-category {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: start;
  padding: 20px 0;
  border-bottom: 1px solid #e6edf6;
}

.cookie-category:first-child {
  padding-top: 4px;
}

.cookie-category:last-child {
  border-bottom: 0;
}

.cookie-category__title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.cookie-category h3 {
  margin: 0;
  color: #0f172a;
  font: 700 16px/1.35 Sora, Inter, sans-serif;
}

.cookie-category p {
  max-width: 590px;
  margin: 0;
  color: #64748b;
  font-size: 13.5px;
  line-height: 1.58;
}

.cookie-category__badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  color: #047857;
  background: #ecfdf5;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.cookie-category__details {
  margin-top: 10px;
}

.cookie-category__details summary {
  width: max-content;
  max-width: 100%;
  color: #2563eb;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.cookie-category__details ul {
  margin: 9px 0 0;
  padding-left: 18px;
  color: #64748b;
  font-size: 12px;
}

.cookie-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  margin-top: 4px;
}

.cookie-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.cookie-switch__track {
  position: relative;
  width: 50px;
  height: 29px;
  display: inline-block;
  border-radius: 999px;
  background: #cbd5e1;
  box-shadow: inset 0 0 0 1px rgba(15,23,42,.08);
  cursor: pointer;
  transition: background-color 200ms ease;
}

.cookie-switch__track::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 10px rgba(15,23,42,.20);
  transition: transform 200ms ease;
}

.cookie-switch input:checked + .cookie-switch__track {
  background: linear-gradient(135deg, #2563eb, #38bdf8);
}

.cookie-switch input:checked + .cookie-switch__track::after {
  transform: translateX(21px);
}

.cookie-switch input:focus-visible + .cookie-switch__track {
  outline: 3px solid #7dd3fc;
  outline-offset: 3px;
}

.cookie-switch input:disabled + .cookie-switch__track {
  cursor: not-allowed;
  opacity: .75;
}

.cookie-preferences__footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 28px;
  border-top: 1px solid #e6edf6;
  background: #f8fbff;
}

.cookie-preferences__footer .cc-button--secondary {
  color: #0f172a;
  border-color: #cbd5e1;
  background: #fff;
}

.cookie-preferences__footer .cc-button--ghost {
  color: #475569;
}

.cookie-preferences__footer .cc-button--ghost:hover {
  color: #0f172a;
  background: #eaf1fb;
}

/* ---------- Toast ---------- */

.cookie-toast {
  position: fixed;
  z-index: calc(var(--cc-z-modal) + 10);
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  min-width: min(420px, calc(100vw - 32px));
  padding: 14px 18px;
  color: #ecfdf5;
  text-align: center;
  background: rgba(6, 78, 59, 0.96);
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 13px;
  box-shadow: 0 18px 48px rgba(2, 8, 23, .28);
  animation: ccSlideUp 240ms ease;
}

/* ---------- Preferences page ---------- */

.cookie-page-intro {
  margin-bottom: 28px;
}

.cookie-page-card {
  background: #fff;
  border: 1px solid #dbe5f3;
  border-radius: 20px;
  padding: 26px;
  box-shadow: 0 14px 42px rgba(15, 23, 42, .06);
}

.cookie-page-card .cookie-category {
  padding: 22px 0;
}

.cookie-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 25px;
}

.cookie-page-actions .cc-button--secondary {
  color: #0f172a;
  border-color: #cbd5e1;
  background: #fff;
}

/* ---------- States / animations ---------- */

body.cookie-modal-open {
  overflow: hidden;
}

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

@keyframes ccFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes ccScaleIn {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 680px) {
  .cookie-consent {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
    border-radius: 19px;
  }

  .cookie-consent__inner {
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 13px;
    padding: 20px;
  }

  .cookie-consent__icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
  }

  .cookie-consent__content h2 {
    font-size: 18px;
  }

  .cookie-consent__actions {
    grid-template-columns: 1fr;
  }

  .cookie-consent__actions .cc-button--primary {
    order: -1;
  }

  .cookie-preferences__dialog {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    margin: 8px auto;
    border-radius: 19px;
  }

  .cookie-preferences__header {
    padding: 24px 62px 20px 20px;
  }

  .cookie-preferences__close {
    top: 16px;
    right: 14px;
  }

  .cookie-preferences__body {
    padding: 18px 20px;
  }

  .cookie-category {
    gap: 14px;
  }

  .cookie-preferences__footer {
    display: grid;
    grid-template-columns: 1fr;
    padding: 15px 20px 20px;
  }

  .cookie-preferences__footer .cc-button--primary {
    order: -1;
  }
}

@media (max-width: 420px) {
  .cookie-category {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .cookie-category p {
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cookie-consent,
  .cookie-preferences__backdrop,
  .cookie-preferences__dialog,
  .cookie-toast {
    animation: none !important;
  }

  .cc-button,
  .cookie-switch__track,
  .cookie-switch__track::after {
    transition: none !important;
  }
}
