/*!
 * Cookie Consent Banner — Webmari.pt
 * RGPD / GDPR Compliant — v1.0
 */

/* ── Banner principal ── */
#cookie-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: min(700px, calc(100vw - 32px));
  background: var(--card, #ffffff);
  border: 1px solid var(--line, rgba(15,25,48,.1));
  border-radius: 16px;
  padding: 20px 24px;
  box-shadow: 0 8px 48px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.08);
  z-index: 99998;
  animation: cookieFadeUp .32s cubic-bezier(.2,.8,.2,1) both;
  font-family: var(--font-body, 'Plus Jakarta Sans', system-ui, sans-serif);
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text, #0b1324);
}

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

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

.cb__inner {
  display: flex;
  align-items: flex-start;
  gap: 18px;
}

.cb__icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  margin-top: 1px;
  line-height: 1;
}

.cb__body { flex: 1; min-width: 0; }

.cb__title {
  font-weight: 700;
  font-size: .95rem;
  margin: 0 0 5px;
  color: var(--text, #0b1324);
  font-family: var(--font-heading, 'Outfit', system-ui, sans-serif);
}

.cb__desc {
  margin: 0;
  color: var(--muted, #4a587a);
  font-size: .84rem;
}

.cb__desc a {
  color: var(--primary, #4f7cff);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cb__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  align-items: center;
}

/* ── Botões gerais ── */
.cb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  min-height: 44px; /* touch target WCAG */
  border-radius: 8px;
  font-size: .875rem; /* ≥14px */
  font-weight: 600;
  cursor: pointer;
  border: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .15s ease, transform .15s ease, background .15s ease;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1.3;
}

.cb-btn:hover   { opacity: .88; transform: translateY(-1px); }
.cb-btn:active  { transform: translateY(0); }

.cb-btn--primary {
  background: var(--primary, #4f7cff);
  color: #fff;
}

.cb-btn--outline {
  background: transparent;
  color: var(--text, #0b1324);
  border: 1.5px solid var(--line, rgba(15,25,48,.15));
}

.cb-btn--link {
  background: transparent;
  color: var(--muted, #4a587a);
  padding: 8px 6px;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-size: .8rem;
}

/* ── Modal de preferências ── */
#cookie-prefs-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  font-family: var(--font-body, 'Plus Jakarta Sans', system-ui, sans-serif);
  font-size: .875rem;
  color: var(--text, #0b1324);
}

#cookie-prefs-modal[hidden] { display: none !important; }

.cp__overlay {
  position: absolute;
  inset: 0;
  background: rgba(11, 19, 36, .55);
  backdrop-filter: blur(2px);
}

.cp__dialog {
  position: relative;
  background: var(--card, #ffffff);
  border: 1px solid var(--line, rgba(15,25,48,.08));
  border-radius: 20px;
  width: min(540px, 100%);
  max-height: 90dvh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 24px 80px rgba(0,0,0,.28);
}

.cp__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.cp__header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  color: var(--text, #0b1324);
  font-family: var(--font-heading, 'Outfit', system-ui, sans-serif);
}

.cp__close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted, #4a587a);
  font-size: 1.1rem;
  padding: 6px;
  min-width: 44px;  /* touch target */
  min-height: 44px; /* touch target */
  line-height: 1;
  border-radius: 8px;
  transition: color .15s, background .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.cp__close:hover {
  color: var(--text, #0b1324);
  background: var(--bg2, #f9fafb);
}

.cp__intro {
  color: var(--muted, #4a587a);
  margin: 0 0 20px;
  font-size: .84rem;
  line-height: 1.6;
}

.cp__intro a { color: var(--primary, #4f7cff); text-decoration: underline; }

/* Categorias */
.cp__category {
  border: 1px solid var(--line, rgba(15,25,48,.1));
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: border-color .2s;
}

.cp__category:focus-within {
  border-color: var(--primary, #4f7cff);
}

.cp__cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cp__cat-name {
  font-weight: 600;
  font-size: .9rem;
  color: var(--text, #0b1324);
}

.cp__cat-badge {
  font-size: .72rem;
  font-weight: 500;
  color: var(--muted, #4a587a);
  background: var(--bg2, #f9fafb);
  border: 1px solid var(--line, rgba(15,25,48,.1));
  padding: 2px 8px;
  border-radius: 99px;
}

.cp__cat-desc {
  color: var(--muted, #4a587a);
  font-size: .8rem;
  margin: 6px 0 0;
  line-height: 1.55;
}

/* Toggle switch */
.cp__toggle {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.cp__toggle input[type="checkbox"] {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.cp__track {
  display: block;
  width: 42px;
  height: 24px;
  background: var(--line, #dde3f0);
  border-radius: 99px;
  cursor: pointer;
  transition: background .2s ease;
  position: relative;
  flex-shrink: 0;
}

.cp__toggle input:checked + .cp__track { background: var(--primary, #4f7cff); }

.cp__track::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform .2s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

.cp__toggle input:checked + .cp__track::after { transform: translateX(18px); }

.cp__toggle input:disabled + .cp__track {
  opacity: .5;
  cursor: not-allowed;
}

.cp__toggle input:focus-visible + .cp__track {
  outline: 2px solid var(--primary, #4f7cff);
  outline-offset: 2px;
}

/* Rodapé do modal */
.cp__footer {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid var(--line, rgba(15,25,48,.08));
}

/* ── Responsivo ── */
@media (max-width: 560px) {
  #cookie-banner {
    bottom: 8px;
    padding: 16px;
    border-radius: 12px;
  }
  .cb__icon { display: none; }
  .cb__actions { flex-direction: column; align-items: stretch; }
  .cb-btn { justify-content: center; width: 100%; }

  .cp__dialog {
    padding: 20px 16px;
    border-radius: 16px;
  }

  /* Botões do footer do modal em coluna */
  .cp__footer {
    flex-direction: column-reverse;
    gap: 8px;
  }

  .cp__footer .cb-btn {
    width: 100%;
  }

  /* Toggle track maior em mobile */
  .cp__track {
    width: 48px;
    height: 28px;
  }

  .cp__track::after {
    width: 22px;
    height: 22px;
    top: 3px;
    left: 3px;
  }

  .cp__toggle input:checked + .cp__track::after {
    transform: translateX(20px);
  }
}

/* ── Touch targets nos toggles ── */
@media (pointer: coarse) {
  .cp__toggle {
    min-height: 44px;
    padding: 4px 0;
  }

  .cp__cat-header {
    min-height: 44px;
  }
}

/* ── Font-size: nunca abaixo de 14px ── */
.cb__title { font-size: .95rem; }
.cb__desc  { font-size: .875rem; }
.cb-btn    { font-size: .875rem; }
