/* =============================================================
   Koi · Netbulb
   Estilos del banner de cookies y del asistente de IA (Koi)
   Paleta coherente con el resto de la experiencia Koi
   ============================================================= */

:root {
  --koi-accent: #0071e3;
  --koi-accent-2: #0077ed;
  --koi-ink: #1d1d1f;
  --koi-ink-soft: #86868b;
  --koi-line: rgba(210, 210, 215, 0.7);
  --koi-paper: #f5f5f7;
  --koi-bg: #fbfbfd;
  --koi-white: #ffffff;
  --koi-font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --koi-display: 'Fredoka', 'Plus Jakarta Sans', system-ui, sans-serif;
}

/* -------------------------------------------------------------
   Banner de cookies
   ------------------------------------------------------------- */
.koi-cookie {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 99990;
  background: var(--koi-white);
  border: 1px solid var(--koi-line);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
  padding: 22px;
  max-width: 680px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  margin-inline: auto;
  display: none;
  color: var(--koi-ink);
  font-family: var(--koi-font);
  font-size: 14px;
  line-height: 1.55;
}
.koi-cookie.is-visible {
  display: grid;
  gap: 16px;
  animation: koi-cookie-in 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes koi-cookie-in {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

.koi-cookie__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.koi-cookie__head h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-family: var(--koi-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--koi-ink);
}
.koi-cookie__head h2::before {
  content: "";
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  background-color: var(--koi-accent);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M12 2a10 10 0 1 0 10 10 4 4 0 0 1-5-5 4 4 0 0 1-5-5'/><circle cx='8.5' cy='8.5' r='1' fill='white' stroke='none'/><circle cx='15.5' cy='15.5' r='1' fill='white' stroke='none'/><circle cx='15' cy='9' r='1' fill='white' stroke='none'/></svg>");
  background-position: center;
  background-size: 16px 16px;
  background-repeat: no-repeat;
}
.koi-cookie__close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--koi-line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--koi-ink-soft);
  cursor: pointer;
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1;
  background: transparent;
  transition: all 0.25s ease;
}
.koi-cookie__close:hover { background: var(--koi-paper); color: var(--koi-ink); }
.koi-cookie p { margin: 0; color: var(--koi-ink-soft); }
.koi-cookie p a { color: var(--koi-accent); text-decoration: underline; }

.koi-cookie__cats { display: grid; gap: 8px; }
.koi-cookie__cat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--koi-line);
  border-radius: 14px;
  background: var(--koi-paper);
}
.koi-cookie__cat-info { display: grid; gap: 2px; flex: 1; }
.koi-cookie__cat-info strong { font-size: 13px; color: var(--koi-ink); }
.koi-cookie__cat-info small { font-size: 11px; color: var(--koi-ink-soft); }

.koi-cookie__switch {
  position: relative;
  width: 42px;
  height: 24px;
  background: rgba(0, 0, 0, 0.16);
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.25s ease;
}
.koi-cookie__switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--koi-white);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.25s ease;
}
.koi-cookie__switch[data-checked="true"] { background: var(--koi-accent); }
.koi-cookie__switch[data-checked="true"]::after { transform: translateX(18px); }
.koi-cookie__switch[data-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.koi-cookie__switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: inherit; }

.koi-cookie__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.koi-cookie__btn {
  flex: 1;
  min-width: 150px;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 11px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.koi-cookie__btn--ghost { background: transparent; color: var(--koi-ink); border-color: rgba(210, 210, 215, 0.9); }
.koi-cookie__btn--ghost:hover { background: var(--koi-paper); }
.koi-cookie__btn--primary { background: var(--koi-accent); color: #fff; }
.koi-cookie__btn--primary:hover { background: var(--koi-accent-2); }
.koi-cookie__btn:focus-visible { outline: 3px solid rgba(0, 113, 227, 0.35); outline-offset: 2px; }

.koi-cookie__fab {
  position: fixed;
  left: 16px;
  bottom: 16px;
  width: 44px;
  height: 44px;
  background: var(--koi-white);
  border: 1px solid var(--koi-line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 99989;
  color: var(--koi-ink-soft);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  transition: all 0.25s ease;
}
.koi-cookie__fab:hover { background: var(--koi-paper); color: var(--koi-ink); transform: scale(1.05); }
.koi-cookie__fab svg { width: 22px; height: 22px; }
.koi-cookie__fab[hidden] { display: none; }

@media (max-width: 700px) {
  .koi-cookie { left: 12px; right: 12px; bottom: 12px; padding: 18px; }
  .koi-cookie__actions { flex-direction: column; }
  .koi-cookie__btn { width: 100%; }
}

/* -------------------------------------------------------------
   Logo de Netbulb en la cabecera
   ------------------------------------------------------------- */
.koi-logo {
  display: block;
  width: auto;
  height: 26px;
}

/* -------------------------------------------------------------
   Pie legal
   ------------------------------------------------------------- */
.koi-legal {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid rgba(210, 210, 215, 0.6);
  font-size: 12px;
  color: var(--koi-ink-soft);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 8px;
  text-align: center;
}
.koi-legal__link {
  color: var(--koi-ink-soft);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s ease;
}
.koi-legal__link:hover { color: var(--koi-accent); }

/* -------------------------------------------------------------
   Tarjeta "Pregunta a Koi"
   ------------------------------------------------------------- */
.koi-ask-card {
  max-width: 48rem;
  margin: 0 auto 40px;
  background: #fff;
  border: 1px solid rgba(210, 210, 215, 0.7);
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.04);
  font-family: var(--koi-font);
}
.koi-ask-card__eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--koi-accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}
.koi-ask-card__eyebrow svg { width: 16px; height: 16px; }
.koi-ask-card__title {
  margin: 0;
  font-family: var(--koi-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--koi-ink);
}
.koi-ask-card__text {
  margin: 10px 0 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--koi-ink-soft);
}
.koi-ask-card__actions {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.koi-ask-card__btn {
  display: inline-flex;
  align-items: center;
  padding: 11px 22px;
  border-radius: 999px;
  background: var(--koi-accent);
  color: #fff;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  transition: background 0.2s ease, transform 0.15s ease;
}
.koi-ask-card__btn:hover { background: var(--koi-accent-2); }
.koi-ask-card__btn:active { transform: scale(0.97); }
.koi-ask-card__link {
  display: inline-flex;
  align-items: center;
  padding: 11px 22px;
  border-radius: 999px;
  background: var(--koi-paper);
  color: var(--koi-ink);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.15s ease;
}
.koi-ask-card__link:hover { background: #e8e8ed; }
.koi-ask-card__link:active { transform: scale(0.97); }

@media (max-width: 640px) {
  .koi-ask-card { padding: 22px; border-radius: 20px; }
  .koi-ask-card__title { font-size: 1.1rem; }
  .koi-ask-card__text { font-size: 14px; }
}

/* -------------------------------------------------------------
   Asistente de IA (Koi)
   ------------------------------------------------------------- */
.koi-chat {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99980;
  font-family: var(--koi-font);
}
.koi-chat__btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--koi-accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 32px rgba(0, 113, 227, 0.4), 0 2px 8px rgba(0, 0, 0, 0.12);
  transition: transform 0.25s ease, background 0.25s ease;
  position: relative;
  animation: koi-chat-pulse 2.4s ease-in-out infinite;
}
.koi-chat__btn:hover { background: var(--koi-accent-2); transform: scale(1.06); }
.koi-chat__btn:focus-visible { outline: 3px solid rgba(0, 113, 227, 0.35); outline-offset: 4px; }
@keyframes koi-chat-pulse {
  0%, 100% { box-shadow: 0 12px 32px rgba(0, 113, 227, 0.4), 0 2px 8px rgba(0, 0, 0, 0.12), 0 0 0 0 rgba(0, 113, 227, 0.45); }
  50% { box-shadow: 0 12px 32px rgba(0, 113, 227, 0.4), 0 2px 8px rgba(0, 0, 0, 0.12), 0 0 0 14px rgba(0, 113, 227, 0); }
}
.koi-chat__icon { width: 26px; height: 26px; }
.koi-chat__icon--close { display: none; }
.koi-chat__btn.is-open .koi-chat__icon--chat { display: none; }
.koi-chat__btn.is-open .koi-chat__icon--close { display: block; }
.koi-chat__btn.is-open { animation: none; }

.koi-chat__panel {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: min(390px, calc(100vw - 32px));
  height: 560px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border: 1px solid var(--koi-line);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22), 0 4px 12px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: koi-chat-pop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.koi-chat__panel[hidden] { display: none; }
@keyframes koi-chat-pop {
  from { opacity: 0; transform: translateY(12px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.koi-chat__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #0071e3 0%, #0a3f7a 100%);
  color: #fff;
}
.koi-chat__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  overflow: hidden;
  flex-shrink: 0;
}
.koi-chat__avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.koi-chat__title {
  margin: 0;
  font-family: var(--koi-display);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 8px;
}
.koi-chat__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.25);
  display: inline-block;
  flex-shrink: 0;
}
.koi-chat__status { margin: 3px 0 0; font-size: 0.78rem; opacity: 0.85; }
.koi-chat__close {
  margin-left: auto;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
  transition: background 0.2s ease;
}
.koi-chat__close:hover { background: rgba(255, 255, 255, 0.15); opacity: 1; }

.koi-chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--koi-paper);
  scrollbar-width: thin;
}
.koi-chat__messages::-webkit-scrollbar { width: 6px; }
.koi-chat__messages::-webkit-scrollbar-thumb { background: rgba(0, 113, 227, 0.2); border-radius: 3px; }

.koi-chat__msg {
  max-width: 86%;
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  word-break: break-word;
  animation: koi-msg-in 0.25s ease;
}
@keyframes koi-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.koi-chat__msg--user {
  align-self: flex-end;
  background: var(--koi-accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.koi-chat__msg--bot {
  align-self: flex-start;
  background: #fff;
  color: var(--koi-ink);
  border: 1px solid var(--koi-line);
  border-bottom-left-radius: 4px;
}
.koi-chat__msg--bot p { margin: 0 0 8px; }
.koi-chat__msg--bot p:last-child { margin-bottom: 0; }
.koi-chat__msg--bot strong { font-weight: 700; }
.koi-chat__msg--bot a { color: var(--koi-accent); text-decoration: underline; overflow-wrap: anywhere; }
.koi-chat__msg--bot ul,
.koi-chat__msg--bot ol { margin: 4px 0 10px; padding-left: 20px; display: grid; gap: 6px; }
.koi-chat__msg--bot ul { list-style: disc; }
.koi-chat__msg--bot ol { list-style: decimal; }
.koi-chat__msg--bot li > p { margin: 0; }

.koi-chat__source {
  display: block;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--koi-line);
  font-size: 0.8rem;
}
.koi-chat__source strong { display: block; color: var(--koi-ink); font-weight: 600; margin-bottom: 3px; }
.koi-chat__source a {
  color: var(--koi-accent);
  font-weight: 600;
  text-decoration: none;
  word-break: break-all;
}
.koi-chat__source a:hover { text-decoration: underline; }

.koi-chat__typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 14px 16px;
}
.koi-chat__typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--koi-accent);
  opacity: 0.4;
  animation: koi-typing 1.2s infinite;
}
.koi-chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.koi-chat__typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes koi-typing {
  0%, 60%, 100% { opacity: 0.4; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

.koi-chat__suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 18px 12px;
  background: var(--koi-paper);
}
.koi-chat__suggest button {
  background: #fff;
  border: 1px solid var(--koi-line);
  color: var(--koi-accent);
  font-family: inherit;
  font-size: 0.82rem;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}
.koi-chat__suggest button:hover { background: var(--koi-accent); color: #fff; border-color: var(--koi-accent); }

.koi-chat__form {
  display: flex;
  gap: 6px;
  padding: 12px 14px;
  border-top: 1px solid var(--koi-line);
  background: #fff;
  align-items: center;
}
.koi-chat__input {
  flex: 1;
  border: 1px solid var(--koi-line);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
  background: var(--koi-paper);
  transition: border-color 0.2s ease, background 0.2s ease;
}
.koi-chat__input:focus { border-color: var(--koi-accent); background: #fff; }
.koi-chat__send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--koi-accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s ease, transform 0.2s ease;
}
.koi-chat__send:hover { background: var(--koi-accent-2); transform: scale(1.06); }
.koi-chat__send:disabled { background: #cbd5e1; cursor: not-allowed; transform: none; }
.koi-chat__send svg { width: 18px; height: 18px; }

.koi-chat__powered {
  text-align: center;
  font-size: 0.75rem;
  color: #94a3b8;
  padding: 9px 10px;
  background: #fff;
  border-top: 1px solid rgba(210, 210, 215, 0.5);
}
.koi-chat__powered strong { color: var(--koi-accent); font-weight: 700; }

@media (max-width: 480px) {
  .koi-chat { bottom: 16px; right: 16px; left: auto; }
  .koi-chat__btn { width: 54px; height: 54px; }
  .koi-chat__panel {
    position: fixed;
    bottom: 80px;
    right: 0;
    left: 0;
    width: auto;
    height: calc(100vh - 110px);
    max-height: none;
    border-radius: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .koi-chat__btn,
  .koi-chat__panel,
  .koi-chat__msg,
  .koi-cookie { animation: none !important; }
}
