/* ============================================================
   CEAON · Organic IA — UX estilo Claude mobile (fondo claro)
   Saludo serif centrado + input inferior + blur reveal.
   ============================================================ */

:root {
  --ia-bg:        #f7f5ef;   /* cream claro tipo Claude light */
  --ia-surface:   #ffffff;
  --ia-ink:       #1f1d1a;   /* texto principal */
  --ia-ink-soft:  #4a4742;
  --ia-muted:     #8c877d;
  --ia-line:      #e6e2d8;
  --ia-line-soft: #efece3;
  --ia-accent:    #c96442;   /* clay/coral (chispa IA) */
  --ia-user-bg:   #ece9df;   /* burbuja del usuario */
  --ia-serif: 'Newsreader', 'Lora', Georgia, 'Times New Roman', serif;
  --ia-sans:  'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Todo dentro de la vista IA usa border-box (evita desbordes a la derecha) */
#view-ia, #view-ia *, #view-ia *::before, #view-ia *::after { box-sizing: border-box; }

/* La vista ocupa toda la pantalla, por encima del mapa */
#view-ia {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  background: var(--ia-bg);
  color: var(--ia-ink);
  font-family: var(--ia-sans);
  padding-top: env(safe-area-inset-top, 0px);
  /* El safe-area inferior lo maneja SOLO el composer (evita el hueco doble en la PWA) */
  padding-bottom: 0;
  overflow: hidden;
}
body.ia-body { background: var(--ia-bg); }

/* ---------- Top bar ---------- */
.ia-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 6px;
}
.ia-top__btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--ia-line);
  border-radius: 50%;
  background: transparent;
  color: var(--ia-ink-soft);
  cursor: pointer;
  transition: background .2s, transform .12s;
}
.ia-top__btn:active { transform: scale(.92); }
.ia-top__btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Cuerpo / thread ---------- */
.ia-body-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

/* Hero centrado (estado inicial, tipo "Bienvenido Oscar") */
.ia-hero {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  gap: 18px;
}
.ia--chatting .ia-hero { display: none; }

/* Lockup de marca: O + IA */
.ia-hero__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  animation: iaPop .7s cubic-bezier(.16,1,.3,1) both;
}
.ia-hero__logo {
  width: 54px; height: 54px;
  object-fit: contain;
  opacity: .95;
}
.ia-hero__ia {
  font-family: var(--ia-serif);
  font-weight: 500;
  font-size: 2.4rem;
  line-height: 1;
  letter-spacing: .01em;
  color: var(--ia-ink);
  position: relative;
  top: 1px;
}
.ia-hero__title {
  font-family: var(--ia-serif);
  font-weight: 400;
  font-size: clamp(1.5rem, 6.4vw, 2rem);
  letter-spacing: -.01em;
  color: var(--ia-ink);
  margin: 0;
  animation: iaRise .7s .08s cubic-bezier(.16,1,.3,1) both;
}
@keyframes iaPop  { from { opacity:0; transform: scale(.8) } to { opacity:.92; transform:none } }
@keyframes iaRise { from { opacity:0; transform: translateY(10px) } to { opacity:1; transform:none } }

/* Thread de mensajes (cuando ya se está chateando) */
.ia-thread {
  display: none;
  flex-direction: column;
  gap: 22px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 18px 26px;
}
.ia--chatting .ia-thread { display: flex; }

/* Mensaje del usuario: burbuja a la derecha */
.ia-msg { display: flex; animation: iaMsgIn .35s cubic-bezier(.16,1,.3,1); }
@keyframes iaMsgIn { from { opacity:0; transform: translateY(8px) } to { opacity:1; transform:none } }
.ia-msg--user { justify-content: flex-end; }
.ia-msg--user .ia-bubble {
  background: var(--ia-user-bg);
  color: var(--ia-ink);
  padding: 11px 16px;
  border-radius: 20px;
  border-bottom-right-radius: 6px;
  font-size: 1rem;
  line-height: 1.45;
  max-width: 82%;
}

/* Mensaje del bot: chispa + texto a todo el ancho (sin burbuja) */
.ia-msg--bot { gap: 12px; align-items: flex-start; }
.ia-ava {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
}
.ia-ava svg { width: 22px; height: 22px; fill: var(--ia-accent); }
.ia-ava__o { width: 24px; height: 24px; object-fit: contain; display: block; }
.ia-bot-body {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 1.02rem;
  line-height: 1.62;
  color: var(--ia-ink);
}
.ia-p { margin: 0 0 12px; }
.ia-p:last-child { margin-bottom: 0; }

/* Revelado palabra por palabra con blur */
.ia-word {
  display: inline-block;
  animation: iaWord .5s cubic-bezier(.16,1,.3,1) both;
}
@keyframes iaWord {
  from { opacity: 0; filter: blur(7px); transform: translateY(3px); }
  to   { opacity: 1; filter: blur(0);   transform: none; }
}

/* Indicador "escribiendo" */
.ia-typing { display: inline-flex; gap: 5px; align-items: center; padding: 6px 0; }
.ia-typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ia-muted);
  animation: iaDot 1.2s ease-in-out infinite;
}
.ia-typing i:nth-child(2) { animation-delay: .15s; }
.ia-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes iaDot { 0%,60%,100% { transform: translateY(0); opacity:.35 } 30% { transform: translateY(-5px); opacity:1 } }

/* Generación de imagen + imagen */
.ia-imggen { margin-top: 12px; }
.ia-imggen__shimmer {
  display: flex; align-items: center; gap: 10px;
  height: 220px;
  border-radius: 18px;
  border: 1px solid var(--ia-line);
  background:
    linear-gradient(100deg, transparent 20%, rgba(201,100,66,.08) 40%, transparent 60%) ,
    var(--ia-line-soft);
  background-size: 220% 100%, auto;
  animation: iaShimmer 1.4s linear infinite;
  justify-content: center;
  color: var(--ia-muted);
  font-size: .92rem;
}
@keyframes iaShimmer { from { background-position: 120% 0, 0 0 } to { background-position: -120% 0, 0 0 } }
.ia-imggen__spark svg { width: 20px; height: 20px; fill: var(--ia-accent); animation: iaSpin 1.6s linear infinite; }
@keyframes iaSpin { to { transform: rotate(360deg) } }
.ia-img {
  display: block;
  width: 100%;
  border-radius: 18px;
  border: 1px solid var(--ia-line);
  opacity: 0;
  transform: scale(.98);
  transition: opacity .6s ease, transform .6s cubic-bezier(.16,1,.3,1);
}
.ia-img.is-in { opacity: 1; transform: none; }

/* ---------- Composer (input inferior estilo Claude) ---------- */
.ia-composer {
  flex: 0 0 auto;
  padding: 8px 14px;
  /* Mismo patrón probado del bottom-nav: pega el input al borde sin dejar hueco en iOS */
  padding-bottom: max(8px, calc(env(safe-area-inset-bottom, 0px) - 14px));
}
.ia-inputwrap {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  background: var(--ia-surface);
  border: 1px solid var(--ia-line);
  border-radius: 28px;
  padding: 16px 14px 12px;
  box-shadow: 0 2px 10px rgba(31,29,26,.05);
  transition: border-color .2s, box-shadow .2s;
  cursor: text;
}
.ia-inputwrap:focus-within {
  border-color: rgba(201,100,66,.5);
  box-shadow: 0 2px 14px rgba(201,100,66,.1);
}
.ia-textarea {
  width: 100%;
  border: none; outline: none; resize: none;
  background: transparent;
  color: var(--ia-ink);
  font-family: var(--ia-sans);
  font-size: 1.05rem;
  line-height: 1.5;
  min-height: 30px;
  max-height: 132px;
  padding: 4px 6px;
  cursor: text;
  pointer-events: none;   /* el tap lo captura el formulario (autotipeo) */
}
.ia-textarea::placeholder { color: var(--ia-muted); }

.ia-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.ia-tool {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--ia-line);
  border-radius: 50%;
  background: transparent;
  color: var(--ia-ink-soft);
  cursor: pointer;
}
.ia-tool svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ia-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--ia-line);
  border-radius: 999px;
  background: transparent;
  color: var(--ia-ink-soft);
  font-size: .85rem;
  font-weight: 500;
}
.ia-pill .ia-pill__spark svg { width: 14px; height: 14px; fill: var(--ia-accent); }
.ia-spacer { flex: 1 1 auto; }

.ia-send {
  width: 38px; height: 38px;
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--ia-ink);
  color: #fff;
  cursor: pointer;
  transition: background .2s, transform .12s, opacity .2s;
}
.ia-send svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ia-send:active { transform: scale(.9); }
.ia-send:disabled { opacity: .35; cursor: default; }

/* ---------- Botón de nav (chispa IA) en el bottom-nav del mapa ---------- */
.bottom-nav__item--ia svg { fill: currentColor !important; stroke: none !important; }
