/* ===========================
   AVATAR FLOTANTE
   =========================== */
.mia-chat-avatar {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  cursor: pointer;
  transition: transform .25s ease;
}
.mia-chat-avatar:hover { transform: scale(1.05); }
.mia-chat-avatar img {
  width: 260px;
  height: auto;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.45));
  pointer-events: auto;
}

/* ===========================
   PANEL DE CHAT (FLEX COLUMN)
   =========================== */
.mia-chat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 360px;
  max-width: 95vw;
  height: 520px;

  background: #fff;
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(0,0,0,.36);

  display: none;                 /* shown via JS; JS forces display:flex */
  flex-direction: column;
  overflow: hidden;              /* clip corners; inner area scrolls */
  z-index: 9999;

  box-sizing: border-box !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

/* Header fijo */
.mia-header {
  background: #000;
  color: #fff;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  flex-shrink: 0;                /* fixed at top */
}
.mia-header .mia-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
}
.mia-header .mia-close:focus { outline: 2px solid #fff; outline-offset: 2px; }

/* Área de mensajes SCROLLABLE (única parte que crece) */
.mia-messages {
  flex: 1 1 auto;                /* take remaining height */
  padding: 12px 14px;
  background: #f7f7f7;
  box-sizing: border-box !important;
  overflow-y: auto !important;   /* vertical scroll */
  overscroll-behavior: contain;
}

/* Burbujas */
.mia-message { margin-bottom: 10px; max-width: 86%; }
.mia-bubble {
  padding: 9px 13px;
  font-size: 14px;
  word-wrap: break-word;
  box-shadow: 0 1px 3px rgba(0,0,0,.14);
  border-radius: 14px;
  line-height: 1.35;
  background: #fff;
  color: #111;
}
.mia-message.mia-bot .mia-bubble { border-radius: 14px 14px 14px 0; }
.mia-message.mia-user { margin-left: auto; text-align: right; }
.mia-message.mia-user .mia-bubble {
  background: #000;
  color: #fff;
  border-radius: 14px 14px 0 14px;
}

/* Indicador de escritura */
.mia-typing {
  font-size: 12px;
  color: #666;
  margin-top: 4px;
}

/* Barra de entrada fija abajo */
.mia-input {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  background: #fff;
  border-top: 1px solid #ddd;
  box-sizing: border-box !important;
  flex-shrink: 0;                /* fixed at bottom */
}
.mia-input-field {
  flex: 1 1 auto;
  border: 1px solid #ccc;
  border-radius: 999px;
  padding: 9px 13px;
  font-size: 14px;
  outline: none;
  min-width: 0;
}
.mia-input-field:focus { border-color: #111; }
.mia-send {
  background: #000;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 9px 16px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.mia-send:disabled { opacity: .6; cursor: default; }
.mia-send:hover:not(:disabled) { background: #333; }

/* Scrollbar (WebKit) – optional nice look */
.mia-messages::-webkit-scrollbar { width: 10px; }
.mia-messages::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 8px; }
.mia-messages::-webkit-scrollbar-track { background: #f0f0f0; }

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 480px) {
  .mia-chat-avatar img { width: 150px; }
  .mia-chat-panel {
    left: 12px;
    right: 12px;
    bottom: 16px;
    width: auto;
    height: 70vh;                /* comfortable mobile height */
  }
}

/* Reduced motion: minimize animations if user prefers */
@media (prefers-reduced-motion: reduce) {
  .mia-chat-avatar { transition: none; }
}
