/* Mi Estancia 1.1.0 · Asistente Jara: botón flotante + ventana flotante que no tapa la pantalla. */
body.has-ja #app { padding-bottom: 88px; } /* el último botón de cada pantalla queda por encima del botón de Jara */

.ja { position: fixed; z-index: 90; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); font-family: var(--font-ui); }
.ja--hidden { display: none; }

/* Botón: foto de Jara + icono de chat */
.ja-launch {
  position: relative; display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 4px; min-height: 60px;
  border: 0; border-radius: var(--radius-pill); background: var(--color-brand); color: var(--color-on-brand);
  box-shadow: 0 8px 24px rgba(31, 42, 36, .28); cursor: pointer;
}
.ja-launch img { width: 52px; height: 52px; border-radius: 50%; background: #fff; object-fit: cover; display: block; }
.ja-launch__dot { position: absolute; left: 42px; bottom: 6px; width: 12px; height: 12px; border-radius: 50%; background: #45c46b; border: 2px solid var(--color-brand); }
.ja-launch__ic { width: 40px; height: 40px; border-radius: 50%; background: rgba(255, 255, 255, .16); display: grid; place-items: center; }
.ja-launch__ic svg { width: 21px; height: 21px; }
.ja-badge { position: absolute; top: -5px; right: -5px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--color-danger); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.ja-launch:focus-visible, .ja-chip:focus-visible, .ja-x:focus-visible, .ja-send:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 2px; }

/* Ventana flotante: deja ver y usar la página por encima */
.ja--open { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
.ja-panel {
  width: min(400px, calc(100vw - 24px)); height: min(560px, 62vh); height: min(560px, 62dvh);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--color-surface); border-radius: 18px; box-shadow: 0 16px 44px rgba(31, 42, 36, .30); border: 1px solid var(--color-border);
}
.ja-panel--in { animation: ja-in .18s ease-out; }
@keyframes ja-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.ja-head { display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 12px; background: var(--color-brand); color: var(--color-on-brand); }
.ja-head img { width: 38px; height: 38px; border-radius: 50%; background: #fff; object-fit: cover; border: 2px solid rgba(255, 255, 255, .7); flex: 0 0 auto; }
.ja-head div { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.ja-head strong { font-size: 16px; }
.ja-head small { font-size: 12px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
.ja-on { width: 8px; height: 8px; border-radius: 50%; background: #45c46b; flex: 0 0 auto; }
.ja-x { width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: inherit; display: grid; place-items: center; cursor: pointer; }
.ja-x svg { width: 20px; height: 20px; }

.ja-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 10px; display: flex; flex-direction: column; gap: 8px; background: var(--color-surface-muted); }
.ja-row { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; max-width: 92%; }
.ja-row--me { align-self: flex-end; align-items: flex-end; }
.ja-who { font-size: 11.5px; color: var(--color-muted); padding: 0 4px; }
.ja-who--team { color: var(--color-accent); font-weight: 600; }
.ja-bubble { background: var(--color-brand-soft); color: var(--color-text); border-radius: 14px 14px 14px 4px; padding: 8px 11px; font-size: 14px; line-height: 1.45; }
.ja-bubble p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.ja-bubble time { display: block; font-size: 10.5px; color: var(--color-muted); margin-top: 2px; text-align: right; }
.ja-row--me .ja-bubble { background: var(--color-brand); color: var(--color-on-brand); border-radius: 14px 14px 4px 14px; }
.ja-row--me .ja-bubble time { color: rgba(255, 255, 255, .75); }
.ja-typing { display: flex; gap: 4px; padding: 12px 14px; }
.ja-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--color-muted); animation: ja-dot 1.2s infinite; }
.ja-typing span:nth-child(2) { animation-delay: .2s; } .ja-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ja-dot { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

.ja-go { display: flex; flex-wrap: wrap; gap: 6px; }
.ja-sug { display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px 2px; border-top: 1px solid var(--color-border); scrollbar-width: none; }
.ja-sug::-webkit-scrollbar { display: none; }
.ja-chip {
  flex: 0 0 auto; border: 1px solid var(--color-border-strong); background: var(--color-surface); color: var(--color-text);
  border-radius: var(--radius-pill); padding: 7px 12px; font: inherit; font-size: 13px; line-height: 1.2; cursor: pointer; white-space: nowrap; min-height: 34px;
}
.ja-chip--go { text-decoration: none; background: var(--color-brand); color: var(--color-on-brand); border-color: var(--color-brand); font-weight: 600; }
.ja-chip--human { color: var(--color-accent); border-color: currentColor; }

.ja-compose { display: flex; align-items: flex-end; gap: 6px; padding: 8px; }
.ja-compose textarea {
  flex: 1; resize: none; min-height: 42px; max-height: 110px; border: 1.5px solid var(--color-border-strong); border-radius: 21px;
  padding: 10px 14px; font: inherit; font-size: 16px; /* 16 px: el iPhone no hace zoom */ line-height: 1.3; background: #fff; color: var(--color-text); outline: none;
}
.ja-cam { width: 42px; height: 42px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center; color: var(--color-brand); background: var(--color-brand-soft); cursor: pointer; }
.ja-cam svg { width: 21px; height: 21px; }
.ja-cam:focus-within { outline: 3px solid var(--color-focus); outline-offset: 2px; }
.ja-photos { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.ja-photos img { width: 120px; max-width: 100%; height: 120px; object-fit: cover; border-radius: 10px; display: block; background: rgba(0,0,0,.06); }
.ja-compose textarea:focus { border-color: var(--color-brand); }
.ja-compose textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ja-send { width: 42px; height: 42px; flex: 0 0 auto; border: 0; border-radius: 50%; background: var(--color-brand); color: var(--color-on-brand); display: grid; place-items: center; cursor: pointer; }
.ja-send:disabled { opacity: .45; }
.ja-send svg { width: 20px; height: 20px; }

@media (max-width: 700px) {
  .ja-panel { height: min(500px, 55vh); height: min(500px, 55dvh); }
}
@media (prefers-reduced-motion: reduce) { .ja-panel, .ja-typing span { animation: none; } }
