/* Cookie consent banner — global (base.html) */

.cookie-consent {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 9999;
  width: calc(100% - 32px);
  max-width: 680px;
  transform: translateX(-50%) translateY(calc(100% + 28px));
  opacity: 0;
  animation: cookie-consent-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.35s forwards;
  pointer-events: auto;
  transition: max-width 0.32s ease, bottom 0.32s ease;
}

.cookie-consent--closing {
  animation: cookie-consent-out 0.28s ease forwards;
}

@keyframes cookie-consent-in {
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

@keyframes cookie-consent-out {
  to {
    transform: translateX(-50%) translateY(calc(100% + 20px));
    opacity: 0;
  }
}

.cookie-consent-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
  border-radius: 18px;
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02)),
    linear-gradient(165deg, rgba(30, 41, 59, 0.97), rgba(10, 14, 23, 0.98));
  border: 1px solid rgba(99, 102, 241, 0.32);
  box-shadow:
    0 22px 56px rgba(0, 0, 0, 0.48),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 0 48px rgba(99, 102, 241, 0.14);
  backdrop-filter: blur(18px);
  transition: box-shadow 0.28s ease;
}

.cookie-consent-head {
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.cookie-consent-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 6px 16px;
  border: none;
  background: rgba(255, 255, 255, 0.03);
  color: #94a3b8;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease;
}

.cookie-consent-toggle:hover {
  background: rgba(99, 102, 241, 0.12);
  color: #c7d2fe;
}

.cookie-consent-head-chip {
  display: none;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.16);
  border: 1px solid rgba(99, 102, 241, 0.28);
  color: #c7d2fe;
  flex-shrink: 0;
}

.cookie-consent-head-chip svg {
  display: block;
  width: 15px;
  height: 15px;
}

.cookie-consent-head-label {
  display: none;
  flex: 1;
  min-width: 0;
  font-size: 0.84rem;
  font-weight: 700;
  color: #e2e8f0;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cookie-consent-toggle-icon {
  display: block;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  transition: transform 0.25s ease;
}

.cookie-consent--collapsed .cookie-consent-toggle-icon {
  transform: rotate(180deg);
}

.cookie-consent-main {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px 18px;
  overflow: hidden;
  max-height: 260px;
  opacity: 1;
  transition: max-height 0.32s ease, opacity 0.22s ease, padding 0.32s ease;
}

.cookie-consent--collapsed {
  max-width: min(340px, calc(100% - 32px));
  bottom: 14px;
}

.cookie-consent--collapsed .cookie-consent-panel {
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 0 28px rgba(99, 102, 241, 0.1);
}

.cookie-consent--collapsed .cookie-consent-head {
  border-bottom: none;
}

.cookie-consent--collapsed .cookie-consent-toggle {
  justify-content: flex-start;
  min-height: 44px;
  padding: 8px 14px 8px 10px;
  background: transparent;
}

.cookie-consent--collapsed .cookie-consent-toggle:hover {
  background: rgba(99, 102, 241, 0.1);
}

.cookie-consent--collapsed .cookie-consent-head-chip,
.cookie-consent--collapsed .cookie-consent-head-label {
  display: flex;
}

.cookie-consent--collapsed .cookie-consent-main {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  pointer-events: none;
}

.cookie-consent-icon {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(99, 102, 241, 0.16);
  border: 1px solid rgba(99, 102, 241, 0.34);
  color: #c7d2fe;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.cookie-consent-icon svg {
  display: block;
  width: 24px;
  height: 24px;
}

.cookie-consent-body {
  flex: 1 1 220px;
  min-width: 0;
}

.cookie-consent-title {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #f8fafc;
}

.cookie-consent-text {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--text-soft);
}

.cookie-consent-legal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin-top: 10px;
}

.cookie-consent-legal-sep {
  color: rgba(148, 163, 184, 0.4);
  font-size: 0.72rem;
  line-height: 1;
  user-select: none;
}

.cookie-consent-actions {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  min-width: 120px;
}

.cookie-consent-btn {
  padding: 10px 18px;
  border: none;
  border-radius: 11px;
  font-size: 0.86rem;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  box-shadow: 0 6px 20px var(--primary-glow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.cookie-consent-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px var(--primary-glow);
}

.cookie-consent-btn:active {
  transform: translateY(0);
}

.cookie-consent-link {
  position: relative;
  z-index: 1;
  font-size: 0.78rem;
  font-weight: 600;
  color: #93c5fd;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s ease;
}

.cookie-consent-legal .cookie-consent-link {
  text-align: left;
}

.cookie-consent-link:hover {
  color: #bfdbfe;
  text-decoration: underline;
}

@media (max-width: 880px) {
  .cookie-consent {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: none !important;
    transform: none !important;
    animation: none !important;
    opacity: 1 !important;
    transition: none !important;
  }

  .cookie-consent--collapsed {
    bottom: 0;
    max-width: 100% !important;
  }

  .cookie-consent-panel {
    border-radius: 14px 14px 0 0;
    border-bottom: none;
    border-left: none;
    border-right: none;
    backdrop-filter: none;
    background: #111827;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.55);
    transition: none;
  }

  .cookie-consent--collapsed .cookie-consent-panel {
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.45);
  }

  .cookie-consent-head {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }

  .cookie-consent-toggle {
    min-height: 44px;
    padding: 10px 14px;
    transition: background 0.15s ease, color 0.15s ease;
  }

  .cookie-consent-toggle-icon {
    transition: transform 0.25s ease;
  }

  .cookie-consent-main {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto;
    align-items: start;
    gap: 8px 12px;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    max-height: min(48vh, 280px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transition: max-height 0.2s ease, opacity 0.15s ease, padding 0.2s ease;
  }

  .cookie-consent-icon {
    display: none;
  }

  .cookie-consent-body {
    display: contents;
  }

  .cookie-consent-title {
    grid-column: 1 / -1;
    font-size: 0.9rem;
    margin: 0;
  }

  .cookie-consent-text {
    grid-column: 1;
    margin: 0;
    font-size: 0.76rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .cookie-consent-legal {
    grid-column: 1 / -1;
    margin: 0;
    gap: 4px 10px;
  }

  .cookie-consent-link {
    font-size: 0.7rem;
  }

  .cookie-consent-actions {
    grid-column: 2;
    grid-row: 2;
    width: auto;
    min-width: 0;
    align-self: end;
  }

  .cookie-consent-btn {
    width: auto;
    min-width: 108px;
    padding: 10px 16px;
    font-size: 0.8rem;
    box-shadow: none;
    transition: none;
  }

  .cookie-consent-btn:hover {
    transform: none;
    box-shadow: none;
  }

  .cookie-consent--collapsed .cookie-consent-main {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
  }

  /* Compert IA: ocultar cookies mientras se escribe (teclado móvil) */
  body.keyboard-open .cookie-consent,
  body.ia-composer-focused .cookie-consent {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(100%) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cookie-consent {
    animation: none;
    transform: translateX(-50%);
    opacity: 1;
  }

  .cookie-consent--closing {
    animation: none;
    opacity: 0;
  }
}
