/* ==========================================================
   Midamentum — Sistema de cookies V039
   Usa las variables CSS del proyecto (style.css)
   ========================================================== */

/* ----------------------------------------------------------
   Banner
   ---------------------------------------------------------- */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  padding: 20px 0;
  background: rgba(250, 250, 255, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line-strong);
  box-shadow: 0 -8px 40px rgba(26, 26, 26, 0.08);
}

.cookie-banner__inner {
  width: min(var(--max), calc(100% - 40px));
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.cookie-banner__text {
  flex: 1 1 340px;
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-soft);
}

.cookie-banner__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ----------------------------------------------------------
   Botones de cookies (independientes del .btn del proyecto)
   ---------------------------------------------------------- */
.cookie-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
  border: 1.5px solid transparent;
  text-decoration: none;
}

.cookie-btn:focus-visible {
  outline: 2px solid var(--mk-coral);
  outline-offset: 2px;
}

.cookie-btn--primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.cookie-btn--primary:hover {
  background: #333;
  border-color: #333;
}

.cookie-btn--secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--line-strong);
}

.cookie-btn--secondary:hover {
  background: var(--bg-soft);
  border-color: var(--text);
}

/* B-02: Mismo nivel de prominencia para Aceptar y Rechazar */
.cookie-btn--choice {
  background: transparent;
  color: var(--text);
  border-color: var(--line-strong);
}

.cookie-btn--choice:hover {
  background: var(--bg-soft);
  border-color: var(--text);
}

.cookie-btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
  padding-left: 12px;
  padding-right: 12px;
}

.cookie-btn--ghost:hover {
  color: var(--text);
  background: var(--bg-soft);
}

/* ----------------------------------------------------------
   Overlay
   ---------------------------------------------------------- */
.cookie-overlay {
  position: fixed;
  inset: 0;
  z-index: 210;
  background: rgba(26, 26, 26, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.cookie-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ----------------------------------------------------------
   Panel
   ---------------------------------------------------------- */
.cookie-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.97);
  z-index: 220;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  box-shadow: 0 32px 80px rgba(26, 26, 26, 0.16);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.cookie-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.cookie-panel__inner {
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.cookie-panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.cookie-panel__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.3;
}

.cookie-panel__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.cookie-panel__close:hover {
  background: var(--bg-soft);
  color: var(--text);
}

.cookie-panel__close:focus-visible {
  outline: 2px solid var(--mk-coral);
  outline-offset: 2px;
}

.cookie-panel__close svg {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.cookie-panel__desc {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-soft);
}

/* ----------------------------------------------------------
   Lista de categorías
   ---------------------------------------------------------- */
.cookie-categories {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.cookie-category {
  padding: 20px 20px;
  border-bottom: 1px solid var(--line);
}

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

.cookie-category__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.cookie-category__info {
  flex: 1;
}

.cookie-category__name {
  display: block;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.cookie-category__desc {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--text-muted);
}

/* ----------------------------------------------------------
   Toggle switch
   ---------------------------------------------------------- */
.cookie-toggle {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  cursor: pointer;
  gap: 8px;
}

.cookie-toggle__input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.cookie-toggle__track {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: var(--grey-3, rgba(26, 26, 26, 0.18));
  transition: background 0.18s ease;
  flex-shrink: 0;
}

.cookie-toggle__track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(26, 26, 26, 0.2);
  transition: transform 0.18s ease;
}

.cookie-toggle__input:checked + .cookie-toggle__track {
  background: var(--text);
}

.cookie-toggle__input:checked + .cookie-toggle__track::after {
  transform: translateX(18px);
}

.cookie-toggle__input:focus-visible + .cookie-toggle__track {
  outline: 2px solid var(--mk-coral);
  outline-offset: 2px;
}

.cookie-toggle__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Toggle bloqueado (técnicas) */
.cookie-toggle--locked {
  cursor: default;
  pointer-events: none;
}

.cookie-toggle__label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

/* ----------------------------------------------------------
   Footer del panel
   ---------------------------------------------------------- */
.cookie-panel__footer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

/* ----------------------------------------------------------
   Body lock cuando el panel está abierto
   ---------------------------------------------------------- */
body.cookie-panel-open {
  overflow: hidden;
}

/* ----------------------------------------------------------
   Reducción de movimiento
   ---------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .cookie-banner,
  .cookie-overlay,
  .cookie-panel,
  .cookie-toggle__track,
  .cookie-toggle__track::after,
  .cookie-btn {
    transition: none;
  }
}

/* ----------------------------------------------------------
   Responsive
   ---------------------------------------------------------- */
@media (max-width: 640px) {
  .cookie-banner__inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .cookie-banner__actions {
    width: 100%;
  }

  .cookie-btn--primary,
  .cookie-btn--secondary,
  .cookie-btn--choice {
    flex: 1;
    justify-content: center;
  }

  .cookie-panel__inner {
    padding: 24px 20px;
    gap: 20px;
  }

  .cookie-panel__footer {
    flex-direction: column;
    align-items: stretch;
  }

  .cookie-panel__footer .cookie-btn {
    width: 100%;
    justify-content: center;
  }
}
