/* ============================================================
   ASISTENTE WEB REVENDEDOR - DISEÑO FINAL LIMPIO
   ============================================================ */

.tsa-widget {
  --tsa-principal: #2457d6;
  --tsa-secundario: #536b9f;
  --tsa-fondo: #ffffff;
  --tsa-texto: #1f2937;
  --tsa-user: #2457d6;
  --tsa-bot: #f4f6f8;
  --tsa-avatar-zoom: 1;
  --tsa-avatar-x: 50%;
  --tsa-avatar-y: 50%;
  position: fixed;
  z-index: 999999;
  bottom: 24px;
  font-family: Arial, Helvetica, sans-serif;
}

.tsa-right { right: 24px; }
.tsa-left { left: 24px; }

/* Botón de apertura: debe verse SOLO el avatar */
.tsa-launcher {
  width: 64px;
  height: 64px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .22);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
}

.tsa-launcher img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--tsa-avatar-x) var(--tsa-avatar-y);
  transform: scale(var(--tsa-avatar-zoom));
  display: block;
  background: #ffffff;
}

.tsa-chat-svg {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--tsa-principal), var(--tsa-secundario));
}

/* Panel principal */
.tsa-panel {
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  margin-bottom: 14px;
  background: var(--tsa-fondo);
  color: var(--tsa-texto);
  border-radius: 18px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, .24);
  border: 1px solid rgba(15, 23, 42, .10);
  overflow: hidden;
  display: none;
  flex-direction: column;
}

.tsa-open { display: flex; }

/* Cabecera: solo avatar, nombre y cierre */
.tsa-header {
  min-height: 72px;
  padding: 13px 15px;
  background: linear-gradient(135deg, var(--tsa-principal), var(--tsa-secundario));
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tsa-header-left {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.tsa-avatar {
  width: 46px;
  height: 46px;
  min-width: 46px;
  border-radius: 50%;
  object-fit: cover;
  object-position: var(--tsa-avatar-x) var(--tsa-avatar-y);
  transform: scale(var(--tsa-avatar-zoom));
  background: #ffffff;
  border: 2px solid rgba(255,255,255,.95);
  box-shadow: 0 5px 14px rgba(15,23,42,.18);
  display: block;
}

.tsa-title-box {
  min-width: 0;
}

.tsa-header strong {
  display: block;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tsa-header small {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.2;
  opacity: .95;
}

/* Cerrar: sin letras raras */
.tsa-close {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 50%;
  background: rgba(255,255,255,.16);
  position: relative;
  cursor: pointer;
  font-size: 0;
}

.tsa-close::before,
.tsa-close::after {
  content: "";
  position: absolute;
  width: 15px;
  height: 2px;
  top: 15px;
  left: 9px;
  background: #ffffff;
  border-radius: 5px;
}

.tsa-close::before { transform: rotate(45deg); }
.tsa-close::after { transform: rotate(-45deg); }

/* Nombre del cliente: SIN logo por defecto para evitar garabatos */
.tsa-brand {
  min-height: 46px;
  padding: 10px 16px;
  background: #f6f7fb;
  border-bottom: 1px solid rgba(15,23,42,.06);
  display: flex;
  align-items: center;
  gap: 10px;
}

.tsa-brand img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  border-radius: 6px;
  flex: 0 0 auto;
}

.tsa-brand span {
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: #1f2937;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mensajes */
.tsa-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #ffffff;
}

.tsa-msg {
  max-width: 88%;
  margin: 8px 0;
  padding: 11px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-line;
}

.tsa-bot {
  background: var(--tsa-bot);
  color: var(--tsa-texto);
  border-bottom-left-radius: 6px;
}

.tsa-user {
  margin-left: auto;
  background: var(--tsa-user);
  color: #ffffff;
  border-bottom-right-radius: 6px;
}

/* Acciones */
.tsa-actions,
.tsa-quick {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tsa-actions { margin: 8px 0 10px; }

.tsa-quick {
  padding: 10px 12px;
  background: #ffffff;
  border-top: 1px solid rgba(15,23,42,.07);
}

.tsa-actions button,
.tsa-quick button {
  border: 1px solid rgba(36,87,214,.18);
  background: #ffffff;
  color: var(--tsa-principal);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.tsa-actions button:hover,
.tsa-quick button:hover {
  background: rgba(36,87,214,.06);
}

/* Input */
.tsa-form {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  background: #ffffff;
  border-top: 1px solid rgba(15,23,42,.07);
}

.tsa-form input {
  flex: 1;
  min-width: 0;
  height: 43px;
  border: 1px solid rgba(15,23,42,.14);
  border-radius: 999px;
  padding: 0 15px;
  outline: none;
  font-size: 14px;
  color: var(--tsa-texto);
}

.tsa-form input:focus {
  border-color: rgba(36,87,214,.5);
  box-shadow: 0 0 0 4px rgba(36,87,214,.08);
}

.tsa-send-btn {
  width: 43px;
  height: 43px;
  min-width: 43px;
  border: none;
  border-radius: 50%;
  background: var(--tsa-principal);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* WhatsApp */
.tsa-whatsapp {
  margin: 0 12px 10px;
  height: 44px;
  border-radius: 12px;
  background: #22c55e;
  color: #ffffff;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
}

/* Créditos */
.tsa-creditos {
  padding: 8px 10px 9px;
  text-align: center;
  background: #ffffff;
  border-top: 1px solid rgba(15,23,42,.06);
  font-size: 11px;
}

.tsa-creditos a {
  color: #64748b;
  text-decoration: none;
  font-weight: 700;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}

.tsa-creditos a:hover {
  color: var(--tsa-principal);
}

.tsa-admin-zone { display: none !important; }

@media (max-width: 480px) {
  .tsa-widget {
    right: 14px;
    left: 14px;
    bottom: 14px;
  }

  .tsa-panel {
    width: 100%;
    height: 74vh;
    max-height: calc(100vh - 96px);
  }

  .tsa-launcher {
    margin-left: auto;
  }

  .tsa-left .tsa-launcher {
    margin-left: 0;
  }

  .tsa-quick {
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .tsa-quick button {
    white-space: nowrap;
  }
}