/* ==========================================================================
   Jobs&Sea · Agente de la web pública
   Escritorio ancho (≥1280px): panel acoplado a la izquierda; la página se aparta y hace de
   Preview (html.site-agent-docked). Resto: escenario a pantalla completa sobre la página.
   La interfaz del chat y del Preview es la de admin-agent.css (.crm-agent); aquí van
   el escenario, los iconos fuera del CRM y los widgets propios (ficha, texto, confirmar).
   Marcado: partials/site-agent.ejs · Lógica: site-agent.js · Ojos: agent-eyes.js
   ========================================================================== */

.admin-icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.site-agent-stage .admin-icon { width: 1.05rem; height: 1.05rem; flex: none; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }

html.site-agent-open { overflow: hidden; }

.site-agent-stage {
  --ag-pad: clamp(0.6rem, 1.6vw, 1.5rem);
  position: fixed;
  z-index: 13000; /* por encima de la cabecera flotante y de los diálogos de la web */
  inset: 0;
  display: flex;
  padding: var(--ag-pad);
  background: rgba(8, 18, 34, 0.62);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  animation: site-agent-in 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.site-agent-stage[hidden] { display: none; }

@keyframes site-agent-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.site-agent-stage .crm-agent {
  width: min(100%, 1480px);
  height: 100%;
  min-height: 0;
  margin: 0 auto;
  font-family: Manrope, Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  text-align: left;
}

/* Con el Preview cerrado, el chat no ocupa todo el ancho: columna centrada como en Joe. */
.site-agent-stage .crm-agent[data-canvas="closed"] { grid-template-columns: minmax(0, 760px); justify-content: center; }

.site-agent-stage .crm-agent__canvas { background: var(--ag-surface-2); }
.site-agent-stage button { font-family: inherit; }

/* ---------- Widgets propios del Preview ---------- */
.crm-view__fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 0; }
.crm-view__field { padding: 12px 14px; border: 1px solid var(--ag-line); border-radius: 14px; background: var(--ag-surface); }
.crm-view__field dt { color: var(--ag-text-muted); font-size: 0.78rem; font-weight: 650; }
.crm-view__field dd { margin: 4px 0 0; color: var(--ag-text); font-size: 0.98rem; font-weight: 700; overflow-wrap: anywhere; }
.crm-view__text { margin: 0 0 0.7rem; color: var(--ag-text-2); font-size: 0.95rem; line-height: 1.65; overflow-wrap: anywhere; }
.crm-view__text:last-child { margin-bottom: 0; }
.crm-view__block--text { padding: 16px 18px; border: 1px solid var(--ag-line); border-radius: 18px; background: var(--ag-surface); }

/* ---------- Acción pendiente de confirmar ---------- */
.crm-pending .crm-proposal__icon { background: var(--ag-primary-soft); color: var(--ag-primary); }

@media (max-width: 900px) {
  .site-agent-stage { padding: 0; background: var(--ag-night, #0b182b); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .site-agent-stage .crm-agent { width: 100%; }
  .site-agent-stage .crm-agent__chat, .site-agent-stage .crm-agent__canvas { border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .site-agent-stage { animation: none; }
}

/* La web pública da borde y foco propios a los campos: dentro del Agente no aplican. */
.site-agent-stage .crm-agent__input textarea,
.site-agent-stage .crm-agent__input textarea:focus,
.site-agent-stage .crm-agent__input textarea:focus-visible { border: 0; border-radius: 0; outline: 0; background: transparent; box-shadow: none; }

.crm-pending__text { margin: 10px 0 0; color: var(--ag-text-2); font-size: 0.88rem; line-height: 1.5; }
.site-agent-stage .crm-proposal__cancel {
  padding: 9px 14px; border: 1px solid var(--ag-line-2); border-radius: 12px; background: var(--ag-surface); color: var(--ag-text-2);
  font-size: 0.9rem; font-weight: 700; cursor: pointer;
}
.site-agent-stage .crm-proposal__cancel:hover { background: var(--ag-surface-3); }
.site-agent-stage .crm-proposal__cancel:disabled { opacity: 0.55; cursor: default; }

.site-agent-stage .crm-msg__link { color: var(--ag-primary); font-weight: 700; text-decoration: underline; text-underline-offset: 0.18em; }

/* ---------- Emo en pequeño: la cara del Agente en la barra del hero y en la burbuja ---------- */
.site-agent-emo {
  display: inline-flex;
  width: 44px;
  height: 44px;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 14px;
  background: radial-gradient(120% 120% at 30% 20%, #18304d 0%, #0b182b 62%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 6px 16px rgba(11, 24, 43, 0.28);
}
.site-agent-emo i {
  width: 9px;
  height: 13px;
  border-radius: 4px;
  background: #4fd1d9;
  box-shadow: 0 0 10px rgba(79, 209, 217, 0.75);
  animation: site-agent-blink 5.2s infinite;
}
.site-agent-emo i:last-child { animation-delay: 0.04s; }
@keyframes site-agent-blink {
  0%, 44%, 48%, 100% { transform: scaleY(1); }
  46% { transform: scaleY(0.12); }
}

/* La barra del hero es la misma conversación: lleva la cara del Agente a la izquierda. */
.home-agent-bar:has(> .site-agent-emo) { grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.85rem; padding-left: 0.85rem; }
.home-agent-bar > .site-agent-emo { width: 38px; height: 38px; border-radius: 12px; gap: 4px; }
.home-agent-bar > .site-agent-emo i { width: 8px; height: 11px; }

/* Con el Agente abierto o la conversación en marcha, la barra del hero se retira (queda su hueco:
   el hero no salta). La conversación sigue en el panel y, cerrado, en la burbuja de la esquina.
   Con !important: en inicio, la secuencia del hero fija visibility y su animación de entrada, opacity. */
html.site-agent-engaged [data-site-agent-form] { visibility: hidden !important; opacity: 0 !important; pointer-events: none !important; }
[data-site-agent-form] { transition: opacity 180ms ease; }

/* Burbuja para volver al Agente (cuando hay conversación y el escenario está cerrado). */
.site-agent-launcher {
  position: fixed;
  z-index: 11500;
  right: clamp(14px, 2.4vw, 28px);
  bottom: clamp(14px, 2.4vw, 28px);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 18px 7px 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: linear-gradient(135deg, #0b182b, #163a61);
  box-shadow: 0 18px 40px -14px rgba(8, 18, 34, 0.7);
  color: #fff;
  font: 750 0.95rem/1 Manrope, Inter, system-ui, sans-serif;
  cursor: pointer;
  animation: site-agent-in 320ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.site-agent-launcher[hidden] { display: none; }
.site-agent-launcher:hover { background: linear-gradient(135deg, #10223b, #1c4877); }
.site-agent-launcher:focus-visible { outline: 3px solid #7fb2ea; outline-offset: 3px; }
.site-agent-launcher .site-agent-emo { width: 40px; height: 40px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12); }

@media (prefers-reduced-motion: reduce) {
  .site-agent-emo i, .site-agent-launcher { animation: none; }
}

/* ==========================================================================
   Panel acoplado: el Agente a la izquierda y la web, viva, a su lado.
   site-agent.js pone html.site-agent-docked al abrir en pantallas de 1280px o más.
   ========================================================================== */
:root { --agent-dock: clamp(372px, 27vw, 440px); }

html.site-agent-docked { overflow-x: clip; }
html.site-agent-docked body { margin-left: var(--agent-dock); }

html.site-agent-docked .site-agent-stage {
  inset: 0 auto 0 0;
  width: var(--agent-dock);
  padding: 0;
  background: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  animation: site-agent-dock-in 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
/* Página nueva con el panel ya abierto: aparece en su sitio, sin animación ni espera al script. */
html.site-agent-docked .site-agent-stage.is-restored { animation: none; }
html.site-agent-boot .site-agent-stage[hidden] { display: flex; animation: none; }
@keyframes site-agent-dock-in {
  from { opacity: 0; translate: -28px 0; }
  to { opacity: 1; translate: 0 0; }
}

html.site-agent-docked .site-agent-stage .crm-agent,
html.site-agent-docked .site-agent-stage .crm-agent[data-canvas="closed"],
html.site-agent-docked .site-agent-stage .crm-agent[data-canvas="open"] { width: 100%; grid-template-columns: minmax(0, 1fr); justify-content: stretch; }
html.site-agent-docked .site-agent-stage .crm-agent__split { display: none; }
/* Borde claro y sombra: el panel se distingue también sobre los heros oscuros (Tripulantes, Empresas). */
html.site-agent-docked .site-agent-stage .crm-agent__chat { border: 0; border-right: 1px solid rgba(150, 196, 240, 0.34); border-radius: 0; box-shadow: 1px 0 0 rgba(4, 12, 24, 0.55), 22px 0 54px -14px rgba(2, 8, 18, 0.72); }
html.site-agent-docked .site-agent-stage .crm-agent__head { min-height: 84px; gap: 12px; padding: 10px 14px; }
html.site-agent-docked .site-agent-stage .crm-agent__head,
html.site-agent-docked .site-agent-stage .crm-agent__console { padding-inline: 14px; }
html.site-agent-docked .site-agent-stage .crm-agent__conversation { padding-inline: 14px; }
html.site-agent-docked .site-agent-stage .crm-agent__menu { left: 14px; }
html.site-agent-docked .site-agent-stage .crm-msg { max-width: 96%; }
html.site-agent-docked .site-agent-stage .crm-agent__name { font-size: 17px; }
html.site-agent-docked .site-agent-stage .crm-agent__input textarea::placeholder { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Lo que no tiene sitio en la página (guías) se abre en un panel junto al chat, sobre la web. */
html.site-agent-docked .site-agent-stage .crm-agent[data-canvas="open"] .crm-agent__canvas {
  position: fixed;
  top: 12px;
  bottom: 12px;
  left: calc(var(--agent-dock) + 12px);
  width: min(640px, calc(100vw - var(--agent-dock) - 24px));
  border-radius: 22px;
  box-shadow: 0 30px 90px -18px rgba(8, 18, 34, 0.6), 0 0 0 1px rgba(8, 18, 34, 0.08);
  animation: site-agent-dock-in 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
html.site-agent-docked #canvasCloseBtn { display: inline-flex; }
html.site-agent-docked #canvasToggleBtn { display: none; }

/* La cabecera flotante de la web se centra en la zona de la página. */
html.site-agent-docked body .secondary-floating-header,
html.site-agent-docked body .home-floating-header.is-scroll-detached {
  left: calc(var(--agent-dock) + (100% - var(--agent-dock)) / 2);
  width: min(calc(100% - var(--agent-dock) - 3rem), 1520px);
}

/* Ventana del anuncio abierta junto al Agente: no es modal (el chat sigue vivo) y ocupa la zona de la página. */
.home-listing-dialog[open]:not(:modal) {
  position: fixed;
  z-index: 12500;
  inset: 0;
  height: fit-content;
  box-shadow: 0 0 0 200vmax rgba(6, 25, 43, 0.62), 0 32px 120px #061b3866;
}
html.site-agent-docked .home-listing-dialog[open]:not(:modal) { left: var(--agent-dock); width: min(1040px, calc(100% - var(--agent-dock) - 48px)); }

@media (prefers-reduced-motion: reduce) {
  html.site-agent-docked .site-agent-stage, html.site-agent-docked .site-agent-stage .crm-agent__canvas { animation: none; }
}

/* Elementos fijos de la web que se centran en la ventana: se centran en la zona de la página. */
html.site-agent-docked .story-dock,
html.site-agent-docked .candidate-favorites-status:not([hidden]) { left: calc(var(--agent-dock) + (100% - var(--agent-dock)) / 2); }

/* Con el panel abierto la página tiene menos ancho que la ventana: ajustes de lo que quedaría apretado. */
@media (max-width: 1700px) {
  html.site-agent-docked .guest-cv-value-grid { grid-template-columns: 1fr; }
}

/* En móvil la burbuja no pisa el dock de capítulos de la página. */
@media (max-width: 900px) {
  .home-story-body .site-agent-launcher { bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 68px); }
}

/* ---------- Adjuntos ---------- */
.site-agent-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 2px; }
.site-agent-chips[hidden] { display: none; }
.site-agent-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.site-agent-file {
  display: inline-flex; max-width: 100%; align-items: center; gap: 6px; padding: 5px 9px; border: 1px solid rgba(255, 255, 255, 0.22); border-radius: 999px;
  background: rgba(255, 255, 255, 0.1); color: inherit; font-size: 0.82rem; font-weight: 650; line-height: 1.2; overflow-wrap: anywhere;
}
.site-agent-file .admin-icon { width: 0.9rem; height: 0.9rem; }
.site-agent-chips .site-agent-file { border-color: rgba(127, 178, 234, 0.4); background: rgba(127, 178, 234, 0.14); color: #dbe9f8; }
.site-agent-file.is-loading { opacity: 0.7; font-style: italic; }
.site-agent-file__remove { display: inline-flex; padding: 2px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
.site-agent-file__remove:hover { background: rgba(255, 255, 255, 0.18); }
.site-agent-file__remove:focus-visible { outline: 2px solid #7fb2ea; outline-offset: 1px; }

/* ---------- La mano del Agente (señala elementos de la página; site-agent.js pointAt) ---------- */
.site-agent-hand {
  position: fixed; z-index: 14000; top: 0; left: 0; width: 54px; height: 54px; pointer-events: none; transform-origin: 21px 3px;
  transition: transform 760ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 320ms ease;
  filter: drop-shadow(0 8px 14px rgba(8, 18, 34, 0.45));
}
.site-agent-hand svg { display: block; width: 100%; height: 100%; overflow: visible; }
.site-agent-hand rect { fill: #ffffff; stroke: #0b182b; stroke-width: 2; }
.site-agent-hand .cuff { fill: #4fd1d9; }
.site-agent-hand .line { fill: none; stroke: #c3cfdd; stroke-width: 1.6; stroke-linecap: round; }
.site-agent-hand.is-tapping svg { animation: site-agent-tap 560ms ease-in-out infinite; }
@keyframes site-agent-tap { 0%, 100% { transform: translateY(7px); } 45% { transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .site-agent-hand { transition: opacity 200ms ease; } .site-agent-hand.is-tapping svg { animation: none; } }

/* ---------- Mini formularios del Agente en el Preview ---------- */
/* Acoplado, el formulario es una tarjeta compacta junto al chat, no un panel de arriba abajo. */
html.site-agent-docked .site-agent-stage .crm-agent[data-canvas="open"][data-canvas-kind="form"] .crm-agent__canvas {
  top: auto; bottom: 12px; width: min(430px, calc(100vw - var(--agent-dock) - 24px)); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
}
.site-agent-stage .crm-agent[data-canvas-kind="form"] .crm-agent__canvas-body { padding-bottom: 20px; }
.site-agent-form, .site-agent-form__body { display: grid; gap: 14px; }
.site-agent-form__intro { margin: 0; color: var(--ag-text-2); font-size: 0.95rem; line-height: 1.45; }
.site-agent-form__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.site-agent-form__field { grid-column: 1 / -1; display: grid; gap: 6px; min-width: 0; align-content: start; }
.site-agent-form__field.is-half { grid-column: span 1; }
.site-agent-form__field[hidden] { display: none; }
.site-agent-form__label { color: var(--ag-text-muted); font-size: 0.78rem; font-weight: 650; }
.site-agent-form__field.is-quiet .site-agent-form__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.site-agent-form input, .site-agent-form select {
  width: 100%; min-height: 46px; padding: 0 14px; border: 1px solid var(--ag-line-2); border-radius: 14px; background: var(--ag-surface); color: var(--ag-text);
  font: inherit; font-size: 1rem; transition: border-color 160ms ease, box-shadow 160ms ease;
}
.site-agent-form select { padding-right: 34px; text-overflow: ellipsis; }
.site-agent-form input[hidden] { display: none; }
.site-agent-form input:focus, .site-agent-form select:focus { outline: none; border-color: var(--ag-primary); box-shadow: var(--ag-ring); }
.site-agent-form__field.is-invalid input, .site-agent-form__field.is-invalid select { border-color: var(--ag-coral); }
.site-agent-form__error { color: #b3324c; font-size: 0.8rem; font-style: normal; }
.site-agent-form__private { display: flex; gap: 8px; align-items: center; margin: 0; color: var(--ag-text-muted); font-size: 0.8rem; line-height: 1.35; }
.site-agent-form__private .admin-icon { flex: none; width: 15px; height: 15px; }
.site-agent-form__status { margin: 0; color: #b3324c; font-size: 0.88rem; }
.site-agent-form__submit {
  justify-self: end; min-height: 46px; padding: 0 28px; border: 0; border-radius: 999px; background: var(--ag-primary-grad); color: #fff;
  font: inherit; font-weight: 700; cursor: pointer; transition: transform 160ms ease, filter 160ms ease;
}
.site-agent-form__submit:hover { filter: brightness(1.06); }
.site-agent-form__submit:active { transform: translateY(1px); }
.site-agent-form__submit:disabled { opacity: 0.6; cursor: progress; }
.site-agent-file--form .admin-icon { color: #8ff0c4; }

/* Fichas de un clic, texto libre y foto en los mini formularios. */
.site-agent-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.site-agent-chip, .site-agent-chips__more {
  min-height: 38px; padding: 0 14px; border: 1px solid var(--ag-line-2); border-radius: 999px; background: var(--ag-surface); color: var(--ag-text-2);
  font: inherit; font-size: 0.9rem; cursor: pointer; transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}
.site-agent-chip[hidden] { display: none; }
.site-agent-chip:hover { border-color: var(--ag-primary-300); }
.site-agent-chip[aria-pressed="true"] { border-color: var(--ag-primary); background: var(--ag-primary); color: #fff; font-weight: 650; }
.site-agent-chip:disabled { opacity: 0.45; cursor: default; }
.site-agent-chip:focus-visible, .site-agent-chips__more:focus-visible, .site-agent-form__pick:focus-visible, .site-agent-form__later:focus-visible { outline: none; box-shadow: var(--ag-ring); }
.site-agent-chips__more { border-style: dashed; color: var(--ag-primary); font-weight: 650; }
.site-agent-form__hint { color: var(--ag-text-muted); font-weight: 500; }
.site-agent-form__dates { display: grid; gap: 8px; }
.site-agent-form__dates[hidden] { display: none; }
.site-agent-form__date { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 10px; align-items: center; color: var(--ag-text-2); font-size: 0.86rem; }
.site-agent-form textarea { width: 100%; padding: 12px 14px; border: 1px solid var(--ag-line-2); border-radius: 14px; background: var(--ag-surface); color: var(--ag-text); font: inherit; font-size: 1rem; line-height: 1.4; resize: vertical; }
.site-agent-form textarea:focus { outline: none; border-color: var(--ag-primary); box-shadow: var(--ag-ring); }
.site-agent-form__pick { display: flex; gap: 14px; align-items: center; width: 100%; padding: 14px; border: 1px dashed var(--ag-line-2); border-radius: 16px; background: var(--ag-surface); color: var(--ag-text-2); font: inherit; text-align: left; cursor: pointer; }
.site-agent-form__photo { display: grid; flex: none; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--ag-primary-soft) center / cover no-repeat; color: var(--ag-primary); }
.site-agent-form__photo.has-photo .admin-icon { display: none; }
.site-agent-form__actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
.site-agent-form__later { min-height: 46px; padding: 0 18px; border: 0; border-radius: 999px; background: transparent; color: var(--ag-text-muted); font: inherit; font-weight: 650; cursor: pointer; }
html.site-agent-docked .site-agent-stage .crm-agent[data-canvas="open"][data-canvas-kind="form"] .crm-agent__canvas { width: min(480px, calc(100vw - var(--agent-dock) - 24px)); }
