/* ═══════════════════════════════════════════════════════════════════════════
   🤖 CHATBOT WIDGET
   Variables tomadas de css/root.css del theme cuando están disponibles.
   ═══════════════════════════════════════════════════════════════════════════ */

.tattooedu-chatbot {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 99999;
  font-family: var(--font-base, system-ui, -apple-system, "Segoe UI", sans-serif);
}

.tattooedu-chatbot__bubble {
  display: none;
}

.tattooedu-chatbot__panel {
  display: none;
  position: absolute;
  bottom: 10px;
  right: 0;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 100px);
  background: var(--color-fondo, #fff);
  color: var(--color-texto, #111);
  border: 1px solid var(--tenue, #e0e0e0);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  flex-direction: column;
  overflow: hidden;
}

.tattooedu-chatbot[data-state="open"] .tattooedu-chatbot__panel {
  display: flex;
}

.tattooedu-chatbot__header {
  background: var(--color-principal, #111);
  color: var(--color-fondo, #fff);
  padding: 12px 14px;
}

.tattooedu-chatbot__title {
  font-size: 15px;
  line-height: 1.2;
}

.tattooedu-chatbot__status {
  font-size: 11px;
  opacity: 0.7;
}

.tattooedu-chatbot__close {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

.tattooedu-chatbot__close:hover {
  background: rgba(255, 255, 255, 0.15);
}

.tattooedu-chatbot__aviso {
  font-size: 11px;
  background: var(--tenue-fondo, #f7f7f7);
  color: var(--color-texto-suave, #666);
  padding: 8px 14px;
  border-bottom: 1px solid var(--tenue, #e0e0e0);
}

.tattooedu-chatbot__mensajes {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--color-fondo, #fff);
}

.tattooedu-chatbot__msg {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.tattooedu-chatbot__msg--bot {
  align-self: flex-start;
  background: var(--tenue-fondo, #f1f1f1);
  color: var(--color-texto, #111);
  border-bottom-left-radius: 4px;
}

.tattooedu-chatbot__msg--user {
  align-self: flex-end;
  background: var(--color-principal, #111);
  color: var(--color-fondo, #fff);
  border-bottom-right-radius: 4px;
}

.tattooedu-chatbot__msg--error {
  align-self: center;
  background: #fee;
  color: #a00;
  font-size: 12px;
  border-radius: 6px;
}

.tattooedu-chatbot__typing {
  align-self: flex-start;
  font-size: 12px;
  color: var(--color-texto-suave, #666);
  font-style: italic;
}

.tattooedu-chatbot__form {
  border-top: 1px solid var(--tenue, #e0e0e0);
  padding: 10px;
  background: var(--color-fondo, #fff);
}

.tattooedu-chatbot__input {
  flex: 1;
  resize: none;
  border: 1px solid var(--tenue, #e0e0e0);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--color-texto, #111);
  background: var(--color-fondo, #fff);
  max-height: 100px;
  outline: none;
}

.tattooedu-chatbot__input:focus {
  border-color: var(--color-principal, #111);
}

.tattooedu-chatbot__enviar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--color-principal, #111);
  color: var(--color-fondo, #fff);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tattooedu-chatbot__enviar:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Gate WhatsApp */
.tattooedu-chatbot .tattooedu-chatbot__gate {
  display: none;
  padding: 16px;
}
.tattooedu-chatbot[data-fase="gate"] .tattooedu-chatbot__gate { display: flex; }
.tattooedu-chatbot[data-fase="gate"] .tattooedu-chatbot__mensajes,
.tattooedu-chatbot[data-fase="gate"] .tattooedu-chatbot__form,
.tattooedu-chatbot[data-fase="gate"] .tattooedu-chatbot__adjunto-preview,
.tattooedu-chatbot[data-fase="gate"] .tattooedu-chatbot__terminar { display: none; }
.tattooedu-chatbot[data-fase="chat"] .tattooedu-chatbot__gate,
.tattooedu-chatbot[data-fase="chat"] .tattooedu-chatbot__aviso { display: none; }
.tattooedu-chatbot__gate-titulo {
  font-size: 14px;
  color: var(--color-texto, #111);
  line-height: 1.4;
  margin: 0;
}
.tattooedu-chatbot__gate-input {
  flex: 1;
  border: 1px solid var(--tenue, #e0e0e0);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--color-fondo, #fff);
  color: var(--color-texto, #111);
  outline: none;
}
.tattooedu-chatbot__gate-input:focus { border-color: var(--color-principal, #111); }
.tattooedu-chatbot__gate-enviar {
  border: none;
  background: var(--color-principal, #111);
  color: var(--color-fondo, #fff);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
}
.tattooedu-chatbot__gate-error {
  font-size: 12px;
  color: #c0392b;
}

/* Botón Terminar */
.tattooedu-chatbot__terminar {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.tattooedu-chatbot__terminar:hover { opacity: 0.85; }

/* Adjuntar imagen */
.tattooedu-chatbot__adjunto {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-texto-suave, #666);
  flex-shrink: 0;
}
.tattooedu-chatbot__adjunto:hover { color: var(--color-principal, #111); }

.tattooedu-chatbot__adjunto-preview:empty { display: none; }
.tattooedu-chatbot__adjunto-preview {
  padding: 6px 10px;
  background: var(--color-fondo-suave, #f7f7f7);
  border-top: 1px solid var(--tenue, #e0e0e0);
}
.tattooedu-chatbot__preview-img {
  max-width: 60px;
  max-height: 60px;
  border-radius: 6px;
  object-fit: cover;
}
.tattooedu-chatbot__preview-quitar {
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

/* Imagen dentro del mensaje */
.tattooedu-chatbot__msg-img {
  display: block;
  max-width: 100%;
  max-height: 220px;
  border-radius: 8px;
  margin-top: 6px;
  cursor: zoom-in;
}
.tattooedu-chatbot__msg-texto { display: block; }

/* Enlaces en mensajes */
.tattooedu-chatbot__msg a {
  color: inherit;
  text-decoration: underline;
  word-break: break-all;
}
.tattooedu-chatbot__msg--bot a { color: var(--color-principal, #111); }

@media (max-width: 700px) {
  .tattooedu-chatbot {
    bottom: 12px;
    right: 12px;
  }
  .tattooedu-chatbot__panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 90px);
    bottom: 70px;
  }
}
