/* KontaBot landing chat (widget styles) */

.chat-tip {
  position: fixed;
  bottom: 96px;
  right: 28px;
  z-index: 149;
  max-width: 260px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #161616;
  border: 1px solid rgba(83, 74, 183, 0.3);
  color: #fafafa;
  font-size: 0.88rem;
  line-height: 1.45;
  box-shadow: 0 8px 28px rgba(83, 74, 183, 0.25);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.chat-tip.show {
  opacity: 1;
  transform: translateY(0);
}

.chat-fab {
  position: fixed;
  bottom: 48px;
  right: 48px;
  z-index: 150;
  width: 96px;
  height: 96px;
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
  cursor: pointer;
  filter: drop-shadow(0 4px 24px rgba(83, 74, 183, 0.35));
  transition: transform 0.25s ease;
}

.chat-fab:hover {
  transform: scale(1.08);
}

.chat-fab canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  background: transparent;
  border-radius: 0;
}

.chat-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  z-index: 140;
  width: 380px;
  max-height: min(72vh, 560px);
  display: flex;
  flex-direction: column;
  background: #0d0d0d;
  color: #fafafa;
  border: 1px solid rgba(83, 74, 183, 0.3);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(83, 74, 183, 0.08) inset;
  overflow: hidden;
}

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

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: rgba(83, 74, 183, 0.1);
  border-bottom: 1px solid rgba(83, 74, 183, 0.25);
  font-weight: 700;
  font-size: 0.95rem;
}

.chat-close {
  background: none;
  border: 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}

.chat-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
  max-height: 360px;
}

.chat-msg {
  max-width: 90%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
  box-sizing: border-box;
}

.chat-msg--user {
  align-self: flex-end;
  background: rgba(83, 74, 183, 0.35);
  border: 1px solid rgba(83, 74, 183, 0.45);
}

.chat-msg--bot {
  align-self: flex-start;
  background: #161616;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #111111;
}

.chat-input-row input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(83, 74, 183, 0.25);
  background: #161616;
  color: #fafafa;
  font: inherit;
  font-size: 0.9rem;
}

.chat-input-row input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.chat-input-row input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.chat-input-row button[type="submit"] {
  padding: 10px 14px;
  border-radius: 10px;
  border: 0;
  background: #534ab7;
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.chat-input-row button[type="submit"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.kb-chat-final-cta {
  padding: 8px 14px 12px;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.72);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: #111;
}

.kb-email-wrap {
  padding: 12px;
  border-top: 1px solid rgba(83, 74, 183, 0.2);
  background: rgba(83, 74, 183, 0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kb-email-wrap[hidden] {
  display: none !important;
}

.kb-email-wrap label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.5);
}

.kb-email-wrap input,
.kb-email-wrap textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(83, 74, 183, 0.25);
  background: #161616;
  color: #fafafa;
  font: inherit;
  font-size: 0.88rem;
  box-sizing: border-box;
}

.kb-email-wrap textarea {
  min-height: 72px;
  resize: vertical;
}

.kb-email-wrap button {
  padding: 10px 14px;
  border-radius: 10px;
  border: 0;
  background: #534ab7;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 640px) {
  /* Panel: casi fullscreen con margen; flex column = header + body scroll + footer fijo */
  .chat-panel {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    bottom: max(8px, env(safe-area-inset-bottom, 0px)) !important;
    top: max(8px, env(safe-area-inset-top, 0px)) !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
  }

  .chat-panel-header {
    flex-shrink: 0;
  }

  .chat-messages {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px;
    overscroll-behavior: contain;
  }

  .kb-email-wrap {
    flex-shrink: 0;
    padding: 8px 12px;
  }

  .chat-input-row {
    flex-shrink: 0;
    padding: 8px 12px;
    gap: 8px;
    background: #111111;
  }

  .chat-input-row input {
    font-size: 16px !important;
    padding: 10px 14px;
    line-height: 1.35;
  }

  .kb-email-wrap input,
  .kb-email-wrap textarea {
    font-size: 16px !important;
    padding: 10px 14px;
  }

  .kb-chat-final-cta {
    flex-shrink: 0;
    padding: 8px 12px 12px;
  }

  .chat-msg {
    max-width: 80%;
    font-size: 14px;
    padding: 9px 12px;
    line-height: 1.45;
  }

  .chat-msg--user {
    margin-right: 4px;
  }

  .chat-msg--bot {
    margin-left: 4px;
  }

  .chat-fab {
    bottom: 20px !important;
    right: 20px !important;
    width: 64px !important;
    height: 64px !important;
  }

  .chat-tip {
    bottom: 92px !important;
    right: 20px !important;
    max-width: 200px;
    font-size: 12px;
    padding: 8px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-tip {
    transition: none;
  }

  .chat-fab {
    transition: none;
  }
}
