/* ==========================================================================
   Chatbot Widget — Diego Cuevas Main Website
   Modern floating chat with avatar integration
   ========================================================================== */

/* ── Floating Character (BonziBuddy-style, no circle) ───── */

.dc-chatbot-btn {
  position: fixed;
  bottom: 8px;
  right: 12px;
  width: 140px;
  height: 220px;
  border-radius: 0;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  z-index: 99990;
  box-shadow: none;
  transition: transform 0.25s ease;
  /* soft drop shadow on the character itself (follows PNG alpha) */
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.45));
  /* Pointer events preserved even when host page uses cursor: none */
  pointer-events: auto;
}

.dc-chatbot-btn:hover {
  transform: scale(1.06) translateY(-2px);
}

.dc-chatbot-btn:active {
  transform: scale(0.98);
}

.dc-chatbot-btn-avatar {
  position: absolute;
  inset: 0;
  background-image: url('retro/assets/avatars/pixel/diego-wave.png');
  background-repeat: no-repeat;
  background-position: center bottom;
  background-size: contain;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  pointer-events: none;
  border-radius: 0;
}

.dc-chatbot-btn.hidden {
  display: none;
}

/* Subtle idle bob */
@keyframes dcAvatarBounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}
.dc-chatbot-btn:not(.hidden) .dc-chatbot-btn-avatar {
  animation: dcAvatarBounce 2.6s ease-in-out infinite;
}

/* ── BonziBuddy-style Speech Bubble ──────────────────────── */
.dc-chatbot-bubble {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  min-width: 180px;
  max-width: 260px;
  padding: 10px 14px;
  background: #ffffff;
  color: #111118;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35),
              0 0 0 1px rgba(43, 125, 233, 0.25);
  opacity: 0;
  transform: translateY(8px) scale(0.9);
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  text-align: left;
  white-space: normal;
  z-index: 1;
}
.dc-chatbot-bubble.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  animation: dcBubbleWobble 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.dc-chatbot-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 20px;
  width: 14px;
  height: 14px;
  background: #ffffff;
  transform: rotate(45deg);
  box-shadow: 1px 1px 0 rgba(43, 125, 233, 0.25);
  z-index: -1;
}
@keyframes dcBubbleWobble {
  0%   { transform: translateY(8px) scale(0.85) rotate(-2deg); }
  60%  { transform: translateY(-2px) scale(1.05) rotate(1.5deg); }
  100% { transform: translateY(0) scale(1) rotate(0); }
}
@media (max-width: 480px) {
  .dc-chatbot-bubble { min-width: 140px; max-width: 210px; font-size: 12px; padding: 8px 12px; }
}

/* ── Chat Panel ──────────────────────────────────────────── */

.dc-chatbot-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 360px;
  height: 520px;
  background: var(--black-light, #111118);
  border: 1px solid rgba(43, 125, 233, 0.3);
  border-radius: 16px;
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6),
              0 0 30px rgba(43, 125, 233, 0.1);
  animation: chatPanelIn 0.3s ease-out;
}

.dc-chatbot-panel.open {
  display: flex;
}

@keyframes chatPanelIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Header ──────────────────────────────────────────────── */

.dc-chatbot-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--blue-dark, #0d3a7a), var(--blue, #1a5fb4));
  border-bottom: 1px solid rgba(43, 125, 233, 0.3);
  flex-shrink: 0;
}

.dc-chatbot-header-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.1);
  background-repeat: no-repeat;
  background-position: center 4px;
  background-size: 82% auto;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  overflow: hidden;
  flex-shrink: 0;
  transition: background-image 0.25s ease;
}

.dc-chatbot-header-avatar svg {
  width: 34px;
  height: 34px;
}

.dc-chatbot-header-info {
  flex: 1;
}

.dc-chatbot-header-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
}

.dc-chatbot-header-status {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.dc-chatbot-header-status::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #4ade80;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.dc-chatbot-lang {
  display: inline-flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 2px;
  flex-shrink: 0;
}
.dc-chatbot-lang button {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.65);
  background: transparent;
  border: none;
  padding: 4px 7px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.dc-chatbot-lang button:hover { color: #ffffff; }
.dc-chatbot-lang button.active {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.dc-chatbot-voice {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
  opacity: 0.55;
}
.dc-chatbot-voice:hover { background: rgba(255, 255, 255, 0.2); opacity: 1; }
.dc-chatbot-voice.active { opacity: 1; background: rgba(43, 125, 233, 0.45); color: #ffffff; }

.dc-chatbot-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #ffffff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.dc-chatbot-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ── Messages Area ───────────────────────────────────────── */

.dc-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--blue, #1a5fb4) transparent;
}

.dc-chatbot-messages::-webkit-scrollbar {
  width: 4px;
}

.dc-chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--blue, #1a5fb4);
  border-radius: 4px;
}

/* ── Message Bubbles ─────────────────────────────────────── */

.dc-chatbot-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  position: relative;
}

.dc-chatbot-msg.bot {
  align-self: flex-start;
  background: rgba(43, 125, 233, 0.15);
  color: #e0e0ee;
  border-bottom-left-radius: 4px;
}

.dc-chatbot-msg.user {
  align-self: flex-end;
  background: var(--blue, #1a5fb4);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.dc-chatbot-msg-time {
  display: block;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 4px;
  text-align: right;
}

.dc-chatbot-msg.bot .dc-chatbot-msg-time {
  text-align: left;
}

/* ── Input Area ──────────────────────────────────────────── */

.dc-chatbot-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid rgba(43, 125, 233, 0.15);
  flex-shrink: 0;
}

.dc-chatbot-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(43, 125, 233, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.2s;
}

.dc-chatbot-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.dc-chatbot-input:focus {
  border-color: var(--blue-glow, #2b7de9);
}

.dc-chatbot-send {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--blue, #1a5fb4);
  border: none;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}

.dc-chatbot-send:hover {
  background: var(--blue-glow, #2b7de9);
}

.dc-chatbot-send:active {
  transform: scale(0.9);
}

.dc-chatbot-send svg {
  width: 18px;
  height: 18px;
  fill: #ffffff;
}

/* ── Mobile Responsive ───────────────────────────────────── */

@media (max-width: 480px) {
  .dc-chatbot-panel {
    width: calc(100vw - 16px);
    height: calc(100vh - 80px);
    bottom: 8px;
    right: 8px;
    border-radius: 12px;
  }

  .dc-chatbot-btn {
    bottom: 12px;
    right: 12px;
    width: 96px;
    height: 150px;
    z-index: 99990;
    /* Extra lift on mobile so the avatar always sits above fixed nav/hero */
  }
  .dc-chatbot-btn-avatar {
    /* Force repaint with hardware acceleration to fix some iOS rendering quirks */
    transform: translateZ(0);
  }
}
@media (max-width: 768px) {
  .dc-chatbot-btn { z-index: 99990; }
}
