/* SWZ Tooltip Assistant — Premium Design v2 */
:root {
  --swz-ta-z: 999999;
  --swz-ta-radius: 14px;
  --swz-ta-radius-sm: 8px;
  --swz-ta-shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
  --swz-ta-shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.08);
  --swz-ta-border: rgba(0, 0, 0, 0.08);
  --swz-ta-bg: #ffffff;
  --swz-ta-text: #1a1a1a;
  --swz-ta-user-bg: #1a1a1a;
  --swz-ta-user-text: #ffffff;
  --swz-ta-accent: #0073aa;

  --swz-ta-btn-size: 50px;
  --swz-ta-right: 20px;
  --swz-ta-bottom: 20px;

  --swz-ta-bubble-w: 300px;
  --swz-ta-font: 14px;
  --swz-ta-line-height: 1.5;

  --swz-ta-pad-y: 12px;
  --swz-ta-pad-x: 14px;

  --swz-ta-stack-gap: 65px;
  --swz-ta-stack-gap-open: 160px;
}

.swz-ta-root {
  z-index: var(--swz-ta-z);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.swz-ta-root[data-mode="floating"] {
  position: fixed;
  right: var(--swz-ta-right);
  bottom: var(--swz-ta-bottom);
}

.swz-ta-root[data-mode="inline"] {
  position: relative;
  display: inline-block;
}

/* Help Button - Premium */
.swz-ta-help {
  width: var(--swz-ta-btn-size);
  height: var(--swz-ta-btn-size);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--swz-ta-bg) 0%, #f9f9f9 100%);
  box-shadow: var(--swz-ta-shadow);
  border: 1px solid var(--swz-ta-border);
  display: grid;
  place-items: center;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--swz-ta-text);
  position: relative;
}

.swz-ta-help::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: rgba(0, 115, 170, 0.1);
  opacity: 0;
  transition: opacity 0.2s;
}

.swz-ta-help:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.16);
}

.swz-ta-help:hover::before {
  opacity: 1;
}

.swz-ta-help svg {
  width: 24px;
  height: 24px;
  display: block;
  position: relative;
  z-index: 1;
}

/* Bubble Stack */
.swz-ta-bubbles {
  position: absolute;
  right: 0;
  bottom: var(--swz-ta-stack-gap);
  width: var(--swz-ta-bubble-w);
  max-width: 85vw;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
  transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.swz-ta-root[data-open="1"] .swz-ta-bubbles {
  bottom: var(--swz-ta-stack-gap-open);
  max-height: 55vh;
  overflow-y: auto;
  padding-right: 6px;
  pointer-events: auto;
}

/* Bubble - Premium Style */
.swz-ta-bubble {
  background: var(--swz-ta-bg);
  color: var(--swz-ta-text);
  border: 1px solid var(--swz-ta-border);
  box-shadow: var(--swz-ta-shadow);
  border-radius: var(--swz-ta-radius);
  padding: var(--swz-ta-pad-y) var(--swz-ta-pad-x);
  line-height: var(--swz-ta-line-height);
  font-size: var(--swz-ta-font);
  white-space: pre-line;
  pointer-events: auto;
  position: relative;
  animation: swzTaInflate 0.26s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: 86% 110%;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Tail Triangle */
.swz-ta-bubble::after {
  content: "";
  position: absolute;
  right: 14px;
  bottom: -8px;
  width: 14px;
  height: 14px;
  background: var(--swz-ta-bg);
  border-right: 1px solid var(--swz-ta-border);
  border-bottom: 1px solid var(--swz-ta-border);
  transform: rotate(45deg);
  border-radius: 0 0 2px 0;
}

/* User Bubble */
.swz-ta-bubble.user {
  align-self: flex-end;
  background: var(--swz-ta-user-bg);
  color: var(--swz-ta-user-text);
  border-color: rgba(255, 255, 255, 0.12);
}

.swz-ta-bubble.user::after {
  background: var(--swz-ta-user-bg);
  border-right-color: rgba(255, 255, 255, 0.12);
  border-bottom-color: rgba(255, 255, 255, 0.12);
}

/* Animation - Smooth Inflate */
@keyframes swzTaInflate {
  0% {
    transform: translateY(8px) scale(0.65);
    opacity: 0;
    filter: blur(1px);
  }
  70% {
    transform: translateY(-1px) scale(1.02);
    opacity: 1;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
    filter: blur(0);
  }
}

/* Fade Out */
.swz-ta-bubble.swz-ta-fade {
  opacity: 0;
  transform: translateY(6px) scale(0.95);
  transition: opacity 0.32s ease, transform 0.32s ease;
}

/* Panel (Input Area) */
.swz-ta-panel {
  position: absolute;
  right: 0;
  bottom: 65px;
  width: var(--swz-ta-bubble-w);
  max-width: 85vw;
  display: none;
  z-index: 3;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.swz-ta-panel.open {
  display: block;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Avatar */
.swz-ta-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0073aa 0%, #005a87 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  box-shadow: var(--swz-ta-shadow-sm);
  border: 1px solid rgba(255, 255, 255, 0.2);
  margin-left: auto;
  margin-bottom: 8px;
  letter-spacing: 0.08em;
}

/* Input Wrap */
.swz-ta-inputWrap {
  background: var(--swz-ta-bg);
  border: 1px solid var(--swz-ta-border);
  box-shadow: var(--swz-ta-shadow);
  border-radius: 999px;
  display: flex;
  gap: 10px;
  padding: 8px 12px;
  align-items: center;
  transition: all 0.2s;
}

.swz-ta-inputWrap:focus-within {
  border-color: var(--swz-ta-accent);
  box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.1), var(--swz-ta-shadow);
}

/* Input Field */
.swz-ta-input {
  border: none;
  outline: none;
  width: 100%;
  font-size: var(--swz-ta-font);
  background: transparent;
  color: var(--swz-ta-text);
  height: 32px;
  line-height: 32px;
  padding: 0 4px;
  font-family: inherit;
}

.swz-ta-input::placeholder {
  color: #999;
}

/* Send Button */
.swz-ta-send {
  border: none;
  background: linear-gradient(135deg, #0073aa 0%, #005a87 100%);
  color: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  height: 32px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 115, 170, 0.2);
}

.swz-ta-send:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
}

.swz-ta-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mobile Responsiveness */
@media (max-width: 540px) {
  :root {
    --swz-ta-bubble-w: min(90vw, 340px);
    --swz-ta-btn-size: 48px;
    --swz-ta-right: 14px;
    --swz-ta-bottom: 14px;
    --swz-ta-font: 14px;
  }

  .swz-ta-bubble {
    font-size: 14px;
    padding: 10px 12px;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  .swz-ta-help,
  .swz-ta-bubble,
  .swz-ta-bubbles,
  .swz-ta-panel {
    transition: none !important;
    animation: none !important;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  :root {
    --swz-ta-bg: #1e1e1e;
    --swz-ta-text: #f0f0f0;
    --swz-ta-border: rgba(255, 255, 255, 0.1);
  }
}

/* Compact / history mode (burbujas viejas se “encogen” pero no desaparecen) */
.swz-ta-bubble.swz-ta-compact {
  opacity: 0.75;
  transform: scale(0.98);
  filter: saturate(0.95);
  padding: 8px 10px;
  font-size: 13px;
  box-shadow: var(--swz-ta-shadow-sm);
}

.swz-ta-bubble.swz-ta-compact:hover {
  opacity: 0.95;
  transform: scale(1);
}

/* Quick actions */
.swz-ta-actions-title {
  font-weight: 600;
  margin-bottom: 8px;
}
.swz-ta-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.swz-ta-actionBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--swz-ta-border);
  background: #fff;
  text-decoration: none;
  color: var(--swz-ta-text);
  font-size: 13px;
  box-shadow: var(--swz-ta-shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease;
}
.swz-ta-actionBtn:hover {
  transform: translateY(-1px);
  box-shadow: var(--swz-ta-shadow);
}

/* Lead card */
.swz-ta-lead-title { font-weight: 700; margin-bottom: 6px; }
.swz-ta-lead-text { opacity: .9; margin-bottom: 10px; }
.swz-ta-lead-email, .swz-ta-lead-note {
  width: 100%;
  border: 1px solid var(--swz-ta-border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 14px;
}
.swz-ta-lead-btn {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--swz-ta-accent);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--swz-ta-shadow-sm);
}
.swz-ta-lead-btn:disabled { opacity: .7; cursor: not-allowed; }
.swz-ta-lead-msg { margin-top: 8px; font-size: 13px; opacity: .9; }

/* Help tip (tooltip del botón) */
.swz-ta-helptip {
  position: absolute;
  right: calc(100% + 10px);
  bottom: 50%;
  transform: translateY(50%);
  background: #111;
  color: #fff;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 13px;
  box-shadow: var(--swz-ta-shadow);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.swz-ta-helptip::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid #111;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}
.swz-ta-helptip.show {
  opacity: 1;
  transform: translateY(50%) translateX(-2px);
  pointer-events: auto; /* permite click para abrir el chat */
}

/* === UX HOTFIXES (botones, scroll, burbujas) === */

/* 1) Botones de atajos: más visibles */
.swz-ta-actions button,
.swz-ta-actions a {
  background: rgba(30, 136, 229, 0.12) !important;
  border: 1px solid rgba(30, 136, 229, 0.35) !important;
  color: rgba(20, 60, 120, 0.95) !important;
}
.swz-ta-actions button:hover,
.swz-ta-actions a:hover {
  background: rgba(30, 136, 229, 0.18) !important;
}

/* 2) Scroll más discreto */
.swz-ta-bubbles::-webkit-scrollbar { width: 6px; }
.swz-ta-bubbles::-webkit-scrollbar-track { background: transparent; }
.swz-ta-bubbles::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.25);
  border-radius: 10px;
}

.swz-ta-bubbles { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.25) transparent; }

/* 3) Evitar que la última burbuja quede tapada por el input */
.swz-ta-bubbles {
  padding-bottom: 110px !important;
}
.swz-ta-actions-row { display:flex; gap:10px; flex-wrap:wrap; }
.swz-ta-actionCell { display:flex; flex-direction:column; gap:6px; }
.swz-ta-actionHint { font-size:12px; opacity:.85; line-height:1.25; max-width:220px; }

