/* ===== Widget de chat ===== */
#cv-chat-toggle {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 200;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(18,20,28,0.22);
  transition: transform 0.15s ease;
}
#cv-chat-toggle:hover { transform: translateY(-2px); }
#cv-chat-toggle svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#cv-chat-toggle .cv-chat-icon-close { display: none; }
#cv-chat-toggle[aria-expanded="true"] .cv-chat-icon-open { display: none; }
#cv-chat-toggle[aria-expanded="true"] .cv-chat-icon-close { display: block; }
#cv-chat-badge {
  position: fixed;
  right: 20px;
  bottom: 76px;
  z-index: 201;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-2);
  border: 2px solid var(--paper);
}
#cv-chat-badge[hidden] { display: none; }

#cv-chat-panel {
  position: fixed;
  right: 24px;
  bottom: 94px;
  z-index: 200;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: var(--paper-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 30px 80px rgba(18,20,28,0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#cv-chat-panel[hidden] { display: none; }

.cv-chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
}
.cv-chat-header strong { font-family: 'Plex Mono', monospace; font-size: 15px; }
.cv-chat-header span { display: block; font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.cv-chat-header button {
  background: none;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 2px 4px;
}
.cv-chat-header button:hover { color: var(--ink); }

.cv-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cv-msg {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.cv-msg-assistant {
  align-self: flex-start;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  color: var(--ink);
}
.cv-msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.cv-msg-system {
  align-self: center;
  background: transparent;
  color: var(--ink-soft);
  font-size: 12px;
  text-align: center;
  max-width: 100%;
}

.cv-typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 0; }
.cv-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-soft);
  animation: cv-blink 1.2s infinite ease-in-out;
}
.cv-typing span:nth-child(2) { animation-delay: 0.2s; }
.cv-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes cv-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.cv-chat-actions { display: flex; gap: 8px; align-self: flex-start; flex-wrap: wrap; }
.cv-chat-actions button {
  font-size: 13px;
  font-weight: 600;
  font-family: 'Plex Sans', sans-serif;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper-3);
  color: var(--ink);
  cursor: pointer;
}
.cv-chat-actions button.cv-primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
.cv-chat-actions button:hover { border-color: var(--accent); }

.cv-lead-form {
  align-self: stretch;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 8px;
}
.cv-lead-form input {
  background: var(--paper-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-family: 'Plex Sans', sans-serif;
}
.cv-lead-form input:focus { outline: none; border-color: var(--accent-2); }
.cv-lead-form button {
  margin-top: 2px;
  padding: 9px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  font-family: 'Plex Sans', sans-serif;
  cursor: pointer;
}
.cv-lead-form small { color: var(--ink-soft); font-size: 11px; }

.cv-chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}
.cv-chat-form input {
  flex: 1;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-family: 'Plex Sans', sans-serif;
}
.cv-chat-form input:focus { outline: none; border-color: var(--accent-2); }
.cv-chat-form button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}
.cv-chat-form button:disabled { opacity: 0.5; cursor: not-allowed; }

.cv-chat-call-cta {
  margin: 0 12px 12px;
  padding: 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  font-size: 12px;
  font-family: 'Plex Sans', sans-serif;
  cursor: pointer;
}
.cv-chat-call-cta:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 480px) {
  #cv-chat-panel {
    right: 12px;
    left: 12px;
    bottom: 88px;
    width: auto;
    max-width: none;
    height: calc(100vh - 120px);
  }
  #cv-chat-toggle { right: 16px; bottom: 16px; }
}
