/* ============================================
   CHAT WIDGET — Side A (assistant) & Side B (abuela)
   ============================================ */

/* ---- Floating Clippy Widget ---- */
.clippy-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
}

.clippy-widget > * {
  pointer-events: auto;
}

/* The Clippy image button */
.clippy-trigger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  width: 70px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.2));
  transition: transform 0.2s ease;
  position: relative;
}

.clippy-trigger:hover {
  transform: scale(1.1);
}

.clippy-trigger:active {
  transform: scale(0.95);
}

.clippy-avatar {
  width: 100%;
  height: 100%;
  object-fit: contain;
  animation: clippyIdle 3s ease-in-out infinite;
}

@keyframes clippyIdle {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  30% { transform: translateY(-4px) rotate(2deg); }
  60% { transform: translateY(-2px) rotate(-1.5deg); }
}

/* ---- Speech bubble tip ---- */
.clippy-tip {
  background: #ffffcc;
  border: 1.5px solid #d4d400;
  border-radius: 8px;
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.4;
  color: #333;
  max-width: 220px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  opacity: 0;
  transform: translateY(8px) scale(0.95);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  position: relative;
}

.clippy-tip::after {
  content: '';
  position: absolute;
  bottom: -7px;
  right: 24px;
  width: 12px;
  height: 12px;
  background: #ffffcc;
  border-right: 1.5px solid #d4d400;
  border-bottom: 1.5px solid #d4d400;
  transform: rotate(45deg);
}

.clippy-tip.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---- Chat panel ---- */
.clippy-chat-panel {
  width: 320px;
  max-height: 420px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  display: none;
  flex-direction: column;
  background: #fafafa;
  border: 1px solid rgba(0,0,0,0.1);
}

.clippy-chat-panel.open {
  display: flex;
  animation: panelSlideUp 0.3s ease;
}

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

.clippy-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: linear-gradient(135deg, #c0c0c0, #e0e0e0);
  border-bottom: 1px solid rgba(0,0,0,0.1);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #333;
}

.clippy-chat-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #666;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.2s ease;
}

.clippy-chat-close:hover {
  color: var(--accent-red);
}

.chat-section {
  border-radius: 0;
  overflow: hidden;
  background: #fafafa;
}

.chat-messages {
  height: 260px;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

/* Bubbles */
.chat-bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  animation: bubbleIn 0.25s ease;
}

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

.chat-bubble-ai {
  align-self: flex-start;
  background: #e9e9eb;
  color: #1a1a1a;
  border-bottom-left-radius: 4px;
}

.chat-bubble-user {
  align-self: flex-end;
  background: var(--accent-red);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.chat-typing {
  display: flex;
  gap: 4px;
  padding: 10px 16px;
}

.chat-typing .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #999;
  animation: typingBounce 1.2s ease-in-out infinite;
}

.chat-typing .dot:nth-child(2) { animation-delay: 0.15s; }
.chat-typing .dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Input row */
.chat-input-row {
  display: flex;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
}

.chat-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 10px 14px;
  font-size: 13px;
  font-family: var(--mono);
  background: transparent;
  color: #1a1a1a;
}

.chat-input::placeholder {
  color: #aaa;
}

.chat-send {
  border: none;
  background: none;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--accent-red);
  display: flex;
  align-items: center;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.chat-send:hover {
  transform: scale(1.15);
}

.chat-send:active {
  transform: scale(0.95);
}

/* ============================================
   SIDE B — Abuela variant (dark theme)
   ============================================ */

.alt-chat-section {
  padding: 0 20px;
  margin: 24px 0;
  position: relative;
  overflow: hidden;
}

.alt-chat-section .chat-section {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
}

.alt-chat-section .chat-bubble-ai {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.85);
}

.alt-chat-section .chat-bubble-user {
  background: var(--accent-red);
  color: #fff;
}

.alt-chat-section .chat-input-row {
  border-top-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.alt-chat-section .chat-input {
  color: #fff;
}

.alt-chat-section .chat-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.alt-chat-section .chat-typing .dot {
  background: rgba(255, 255, 255, 0.4);
}

/* Abuela label */
.alt-chat-label {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: rgba(255, 255, 255, 0.75);
  margin-bottom: 4px;
  text-align: center;
}

.alt-chat-sublabel {
  font-family: var(--mono);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  text-align: center;
  margin-bottom: 14px;
  font-style: italic;
}

/* Avatar in chat bubbles */
.chat-bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: bubbleIn 0.25s ease;
}

.chat-bubble-row-ai {
  align-self: flex-start;
}

.chat-bubble-row .chat-bubble {
  animation: none;
}

.avo-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
}

/* Verdict banner */
.avo-verdict {
  text-align: center;
  padding: 24px 16px;
  margin: 16px 0;
  border-radius: var(--radius-md);
  animation: verdictIn 0.6s ease;
}

@keyframes verdictIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.avo-verdict-aprobada {
  background: linear-gradient(135deg, rgba(107, 203, 119, 0.15), rgba(107, 203, 119, 0.05));
  border: 1px solid rgba(107, 203, 119, 0.3);
}

.avo-verdict-rechazada {
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.15), rgba(255, 107, 107, 0.05));
  border: 1px solid rgba(255, 107, 107, 0.3);
}

.verdict-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.verdict-title {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.verdict-sub {
  font-family: var(--mono);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
}

/* Share button */
.avo-share-btn {
  display: block;
  width: calc(100% - 40px);
  margin: 0 20px 16px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.8);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.avo-share-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.avo-share-btn:active {
  transform: scale(0.98);
}

/* Confetti */
.confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  top: 0;
  border-radius: 2px;
  animation: confettiFall linear forwards;
  pointer-events: none;
  z-index: 10;
}

@keyframes confettiFall {
  0% {
    transform: translateY(-20px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(400px) rotate(720deg);
    opacity: 0;
  }
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

.alt-chat-section .chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
}

/* ---- Avó Intro Box ---- */
.avo-intro-box {
  margin: 0 20px 14px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  text-align: center;
}

.avo-intro-text {
  font-family: var(--mono);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.5;
  margin: 0 0 10px;
}

.avo-intro-stakes {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.avo-stake {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: rgba(107, 203, 119, 0.8);
  letter-spacing: 0.5px;
}

.avo-stake-fail {
  color: rgba(255, 107, 107, 0.6);
}

/* ---- Mobile adjustments ---- */
@media (max-width: 600px) {
  .clippy-widget {
    bottom: 12px;
    right: 12px;
  }

  .clippy-trigger {
    width: 68px;
    height: 68px;
  }

  .clippy-tip {
    max-width: 190px;
    font-size: 10px;
  }

  /* Full-screen chat on mobile */
  .clippy-chat-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 100%;
    border-radius: 0;
    z-index: 9999;
  }

  .clippy-chat-panel .chat-messages {
    height: auto;
    flex: 1;
  }

  .clippy-chat-panel .chat-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }

  .clippy-chat-header {
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    font-size: 13px;
  }

  .clippy-chat-close {
    font-size: 22px;
    padding: 4px 8px;
  }

  .clippy-chat-panel .chat-input {
    font-size: 16px;
    padding: 14px 16px;
  }

  .clippy-chat-panel .chat-send {
    padding: 12px 16px;
  }

  .clippy-chat-panel .chat-bubble {
    font-size: 14px;
  }

  .clippy-chat-panel .chat-input-row {
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* Abuela chat — compact on mobile */
  .alt-chat-section {
    padding: 0 12px;
    margin: 16px 0;
  }

  .alt-chat-label {
    font-size: 14px;
    letter-spacing: 2px;
    margin-bottom: 2px;
  }

  .alt-chat-sublabel {
    font-size: 10px;
    margin-bottom: 10px;
  }

  .avo-intro-box {
    margin: 0 0 10px;
    padding: 10px 12px;
  }

  .avo-intro-text {
    font-size: 11px;
    margin-bottom: 8px;
  }

  .avo-stake {
    font-size: 10px;
  }

  .alt-chat-section .chat-messages {
    height: 220px;
  }

  .alt-chat-section .chat-bubble {
    font-size: 13px;
    padding: 7px 10px;
  }

  .avo-avatar {
    width: 26px;
    height: 26px;
  }

  .avo-verdict {
    padding: 16px 12px;
    margin: 10px 0;
  }

  .verdict-icon {
    font-size: 36px;
  }

  .verdict-title {
    font-size: 15px;
  }

  .verdict-sub {
    font-size: 11px;
  }

  .avo-share-btn {
    width: calc(100% - 24px);
    margin: 0 12px 12px;
    padding: 10px;
    font-size: 11px;
  }
}
