:root{
  --pv-chat-primary: #0f172a;
  --pv-chat-primary-2: #16213e;
  --pv-chat-bg: #ffffff;
  --pv-chat-soft: #f3f4f6;
  --pv-chat-soft-2: #eef2f7;
  --pv-chat-line: #e5e7eb;
  --pv-chat-text: #111827;
  --pv-chat-muted: #667085;
  --pv-chat-user-bg: #0f172a;
  --pv-chat-user-text: #ffffff;
  --pv-chat-bot-bg: #f2f4f7;
  --pv-chat-bot-text: #101828;
  --pv-chat-shadow: 0 22px 60px rgba(2, 6, 23, 0.20);
  --pv-chat-radius: 26px;
  --pv-chat-font: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#pv-chat-bubble-root,
#pv-chat-bubble-root *{
  box-sizing: border-box;
  font-family: var(--pv-chat-font);
}

#pv-chat-bubble-root{
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 999999;
  color: var(--pv-chat-text);
}

/* Burbuja */
.pv-chat-toggle{
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--pv-chat-primary), var(--pv-chat-primary-2));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.34);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
  padding: 0;
}

.pv-chat-toggle:hover{
  transform: translateY(-2px);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.42);
}

.pv-chat-toggle:focus-visible,
.pv-chat-close:focus-visible,
.pv-chat-send:focus-visible,
#pvChatInput:focus-visible{
  outline: none;
  box-shadow: 0 0 0 4px rgba(59,130,246,.18);
}

.pv-chat-toggle-icon{
  font-size: 28px;
  line-height: 1;
}

.pv-chat-toggle-label{
  display: none;
}

/* Panel */
.pv-chat-panel{
  position: absolute;
  right: 0;
  bottom: 82px;
  width: min(392px, calc(100vw - 24px));
  height: min(680px, calc(100vh - 110px));
  background: var(--pv-chat-bg);
  border: 1px solid rgba(15,23,42,.06);
  border-radius: var(--pv-chat-radius);
  box-shadow: var(--pv-chat-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.pv-chat-panel[hidden]{
  display: none !important;
}

/* Header */
.pv-chat-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 14px;
  background: #fff;
  border-bottom: 1px solid var(--pv-chat-line);
}

.pv-chat-persona{
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.pv-chat-avatar{
  width: 46px;
  height: 46px;
  min-width: 46px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--pv-chat-soft-2);
  color: var(--pv-chat-primary);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -.02em;
}

.pv-chat-header-copy{
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.pv-chat-header-copy strong{
  display: block;
  margin: 0;
  color: var(--pv-chat-text);
  font-size: 17px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -.02em;
}

.pv-chat-header-copy span{
  display: block;
  margin-top: 2px;
  color: var(--pv-chat-muted);
  font-size: 13px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pv-chat-close{
  width: 42px;
  height: 42px;
  min-width: 42px;
  border: 0;
  border-radius: 999px;
  background: #f3f4f6;
  color: #111827;
  font-size: 30px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .16s ease, transform .16s ease;
  padding: 0;
}

.pv-chat-close:hover{
  background: #e8eaee;
  transform: scale(1.02);
}

.pv-chat-subtitle{
  padding: 10px 18px 0;
  color: var(--pv-chat-muted);
  font-size: 13px;
  line-height: 1.4;
  background: #fff;
}

.pv-chat-status{
  min-height: 20px;
  padding: 6px 18px 10px;
  color: var(--pv-chat-muted);
  font-size: 12px;
  line-height: 1.35;
  background: #fff;
}

/* Área mensajes */
.pv-chat-messages{
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 18px;
  background: linear-gradient(to bottom, #ffffff 0%, #fbfcfe 100%);
  scroll-behavior: smooth;
}

.pv-chat-messages::-webkit-scrollbar{
  width: 8px;
}

.pv-chat-messages::-webkit-scrollbar-thumb{
  background: rgba(15,23,42,.16);
  border-radius: 999px;
}

/* Cada mensaje ocupa su propia fila */
.pv-chat-message{
  display: block;
  clear: both;
  width: fit-content;
  max-width: 84%;
  padding: 13px 16px;
  margin-bottom: 12px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.58;
  letter-spacing: -.01em;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  box-shadow: 0 1px 1px rgba(15,23,42,.04);
}

/* Bot */
.pv-chat-message.is-bot{
  background: var(--pv-chat-bot-bg);
  color: var(--pv-chat-bot-text);
  margin-right: auto;
  margin-left: 0;
  border-top-left-radius: 8px;
  border: 1px solid #eaecf0;
}

/* Usuario */
.pv-chat-message.is-user{
  background: linear-gradient(180deg, var(--pv-chat-user-bg), var(--pv-chat-primary-2));
  color: var(--pv-chat-user-text);
  margin-left: auto;
  margin-right: 0;
  border-top-right-radius: 8px;
}

/* Primer mensaje menos pesado */
.pv-chat-message.is-bot:first-child{
  font-size: 15px;
  line-height: 1.55;
}

/* Links dentro de burbujas */
.pv-chat-message a{
  color: inherit;
  text-decoration: underline;
}

/* Composer */
.pv-chat-composer{
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px;
  background: #fff;
  border-top: 1px solid var(--pv-chat-line);
}

#pvChatInput{
  flex: 1;
  min-height: 56px;
  max-height: 130px;
  resize: none;
  border: 1px solid #d0d5dd;
  border-radius: 18px;
  background: #fff;
  color: var(--pv-chat-text);
  font-size: 16px;
  line-height: 1.4;
  padding: 15px 16px;
  margin: 0;
  box-shadow: none;
}

#pvChatInput::placeholder{
  color: #98a2b3;
}

#pvChatInput:focus{
  border-color: #98a2ff;
}

.pv-chat-send{
  width: 54px;
  height: 54px;
  min-width: 54px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--pv-chat-primary), var(--pv-chat-primary-2));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(15,23,42,.22);
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
  padding: 0;
}

.pv-chat-send:hover{
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(15,23,42,.28);
}

.pv-chat-send:disabled{
  opacity: .6;
  cursor: not-allowed;
  transform: none;
}

.pv-chat-send span{
  font-size: 22px;
  line-height: 1;
  transform: translateX(1px);
}

/* Mobile */
@media (max-width: 640px){
  #pv-chat-bubble-root{
    right: 12px;
    bottom: 12px;
  }

  .pv-chat-toggle{
    width: 60px;
    height: 60px;
  }

  .pv-chat-panel{
    width: calc(100vw - 16px);
    height: min(76vh, 620px);
    right: 0;
    bottom: 74px;
    border-radius: 24px;
  }

  .pv-chat-header{
    padding: 14px 14px 12px;
  }

  .pv-chat-avatar{
    width: 42px;
    height: 42px;
    min-width: 42px;
    font-size: 15px;
  }

  .pv-chat-header-copy strong{
    font-size: 18px;
  }

  .pv-chat-header-copy span{
    font-size: 13px;
  }

  .pv-chat-subtitle{
    padding: 8px 14px 0;
    font-size: 12px;
  }

  .pv-chat-status{
    padding: 6px 14px 10px;
    font-size: 12px;
  }

  .pv-chat-messages{
    padding: 14px 12px 16px;
  }

  .pv-chat-message{
    max-width: 88%;
    font-size: 15px;
    line-height: 1.55;
    padding: 12px 14px;
    margin-bottom: 10px;
  }

  .pv-chat-composer{
    padding: 10px;
  }

  #pvChatInput{
    min-height: 54px;
    font-size: 16px;
    border-radius: 16px;
    padding: 14px;
  }

  .pv-chat-send{
    width: 52px;
    height: 52px;
    min-width: 52px;
  }
}

@media (max-width: 420px){
  .pv-chat-panel{
    width: calc(100vw - 12px);
    height: min(74vh, 600px);
    bottom: 72px;
    border-radius: 22px;
  }

  .pv-chat-header-copy strong{
    font-size: 17px;
  }

  .pv-chat-header-copy span{
    font-size: 12px;
  }

  .pv-chat-message{
    font-size: 14px;
    line-height: 1.54;
  }
}

@media (max-height: 740px){
  .pv-chat-panel{
    height: min(640px, calc(100vh - 94px));
  }

  .pv-chat-message{
    font-size: 14px;
  }
}