/*!
 * cookie-consent.css — Kit GDPR / Cookies UE
 * Adapta el banner a la marca sobrescribiendo las variables --cc-* en tu CSS
 * (cargado DESPUÉS de este archivo), por ejemplo:
 *   :root { --cc-primary: #0f766e; --cc-radius: 20px; --cc-font: "Inter", sans-serif; }
 * Regla AEPD: "Aceptar" y "Rechazar" comparten estilo (.cc-btn--choice). No les des
 * colores o tamaños distintos.
 */

/* ---------- Tokens de diseño (tema claro por defecto) ---------- */
:root {
  --cc-font: inherit;
  --cc-font-size: 15px;
  --cc-line-height: 1.5;
  --cc-title-size: 1.1em;
  --cc-title-weight: 700;

  --cc-bg: #ffffff;
  --cc-text: #1f2328;
  --cc-muted: #59636e;
  --cc-border: #e2e5e9;
  --cc-link: currentColor;

  /* Botones Aceptar y Rechazar (idénticos) */
  --cc-primary: #1f2328;
  --cc-primary-text: #ffffff;
  --cc-primary-hover: #3a4148;

  /* Botones secundarios (Configurar, Guardar) */
  /* --cc-secondary-text y --cc-secondary-border heredan de --cc-text / --cc-border si no se definen */
  --cc-secondary-bg: transparent;
  --cc-secondary-hover: rgba(127, 127, 127, .12);

  --cc-toggle-off: #c4c9d0;  /* --cc-toggle-on: por defecto = --cc-primary */
  --cc-focus: #2563eb;

  --cc-radius: 14px;
  --cc-btn-radius: 10px;
  --cc-btn-padding: .7em 1.2em;
  --cc-shadow: 0 12px 40px rgba(0, 0, 0, .18);
  --cc-backdrop: rgba(10, 12, 16, .55);
  --cc-max-width: 440px;
  --cc-offset: 16px;
  --cc-z: 2147483000;
}

/* ---------- Tema oscuro ---------- */
[data-cc-theme="dark"] {
  --cc-bg: #17191d;
  --cc-text: #eef0f2;
  --cc-muted: #a4acb6;
  --cc-border: #30353c;
  --cc-primary: #eef0f2;
  --cc-primary-text: #17191d;
  --cc-primary-hover: #d5d9de;
  --cc-toggle-off: #4a515a;
  --cc-focus: #7aa7ff;
  --cc-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}
@media (prefers-color-scheme: dark) {
  [data-cc-theme="auto"] {
    --cc-bg: #17191d;
    --cc-text: #eef0f2;
    --cc-muted: #a4acb6;
    --cc-border: #30353c;
    --cc-primary: #eef0f2;
    --cc-primary-text: #17191d;
    --cc-primary-hover: #d5d9de;
    --cc-toggle-off: #4a515a;
    --cc-focus: #7aa7ff;
    --cc-shadow: 0 12px 40px rgba(0, 0, 0, .5);
  }
}

/* ---------- Base ---------- */
.cc-root,
.cc-inline {
  font-family: var(--cc-font);
  font-size: var(--cc-font-size);
  line-height: var(--cc-line-height);
  color: var(--cc-text);
}
.cc-root *,
.cc-root *::before,
.cc-root *::after,
.cc-inline *,
.cc-inline *::before,
.cc-inline *::after { box-sizing: border-box; }
.cc-root [hidden],
.cc-inline [hidden] { display: none; }
html.cc-lock { overflow: hidden; }

.cc-link { color: var(--cc-link); text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Botones ---------- */
.cc-btn {
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  padding: var(--cc-btn-padding);
  border-radius: var(--cc-btn-radius);
  border: 1px solid transparent;
  cursor: pointer;
  flex: 1 1 auto;
  text-align: center;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.cc-btn--choice { background: var(--cc-primary); color: var(--cc-primary-text); border-color: var(--cc-primary); }
.cc-btn--choice:hover { background: var(--cc-primary-hover); border-color: var(--cc-primary-hover); }
.cc-btn--secondary { background: var(--cc-secondary-bg); color: var(--cc-secondary-text, var(--cc-text)); border-color: var(--cc-secondary-border, var(--cc-border)); }
.cc-btn--secondary:hover { background: var(--cc-secondary-hover); }
.cc-btn:focus-visible,
.cc-close:focus-visible,
.cc-float:focus-visible,
.cc-link:focus-visible,
.cc-switch input:focus-visible + .cc-switch__track,
.cc-modal__dialog:focus-visible { outline: 3px solid var(--cc-focus); outline-offset: 2px; }

/* ---------- Banner ---------- */
.cc-banner {
  position: fixed;
  z-index: var(--cc-z);
  background: var(--cc-bg);
  color: var(--cc-text);
  border: 1px solid var(--cc-border);
  box-shadow: var(--cc-shadow);
  padding: 20px;
  animation: cc-in .25s ease-out;
}
.cc-banner__title { margin: 0 0 6px; font-size: var(--cc-title-size); font-weight: var(--cc-title-weight); line-height: 1.3; color: inherit; }
.cc-banner__text { margin: 0; color: var(--cc-muted); }
.cc-banner__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* layout: box (tarjeta en esquina) */
[data-cc-layout="box"] .cc-banner {
  bottom: var(--cc-offset);
  width: calc(100% - 2 * var(--cc-offset));
  max-width: var(--cc-max-width);
  border-radius: var(--cc-radius);
}
[data-cc-layout="box"][data-cc-position$="left"] .cc-banner { left: var(--cc-offset); }
[data-cc-layout="box"][data-cc-position$="right"] .cc-banner { right: var(--cc-offset); }
[data-cc-layout="box"][data-cc-position$="center"] .cc-banner { left: 50%; transform: translateX(-50%); }

/* layout: bar (barra inferior a todo el ancho) */
[data-cc-layout="bar"] .cc-banner {
  left: 0; right: 0; bottom: 0;
  border-width: 1px 0 0;
  display: flex; align-items: center; gap: 24px;
  padding: 18px max(20px, calc((100% - 1200px) / 2));
}
[data-cc-layout="bar"] .cc-banner__body { flex: 1 1 auto; }
[data-cc-layout="bar"] .cc-banner__actions { margin-top: 0; flex: 0 0 auto; flex-wrap: nowrap; }

/* layout: modal (centrado con fondo) */
[data-cc-layout="modal"] .cc-banner {
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 2 * var(--cc-offset));
  max-width: 520px;
  border-radius: var(--cc-radius);
  padding: 28px;
}

/* ---------- Fondo ---------- */
.cc-backdrop { position: fixed; inset: 0; z-index: var(--cc-z); background: var(--cc-backdrop); }

/* ---------- Modal de preferencias ---------- */
.cc-modal { position: fixed; inset: 0; z-index: calc(var(--cc-z) + 1); display: flex; align-items: center; justify-content: center; padding: var(--cc-offset); }
.cc-modal[hidden] { display: none; }
.cc-modal .cc-backdrop { z-index: 0; }
.cc-modal__dialog {
  position: relative;
  z-index: 1;
  display: flex; flex-direction: column;
  width: 100%; max-width: 560px; max-height: calc(100vh - 2 * var(--cc-offset));
  max-height: calc(100dvh - 2 * var(--cc-offset));
  background: var(--cc-bg);
  color: var(--cc-text);
  border: 1px solid var(--cc-border);
  border-radius: var(--cc-radius);
  box-shadow: var(--cc-shadow);
  animation: cc-in .2s ease-out;
}
.cc-modal__header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 20px 0; }
.cc-modal__title { margin: 0; font-size: var(--cc-title-size); font-weight: var(--cc-title-weight); line-height: 1.3; color: inherit; }
.cc-modal__body { padding: 12px 20px; overflow-y: auto; }
.cc-modal__text { margin: 0 0 8px; color: var(--cc-muted); }
.cc-modal__actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px 20px 20px; border-top: 1px solid var(--cc-border); }
.cc-close {
  font: inherit; font-size: 1.6em; line-height: 1;
  width: 36px; height: 36px; flex: 0 0 auto;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--cc-muted); cursor: pointer;
}
.cc-close:hover { background: var(--cc-secondary-hover); color: var(--cc-text); }

/* ---------- Categorías ---------- */
.cc-cat { padding: 14px 0; border-bottom: 1px solid var(--cc-border); }
.cc-cat:last-of-type { border-bottom: 0; }
.cc-cat__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cc-cat__title { font-weight: 600; }
.cc-cat__desc { margin: 4px 0 0; color: var(--cc-muted); font-size: .92em; }
.cc-cat__services { display: block; margin-top: 2px; }
.cc-cat__always { font-size: .85em; font-weight: 600; color: var(--cc-muted); white-space: nowrap; }

/* Interruptor */
.cc-switch { position: relative; display: inline-flex; flex: 0 0 auto; cursor: pointer; }
.cc-switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.cc-switch__track {
  width: 44px; height: 24px; border-radius: 999px;
  background: var(--cc-toggle-off);
  position: relative; transition: background-color .15s ease;
}
.cc-switch__track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: transform .15s ease;
}
.cc-switch input:checked + .cc-switch__track { background: var(--cc-toggle-on, var(--cc-primary)); }
.cc-switch input:checked + .cc-switch__track::after { transform: translateX(20px); }

/* ---------- Botón flotante para reabrir ---------- */
.cc-float {
  position: fixed; z-index: var(--cc-z);
  bottom: var(--cc-offset);
  width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--cc-bg); color: var(--cc-text);
  border: 1px solid var(--cc-border); box-shadow: var(--cc-shadow);
  cursor: pointer;
}
.cc-float[hidden] { display: none; }
[data-cc-position$="left"] .cc-float { left: var(--cc-offset); }
[data-cc-position$="right"] .cc-float,
[data-cc-position$="center"] .cc-float { right: var(--cc-offset); }

/* ---------- Panel embebido (política de cookies / privacidad) ---------- */
.cc-inline {
  background: var(--cc-bg);
  border: 1px solid var(--cc-border);
  border-radius: var(--cc-radius);
  padding: 4px 20px 20px;
  margin: 1.5em 0;
}
.cc-inline__status { margin: 16px 0 4px; font-weight: 600; }
.cc-inline__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ---------- Tabla de cookies ---------- */
.cc-table-wrap { overflow-x: auto; margin: 1em 0; }
.cc-table { width: 100%; border-collapse: collapse; font-size: .92em; }
.cc-table th,
.cc-table td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--cc-border, #e2e5e9); }
.cc-table th { font-weight: 600; white-space: nowrap; }
.cc-table__name { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: nowrap; }

/* ---------- Móvil ---------- */
@media (max-width: 640px) {
  [data-cc-layout="bar"] .cc-banner { display: block; padding: 16px; }
  [data-cc-layout="bar"] .cc-banner__actions { margin-top: 14px; flex-wrap: wrap; }
  [data-cc-layout="box"] .cc-banner { left: 8px; right: 8px; bottom: 8px; width: auto; max-width: none; transform: none; }
  .cc-btn--choice { flex: 1 1 40%; }
  .cc-btn--secondary { flex: 1 1 100%; order: 3; }
}

@keyframes cc-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .cc-banner, .cc-modal__dialog { animation: none; }
  .cc-btn, .cc-switch__track, .cc-switch__track::after { transition: none; }
}
