/* MPC Chatbot Widget */

.mpc-cb-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99998;
  transition: transform 0.2s, opacity 0.2s;
}

.mpc-cb-toggle:hover {
  transform: scale(1.08);
}

.mpc-cb-toggle-hidden {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

/* Nudge bubble */
.mpc-cb-nudge {
  position: fixed;
  bottom: 100px;
  right: 28px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.18);
  padding: 16px 18px 16px 16px;
  max-width: 300px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  z-index: 99998;
  cursor: pointer;
  transform: scale(0.6) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
}

.mpc-cb-nudge-visible {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
  animation: mpc-cb-nudge-float 3s ease-in-out infinite;
}

@keyframes mpc-cb-nudge-float {
  0%, 100% { transform: scale(1) translateY(0); }
  50% { transform: scale(1) translateY(-6px); }
}

.mpc-cb-nudge-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #6366f1, #2563eb);
  color: #fff;
  font-size: 20px;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.mpc-cb-nudge-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mpc-cb-nudge-name {
  font-size: 13px;
  font-weight: 700;
  color: #6366f1;
  letter-spacing: 0.02em;
}

.mpc-cb-nudge-text {
  font-size: 15px;
  line-height: 1.45;
  color: #1e293b;
}

.mpc-cb-nudge-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: #c0c5ce;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}

.mpc-cb-nudge-close:hover {
  color: #475569;
}

.mpc-cb-nudge::after {
  content: "";
  position: absolute;
  bottom: -7px;
  right: 30px;
  width: 14px;
  height: 14px;
  background: #fff;
  transform: rotate(45deg);
  box-shadow: 3px 3px 6px rgba(0, 0, 0, 0.06);
}

/* Pulse ring on toggle when nudge is visible */
.mpc-cb-toggle-pulse {
  animation: mpc-cb-pulse 2s ease-in-out infinite;
}

@keyframes mpc-cb-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25); }
  50% { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25), 0 0 0 10px rgba(37, 99, 235, 0.2); }
}

/* Chat window */
.mpc-cb-window {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 40px);
  min-width: 320px;
  min-height: 400px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  transition: transform 0.25s ease, opacity 0.25s ease;
  transform-origin: bottom right;
}

.mpc-cb-hidden {
  transform: scale(0.8);
  opacity: 0;
  pointer-events: none;
}

/* Resize handle - barra superior */
.mpc-cb-resize-handle {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  cursor: n-resize;
  z-index: 10;
}

.mpc-cb-resize-handle-left {
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  bottom: 0;
  cursor: w-resize;
  z-index: 10;
}

.mpc-cb-resize-handle-corner {
  position: absolute;
  top: 0;
  left: 0;
  width: 14px;
  height: 14px;
  cursor: nw-resize;
  z-index: 11;
}

.mpc-cb-resize-handle-corner::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 7px;
  height: 7px;
  border-top: 2px solid rgba(255, 255, 255, 0.5);
  border-left: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 1px;
}

/* Header */
.mpc-cb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  color: #fff;
  flex-shrink: 0;
}

.mpc-cb-header-title {
  font-weight: 600;
  font-size: 15px;
}

.mpc-cb-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  opacity: 0.8;
}

.mpc-cb-close:hover {
  opacity: 1;
}

/* Messages */
.mpc-cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.mpc-cb-msg {
  display: flex;
  max-width: 85%;
}

.mpc-cb-msg-user {
  align-self: flex-end;
}

.mpc-cb-msg-bot {
  align-self: flex-start;
}

.mpc-cb-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.mpc-cb-msg-user .mpc-cb-bubble {
  background: #2563eb;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.mpc-cb-msg-bot .mpc-cb-bubble {
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}

.mpc-cb-text code {
  background: rgba(0, 0, 0, 0.08);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 13px;
}

/* Input */
.mpc-cb-input-area {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid #e5e7eb;
  gap: 8px;
  flex-shrink: 0;
}

.mpc-cb-input {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.mpc-cb-input:focus {
  border-color: #2563eb;
}

.mpc-cb-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.mpc-cb-send:hover {
  transform: scale(1.08);
}

/* Honeypot (invisible) */
.mpc-cb-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  tab-index: -1;
}

/* Mobile */
@media (max-width: 480px) {
  .mpc-cb-window {
    width: calc(100vw - 16px);
    height: calc(100dvh - 100px);
    bottom: 8px;
    right: 8px;
    max-height: calc(100dvh - 100px);
    border-radius: 12px;
  }

  .mpc-cb-resize-handle,
  .mpc-cb-resize-handle-left,
  .mpc-cb-resize-handle-corner {
    display: none;
  }

  .mpc-cb-nudge {
    right: 8px;
    bottom: 100px;
    max-width: calc(100vw - 80px);
  }
}
