/**
 * Solo Frutales - Estilos del Sistema de Gestión de Cookies (RGPD / AEPD / LSSI-CE)
 * Totalmente encapsulado y prefijado bajo .sf-cookie-* para evitar colisiones.
 */

:root {
  --sf-c-forest-900: #043a1b;
  --sf-c-forest-800: #074d25;
  --sf-c-forest-700: #0a6230;
  --sf-c-forest-500: #0F8C43;
  --sf-c-forest-100: #d6f2e3;
  --sf-c-citrus-500: #FB923C;
  --sf-c-citrus-600: #ea7b20;
  --sf-c-cream-50: #fffdf5;
  --sf-c-cream-100: #FEF3C7;
  --sf-c-earth-800: #451A03;
  --sf-c-earth-600: #78350f;
  --sf-c-text-muted: #4b6354;
  --sf-c-border: #e2e8f0;
  --sf-c-shadow: rgba(4, 58, 27, 0.15);
  --sf-c-radius-lg: 20px;
  --sf-c-radius-md: 12px;
  --sf-c-radius-full: 9999px;
  --sf-c-font-sans: 'Outfit', system-ui, -apple-system, sans-serif;
  --sf-c-font-serif: 'Lora', Georgia, serif;
}

/* ─────────────────────────────────────────────────────────────
   1. BANNER FLOTANTE (PRIMERA CAPA)
   ───────────────────────────────────────────────────────────── */
.sf-cookie-banner {
  position: fixed;
  bottom: 24px;
  left: 24px;
  max-width: 520px;
  width: calc(100% - 48px);
  background: var(--sf-c-cream-50);
  border: 1px solid rgba(15, 140, 67, 0.2);
  border-radius: var(--sf-c-radius-lg);
  box-shadow: 0 12px 36px var(--sf-c-shadow), 0 2px 8px rgba(0, 0, 0, 0.06);
  padding: 24px;
  z-index: 9998;
  font-family: var(--sf-c-font-sans);
  color: var(--sf-c-earth-800);
  box-sizing: border-box;
  opacity: 0;
  transform: translateY(20px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.sf-cookie-banner.sf-cookie-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.sf-cookie-banner *,
.sf-cookie-modal * {
  box-sizing: border-box;
}

.sf-cookie-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.sf-cookie-icon-wrapper {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background-color: var(--sf-c-forest-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.sf-cookie-title {
  font-family: var(--sf-c-font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--sf-c-forest-900);
  margin: 0;
  line-height: 1.25;
}

.sf-cookie-description {
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--sf-c-text-muted);
  margin: 0 0 18px 0;
}

.sf-cookie-description a {
  color: var(--sf-c-forest-700);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
  transition: color 0.2s;
}

.sf-cookie-description a:hover {
  color: var(--sf-c-citrus-600);
}

/* Botones con estricta paridad visual según directrices AEPD */
.sf-cookie-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sf-cookie-actions .sf-cookie-btn-config {
  grid-column: 1 / -1;
}

@media (min-width: 480px) {
  .sf-cookie-actions {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .sf-cookie-actions .sf-cookie-btn-config {
    grid-column: auto;
  }
}

.sf-cookie-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  font-family: var(--sf-c-font-sans);
  font-size: 0.84rem;
  font-weight: 600;
  border-radius: var(--sf-c-radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1.5px solid transparent;
  text-align: center;
  line-height: 1.2;
}

.sf-cookie-btn:active {
  transform: scale(0.97);
}

/* Aceptar todas */
.sf-cookie-btn-accept {
  background-color: var(--sf-c-forest-500);
  color: #ffffff;
  border-color: var(--sf-c-forest-500);
}

.sf-cookie-btn-accept:hover {
  background-color: var(--sf-c-forest-700);
  border-color: var(--sf-c-forest-700);
  box-shadow: 0 4px 12px rgba(15, 140, 67, 0.25);
}

/* Rechazar no esenciales */
.sf-cookie-btn-reject {
  background-color: var(--sf-c-cream-100);
  color: var(--sf-c-earth-800);
  border-color: rgba(69, 26, 3, 0.2);
}

.sf-cookie-btn-reject:hover {
  background-color: #fde68a;
  border-color: rgba(69, 26, 3, 0.4);
}

/* Configurar */
.sf-cookie-btn-config {
  background-color: transparent;
  color: var(--sf-c-forest-800);
  border-color: rgba(15, 140, 67, 0.35);
}

.sf-cookie-btn-config:hover {
  background-color: var(--sf-c-forest-100);
  border-color: var(--sf-c-forest-500);
}

/* ─────────────────────────────────────────────────────────────
   2. MODAL DE CONFIGURACIÓN (SEGUNDA CAPA DETALLADA)
   ───────────────────────────────────────────────────────────── */
.sf-cookie-modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(4, 58, 27, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sf-cookie-modal-backdrop.sf-cookie-visible {
  opacity: 1;
  pointer-events: auto;
}

.sf-cookie-modal {
  background: var(--sf-c-cream-50);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  border-radius: var(--sf-c-radius-lg);
  box-shadow: 0 20px 48px rgba(4, 58, 27, 0.3);
  border: 1px solid rgba(15, 140, 67, 0.2);
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.96);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.sf-cookie-modal-backdrop.sf-cookie-visible .sf-cookie-modal {
  transform: translateY(0) scale(1);
}

.sf-cookie-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(15, 140, 67, 0.12);
  background-color: #ffffff;
}

.sf-cookie-modal-header h2 {
  font-family: var(--sf-c-font-serif);
  font-size: 1.35rem;
  color: var(--sf-c-forest-900);
  margin: 0;
  font-weight: 600;
}

.sf-cookie-close-btn {
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--sf-c-text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.2s;
}

.sf-cookie-close-btn:hover {
  background: var(--sf-c-forest-100);
  color: var(--sf-c-forest-900);
}

.sf-cookie-modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--sf-c-earth-800);
}

.sf-cookie-modal-body::-webkit-scrollbar {
  width: 6px;
}
.sf-cookie-modal-body::-webkit-scrollbar-thumb {
  background-color: rgba(15, 140, 67, 0.25);
  border-radius: 4px;
}

.sf-cookie-category-item {
  background: #ffffff;
  border: 1px solid rgba(15, 140, 67, 0.15);
  border-radius: var(--sf-c-radius-md);
  padding: 16px;
  margin-bottom: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.sf-cookie-category-item:last-child {
  margin-bottom: 0;
}

.sf-cookie-category-item:hover {
  border-color: var(--sf-c-forest-500);
}

.sf-cookie-cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.sf-cookie-cat-title {
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--sf-c-forest-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sf-cookie-badge {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: var(--sf-c-radius-full);
  background: var(--sf-c-forest-100);
  color: var(--sf-c-forest-800);
}

.sf-cookie-badge-optional {
  background: var(--sf-c-cream-100);
  color: var(--sf-c-earth-600);
}

.sf-cookie-cat-desc {
  font-size: 0.82rem;
  color: var(--sf-c-text-muted);
  margin: 0;
  line-height: 1.5;
}

/* Switch toggle */
.sf-cookie-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

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

.sf-cookie-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #cbd5e1;
  transition: .3s;
  border-radius: 24px;
}

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

.sf-cookie-switch input:checked + .sf-cookie-slider {
  background-color: var(--sf-c-forest-500);
}

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

.sf-cookie-switch input:disabled + .sf-cookie-slider {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: var(--sf-c-forest-700);
}

.sf-cookie-modal-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  background-color: #ffffff;
  border-top: 1px solid rgba(15, 140, 67, 0.12);
}

/* ─────────────────────────────────────────────────────────────
   3. BOTÓN FLOTANTE PERMANENTE / DISCRETO (REVOCACIÓN AEPD)
   ───────────────────────────────────────────────────────────── */
.sf-cookie-floating-btn {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 9990;
  background: var(--sf-c-forest-900);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--sf-c-radius-full);
  padding: 8px 14px;
  font-family: var(--sf-c-font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(4, 58, 27, 0.3);
  transition: all 0.25s ease;
  text-decoration: none;
}

.sf-cookie-floating-btn:hover {
  background: var(--sf-c-forest-700);
  color: var(--sf-c-citrus-500);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(4, 58, 27, 0.4);
}

/* Ocultar botón flotante cuando el banner está visible */
body.sf-cookie-banner-open .sf-cookie-floating-btn {
  display: none !important;
}

@media (max-width: 640px) {
  .sf-cookie-banner {
    bottom: 12px;
    left: 12px;
    width: calc(100% - 24px);
    padding: 18px;
  }
  .sf-cookie-floating-btn {
    bottom: 12px;
    left: 12px;
    padding: 6px 12px;
    font-size: 0.75rem;
  }
}
