/* CESaEV · Asistente comercial — presentación pública v1.0.1
 * La lógica conversacional, los tickets y OpenAI no se modifican aquí.
 * Sin bibliotecas, fuentes remotas ni dependencias del tema Almondb.
 */
.cesaev-chat {
  --ca-primary: #2f5d62;
  --ca-accent: #65c2bb;
  --ca-ink: #233c40;
  --ca-muted: #617477;
  --ca-line: #e2eae9;
  --ca-surface: #ffffff;
  --ca-soft: #f4f8f7;
  --ca-user: #e0f3f0;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: 100%;
  max-width: 760px;
  min-height: 520px;
  margin: 24px auto;
  overflow: hidden;
  border: 1px solid var(--ca-line);
  border-radius: 18px;
  background: var(--ca-surface);
  color: var(--ca-ink);
  box-shadow: 0 12px 40px rgb(27 60 58 / 10%);
  font: 400 14px/1.55 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  text-align: left;
}
.cesaev-chat *, .cesaev-chat *::before, .cesaev-chat *::after {
  box-sizing: border-box;
}
.cesaev-head {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 11px;
  min-height: 77px;
  padding: 14px 17px;
  background: var(--ca-primary);
  color: #fff;
}
.cesaev-brand-icon {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 39px;
  height: 39px;
  border-radius: 13px;
  background: var(--ca-accent);
  color: #173e43;
}
.cesaev-brand-icon svg { width: 22px; height: 22px; }
.cesaev-heading { display: flex; flex: 1; flex-direction: column; min-width: 0; gap: 1px; }
.cesaev-heading strong { color: #fff; font-size: 15px; font-weight: 700; line-height: 1.35; }
.cesaev-heading span { color: #def4f1; font-size: 11.5px; line-height: 1.4; }
.cesaev-close {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 6px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #fff;
  cursor: pointer;
}
.cesaev-close:hover { background: rgb(255 255 255 / 12%); }
.cesaev-close svg { width: 19px; height: 19px; }
.cesaev-messages {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 65vh;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 17px 14px;
  background: #fff;
  scrollbar-color: #c7d8d5 transparent;
}
.cesaev-bubble {
  width: fit-content;
  max-width: 92%;
  margin: 0 0 14px;
  padding: 11px 14px;
  border: 1px solid #edf1f0;
  border-radius: 15px 15px 15px 5px;
  background: var(--ca-soft);
  color: var(--ca-ink);
  overflow-wrap: anywhere;
  line-height: 1.58;
}
.cesaev-bubble.cesaev-user {
  margin-left: auto;
  border-color: #d8efeb;
  border-radius: 15px 15px 5px 15px;
  background: var(--ca-user);
  white-space: pre-wrap;
}
.cesaev-bubble p { margin: 0 0 8px; }
.cesaev-bubble p:last-child { margin-bottom: 0; }
.cesaev-bubble ul, .cesaev-bubble ol { margin: 5px 0 8px; padding-left: 20px; }
.cesaev-bubble li + li { margin-top: 5px; }
.cesaev-chat a { color: #235f63; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.cesaev-chat a:hover { color: #193f43; }
.cesaev-chat label { display: block; margin: 0 0 5px; color: #345156; font-weight: 600; font-size: 12px; }
.cesaev-chat textarea, .cesaev-chat input, .cesaev-chat select {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #b8ccca;
  border-radius: 10px;
  outline: 0;
  background: #fff;
  color: var(--ca-ink);
  font: inherit;
  line-height: 1.45;
}
.cesaev-chat textarea::placeholder, .cesaev-chat input::placeholder { color: #788a8c; }
.cesaev-chat button { font: inherit; cursor: pointer; }
.cesaev-chat button:disabled { opacity: .55; cursor: not-allowed; }
.cesaev-chat :focus-visible { outline: 3px solid #65c2bb; outline-offset: 3px; }
.cesaev-chat input:focus, .cesaev-chat textarea:focus, .cesaev-chat select:focus {
  border-color: var(--ca-primary);
  box-shadow: 0 0 0 3px rgb(101 194 187 / 16%);
}
.cesaev-compose {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-end;
  gap: 9px;
  margin: 0;
  padding: 13px 14px 8px;
  border-top: 1px solid var(--ca-line);
  background: #fff;
}
.cesaev-compose label { flex: 1; min-width: 0; margin: 0; }
.cesaev-compose textarea { min-height: 44px; max-height: 124px; resize: vertical; }
.cesaev-send {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 11px;
  background: var(--ca-primary);
  color: #fff;
}
.cesaev-send:hover:not(:disabled) { background: #254c50; }
.cesaev-send svg { width: 19px; height: 19px; }
.cesaev-error {
  display: block;
  margin: 0;
  padding: 0 15px 8px;
  background: #fff;
  color: #a12631;
  font-size: 12px;
}
.cesaev-error:empty { display: none; }
.cesaev-ticket {
  width: 100%;
  margin: 2px 0 15px;
  padding: 17px;
  border: 1px solid #b9d9d4;
  border-radius: 15px;
  background: #f8fbfa;
  box-shadow: 0 3px 14px rgb(27 60 58 / 5%);
}
.cesaev-ticket h3 { margin: 0 0 14px; color: var(--ca-primary); font-size: 15px; font-weight: 700; line-height: 1.3; }
.cesaev-ticket label { margin-top: 12px; }
.cesaev-ticket label:first-of-type { margin-top: 0; }
.cesaev-ticket textarea { min-height: 95px; resize: vertical; }
.cesaev-ticket p { margin: 11px 0; color: var(--ca-muted); font-size: 11.5px; }
.cesaev-ticket button[type='submit'] {
  width: 100%;
  margin-top: 3px;
  padding: 11px 13px;
  border: 0;
  border-radius: 10px;
  background: var(--ca-primary);
  color: #fff;
  font-weight: 700;
}
.cesaev-ticket button[type='submit']:hover:not(:disabled) { background: #254c50; }
.cesaev-ticket p[role='alert'] { color: #a12631; }
.cesaev-ticket p[role='alert']:empty { display: none; }
.cesaev-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Lanzador fijo. El panel se despliega HACIA ARRIBA, no fuera del viewport. */
.cesaev-launcher {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 1030;
  margin: 0;
  border: 0;
  background: transparent;
}
.cesaev-launcher > summary {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ca-primary, #2f5d62);
  box-shadow: 0 5px 20px rgb(16 54 53 / 23%);
  color: #fff;
  cursor: pointer;
  list-style: none;
}
.cesaev-launcher > summary::-webkit-details-marker { display: none; }
.cesaev-launcher > summary::marker { content: ''; }
.cesaev-launcher > summary:hover { background: #254b50; }
.cesaev-launcher > summary:focus-visible { outline: 3px solid #65c2bb; outline-offset: 3px; }
.cesaev-launcher > summary svg { width: 25px; height: 25px; }
.cesaev-launcher[open] > summary { background: #254b50; }
.cesaev-chat.cesaev-floating {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  width: min(408px, calc(100vw - 36px));
  max-width: none;
  height: min(632px, calc(100dvh - 112px));
  min-height: 0;
  margin: 0;
  border-radius: 18px;
  box-shadow: 0 14px 48px rgb(18 52 51 / 22%);
}
.cesaev-floating .cesaev-messages { max-height: none; }
@media (max-width: 600px) {
  .cesaev-launcher { right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); }
  .cesaev-launcher > summary { width: 52px; height: 52px; }
  .cesaev-chat.cesaev-floating {
    width: calc(100vw - 24px);
    height: calc(100dvh - 95px - env(safe-area-inset-bottom));
    border-radius: 16px;
  }
  .cesaev-chat { margin: 12px 0; border-radius: 14px; }
  .cesaev-head { padding: 12px 14px; min-height: 72px; }
  .cesaev-messages { padding: 15px 12px 10px; }
  .cesaev-bubble { max-width: 96%; padding: 10px 12px; }
  .cesaev-ticket { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .cesaev-messages { scroll-behavior: auto; }
}

/* 1.0.3: lightweight new-conversation control in desktop and mobile headers. */
.cesaev-chat .cesaev-new-conversation {
  flex:0 0 auto; border:1px solid rgba(255,255,255,.45); border-radius:9px;
  color:#fff; background:transparent; font:inherit; font-size:11px;
  padding:6px 8px; cursor:pointer; line-height:1.3;
}
.cesaev-chat .cesaev-new-conversation:hover,
.cesaev-chat .cesaev-new-conversation:focus-visible { background:rgba(255,255,255,.18); }
@media (max-width:420px) {
  .cesaev-chat .cesaev-new-conversation { font-size:10px; padding:5px 6px; }
}
