/* ============================================================
   Agente Memorias — Frontend CSS
   ============================================================ */

:root {
  --am-purple: #6d28d9;
  --am-purple-lt: #7c3aed;
  --am-blue: #1C3B73;
  --am-blue-lt: #2c529b;
  --am-blue-bg: #f0f4fa;
  --am-gray-50: #f9fafb;
  --am-gray-100: #f3f4f6;
  --am-gray-200: #e5e7eb;
  --am-gray-300: #d1d5db;
  --am-gray-600: #6b7280;
  --am-gray-800: #1f2937;
  --am-green: #1C3B73;
  /* legacy alias used by card styles */
  --am-green-lt: #2c529b;
  --am-green-bg: #f0f4fa;
  --am-radius: 12px;
  --am-shadow: 0 4px 24px rgba(0, 0, 0, .10);
  --am-shadow-lg: 0 24px 80px rgba(0, 5, 20, .28);
  --am-transition: .22s cubic-bezier(.4, 0, .2, 1);
  --am-font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Grid listing ─────────────────────────────────────────────────────── */
.am-lista {
  font-family: var(--am-font);
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.am-lista__header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.am-lista__header h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 700;
  color: var(--am-green);
  margin: 0 0 .5rem;
}

.am-lista__header p {
  color: var(--am-gray-600);
  font-size: 1.05rem;
}

.am-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.75rem;
}

/* ── Memory card ─────────────────────────────────────────────────────── */
.am-floating-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  border: none;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform var(--am-transition), box-shadow var(--am-transition);
  z-index: 2;
  cursor: grab;
}

/* ── Pseudo-element for rotating gradient background ── */
.am-floating-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: conic-gradient(from 180deg at 50% 50%,
      #10B981 0deg,
      #3B82F6 120deg,
      #8B5CF6 240deg,
      #10B981 360deg);
  animation: am-siri-rotate 4s linear infinite;
  z-index: -1;
}

.am-floating-container {
  position: fixed;
  bottom: 16px;
  right: 18px;
  z-index: 2147483647 !important;
  /* Always on top — above modal and any backdrop */
}

.am-floating-container.am-is-dragging .am-floating-btn {
  cursor: grabbing;
  transform: scale(1.05);
  /* Slight lift effect while dragging */
  box-shadow: 0 12px 30px rgba(59, 130, 246, 0.6);
}

.am-floating-btn.am-is-recording-mic::before {
  background: conic-gradient(from 180deg at 50% 50%,
      #EF4444 0deg,
      #F97316 120deg,
      #F59E0B 240deg,
      #EF4444 360deg);
  animation-duration: 2s;
  /* spin faster when recording */
}

/* ── Error state for Safari mic blockage ── */
.am-floating-btn.am-mic-error::before {
  background: #9ca3af !important;
  animation: none !important;
}

.am-floating-btn.am-mic-error {
  box-shadow: 0 4px 16px rgba(156, 163, 175, 0.4) !important;
  cursor: not-allowed !important;
}

.am-js-chat-voice-btn.am-mic-error {
  color: #9ca3af !important;
  cursor: not-allowed !important;
}
.am-js-chat-voice-btn.am-mic-error:hover {
  background: transparent !important;
  color: #9ca3af !important;
}

@keyframes am-siri-rotate {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.am-floating-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.5);
}

.am-floating-btn:hover::before {
  animation-play-state: paused;
}

.am-floating-btn__ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
}

.am-floating-btn.am-is-speaking .am-floating-btn__ring--1 {
  width: 100%;
  height: 100%;
  border: 2px solid #3B82F6;
  animation: am-siri-pulse 2.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

.am-floating-btn.am-is-speaking .am-floating-btn__ring--2 {
  width: 100%;
  height: 100%;
  border: 2px solid #8B5CF6;
  animation: am-siri-pulse 2.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite 0.8s;
}

.am-floating-btn.am-is-speaking .am-floating-btn__ring--3 {
  width: 100%;
  height: 100%;
  height: 100%;
  border: 2px solid #fb923c;
  animation: am-siri-pulse 1.8s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

.am-floating-btn.am-is-recording-mic .am-floating-btn__ring--2 {
  width: 100%;
  height: 100%;
  border: 2px solid #ef4444;
  animation: am-siri-pulse 1.8s cubic-bezier(0.215, 0.61, 0.355, 1) infinite 0.6s;
}

.am-floating-btn.am-is-recording-mic .am-floating-btn__ring--3 {
  width: 100%;
  height: 100%;
  border: 2px solid #f97316;
  animation: am-siri-pulse 1.8s cubic-bezier(0.215, 0.61, 0.355, 1) infinite 1.2s;
}

@keyframes am-siri-pulse {
  0% {
    width: 100%;
    height: 100%;
    opacity: 0.8;
  }

  100% {
    width: 220%;
    height: 220%;
    opacity: 0;
  }
}

.am-floating-btn__icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  width: 52px;
  height: 52px;
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.am-floating-btn:hover .am-floating-btn__icon {
  animation: am-icon-bounce 0.8s ease;
}

@keyframes am-icon-bounce {

  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
  }

  50% {
    transform: translate(-50%, -50%) scale(1.15);
  }
}

.am-card--memoria {
  background: #fff;
  border-radius: var(--am-radius);
  box-shadow: var(--am-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--am-transition), box-shadow var(--am-transition);
  cursor: default;
}

.am-card--memoria:hover {
  transform: translateY(-4px);
  box-shadow: var(--am-shadow-lg);
}

.am-card__thumb {
  position: relative;
  height: 180px;
  background: var(--am-gray-100);
  overflow: hidden;
}

.am-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.am-card__thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 3.5rem;
  background: linear-gradient(135deg, var(--am-green-bg), #d1fae5);
}

.am-ia-badge {
  position: absolute;
  top: .65rem;
  right: .65rem;
  background: rgba(26, 127, 75, .9);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  padding: .25rem .6rem;
  border-radius: 20px;
  backdrop-filter: blur(4px);
  letter-spacing: .04em;
}

.am-card__body {
  padding: 1.25rem 1.4rem 1.5rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: .6rem;
}

.am-card__logo {
  height: 36px;
  width: auto;
  object-fit: contain;
}

.am-card__title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--am-gray-800);
  margin: 0;
  line-height: 1.3;
}

.am-card__emisor {
  font-size: .85rem;
  color: var(--am-green);
  font-weight: 600;
  margin: 0;
}

.am-card__temas {
  list-style: none;
  padding: 0;
  margin: .25rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}

.am-card__temas li {
  background: var(--am-green-bg);
  color: var(--am-green);
  font-size: .72rem;
  font-weight: 600;
  padding: .2rem .55rem;
  border-radius: 20px;
  border: 1px solid #bbf7d0;
}

.am-card__temas-more {
  background: var(--am-gray-200);
  color: var(--am-gray-600);
  border-color: transparent;
}

/* ── Pagination ──────────────────────────────────────────────────────── */
.am-pagination {
  display: flex;
  justify-content: center;
  gap: .5rem;
  margin-top: 2.5rem;
}

.am-pagination__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: var(--am-gray-100);
  color: var(--am-gray-800);
  font-weight: 600;
  text-decoration: none;
  transition: background var(--am-transition);
}

.am-pagination__btn:hover,
.am-pagination__btn--active {
  background: var(--am-green);
  color: #fff;
}

/* ── Buttons (shared) ────────────────────────────────────────────────── */
.am-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  border: none;
  cursor: pointer;
  font-family: var(--am-font);
  font-weight: 600;
  border-radius: 8px;
  transition: filter var(--am-transition), transform var(--am-transition);
  text-decoration: none;
}

.am-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.am-btn--primary {
  background: var(--am-green);
  color: #fff;
  padding: .7rem 1.4rem;
  font-size: .92rem;
}

.am-btn--success {
  background: #059669;
  color: #fff;
  padding: .7rem 1.4rem;
  font-size: .92rem;
}

.am-btn--outline {
  background: transparent;
  border: 2px solid var(--am-green);
  color: var(--am-green);
  padding: .6rem 1.2rem;
  font-size: .88rem;
}

.am-btn--sm {
  padding: .45rem .9rem;
  font-size: .82rem;
}

.am-btn--lg {
  padding: .85rem 1.8rem;
  font-size: 1rem;
}

.am-btn--block {
  width: 100%;
  justify-content: center;
  margin-top: 1rem;
}

.am-empty {
  text-align: center;
  color: var(--am-gray-600);
  padding: 3rem 0;
}

/* ── Modal ───────────────────────────────────────────────────────────── */
.am-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483647 !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

body:not(.am-modal-open) .am-modal {
  pointer-events: none !important;
}

/* ── Bot Aura Pulse Effect on Modal Box & Screen Edge ───────────────────── */
body.am-modal-open .am-modal::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  /* over the backdrop, under or over the box doesn't matter since it's just edges */
  box-shadow: inset 0 0 0 4px rgba(125, 74, 255, 0.8), inset 0 0 40px rgba(148, 102, 255, 0.6);
  animation: am-aura-pulse-edge 2s ease-in-out infinite;
}

@keyframes am-aura-pulse-edge {
  0% {
    opacity: 0.3;
  }

  50% {
    opacity: 1;
  }

  100% {
    opacity: 0.3;
  }
}

body.am-modal-open .am-modal__box {
  animation: am-aura-pulse-box 2.2s ease-in-out infinite;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

@keyframes am-aura-pulse-box {
  0% {
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15), 0 0 0px 2px rgba(125, 74, 255, 0.5), 0 0 15px rgba(138, 92, 255, 0.3);
  }

  50% {
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15), 0 0 0px 4px rgba(125, 74, 255, 0.8), 0 0 30px rgba(148, 102, 255, 0.6);
  }

  100% {
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15), 0 0 0px 2px rgba(125, 74, 255, 0.5), 0 0 15px rgba(138, 92, 255, 0.3);
  }
}

.am-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
}

.am-modal__box {
  position: relative;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: var(--am-shadow-lg);
  padding: 1.25rem 1.25rem 1rem;
  max-width: 760px;
  width: calc(100% - 2rem);
  max-height: 92vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  animation: amModalIn .28s cubic-bezier(.34, 1.56, .64, 1);
  transition: transform .4s cubic-bezier(.34, 1.56, .64, 1), opacity .3s ease, max-width .4s ease, width .4s ease;
  transform-origin: bottom right;
}

.am-modal.am-modal--expanded .am-modal__box {
  max-width: 90vw !important;
  width: 90vw !important;
  max-height: 95vh !important;
  height: 95vh !important;
}

.am-modal__content-area {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 15px;
}

.am-chat-left-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  gap: .75rem;
  transition: flex .4s ease;
}

.am-modal.am-modal--expanded .am-chat-left-panel {
  flex: 1; /* 50% width */
}

@media (max-width: 768px) {
  .am-modal.am-modal--expanded .am-chat-left-panel {
    flex: 1;
  }
}

.am-modal.am-modal-minimized {
  pointer-events: none;
}

.am-modal.am-modal-minimized .am-modal__box {
  pointer-events: auto;
  /* allow clicking/dragging to maximize */
}

.am-modal.am-modal-minimized .am-modal__backdrop {
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s ease;
}

.am-modal.am-modal-minimized .am-modal__box {
  transform: scale(0) translate(200px, 200px);
  opacity: 0;
}

@keyframes amModalIn {
  from {
    opacity: 0;
    transform: scale(.92) translateY(16px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

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

/* ── Modal header ─────────────────────────────────────────────────────── */
.am-modal__header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding-right: 2rem;
  /* space for close btn */
  min-height: 40px;
}

.am-modal__logo {
  height: 36px;
  width: auto;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--am-gray-200);
  padding: 2px;
  flex-shrink: 0;
}

.am-modal__header-text {
  flex: 1;
  overflow: hidden;
}

.am-modal__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--am-gray-800);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.am-modal__emisor-name {
  font-size: .75rem;
  color: var(--am-gray-600);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.am-modal__expand {
  position: absolute;
  top: .9rem;
  right: 3.2rem;
  background: var(--am-gray-100);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--am-gray-600);
  transition: background var(--am-transition);
  flex-shrink: 0;
}

.am-modal__expand:hover {
  background: var(--am-gray-200);
  color: var(--am-gray-800);
}

.am-modal__close {
  position: absolute;
  top: .9rem;
  right: .9rem;
  background: var(--am-gray-100);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--am-gray-600);
  transition: background var(--am-transition);
  flex-shrink: 0;
}

.am-modal__close:hover {
  background: var(--am-gray-200);
  color: var(--am-gray-800);
}

/* ── Chat window ─────────────────────────────────────────────────────── */
.am-chat-window {
  background: var(--am-gray-50);
  border: 1px solid var(--am-gray-200);
  border-radius: 10px;
  flex: 1;
  min-height: 220px;
  max-height: 52vh;
  overflow-y: auto;
  padding: .9rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .02);
}

.am-modal.am-modal--expanded .am-chat-window {
  max-height: none;
}

.am-chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: amFadeInUp .4s ease-out forwards;
}

.am-chat-msg--user {
  align-self: flex-end;
  align-items: flex-end;
}

.am-chat-msg--ai,
.am-chat-msg--system {
  align-self: flex-start;
  align-items: flex-start;
}

.am-chat-author {
  font-size: .7rem;
  font-weight: 600;
  color: var(--am-gray-600);
  margin-bottom: .2rem;
}

.am-chat-msg--user .am-chat-author {
  color: var(--am-purple);
}

.am-chat-bubble {
  padding: .65rem .9rem;
  border-radius: 12px;
  font-size: .92rem;
  line-height: 1.45;
  color: var(--am-gray-800);
}

.am-chat-msg--user .am-chat-bubble {
  background: linear-gradient(90deg, #ffd89b 0%, #f7aab5 50%, #e2b0ff 100%);
  color: #ffffff;
  border-radius: 9999px;
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 14px rgba(247, 170, 181, 0.25);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.am-chat-msg--ai .am-chat-bubble {
  background: #fff;
  border: 1px solid var(--am-gray-200);
  border-bottom-left-radius: 4px;
}

.am-chat-msg--summary {
  align-self: flex-start;
  align-items: flex-start;
  width: 100%;
  max-width: 95%;
  /* allow summary to be a bit wider */
}

.am-chat-msg--summary .am-chat-bubble {
  background: #f3e8ff;
  /* lilac background */
  border: 1px solid #e9d5ff;
  border-bottom-left-radius: 4px;
  color: var(--am-purple);
}

.am-chat-msg--summary .am-chat-bubble h1,
.am-chat-msg--summary .am-chat-bubble h2,
.am-chat-msg--summary .am-chat-bubble h3 {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  color: var(--am-purple);
}

.am-chat-msg--summary .am-chat-bubble ul,
.am-chat-msg--summary .am-chat-bubble ol {
  margin: .4rem 0;
  padding-left: 1.25rem;
}

.am-chat-bubble li {
  margin-bottom: .25rem;
}

/* ── RightData Summary Special Table Styling ──────────── */
.am-chat-msg--summary .am-chat-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 2.2rem 0 1.2rem 0;
  font-size: 0.9em;
  background: transparent;
  border: none;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.am-chat-msg--summary .am-chat-bubble thead,
.am-chat-msg--summary .am-chat-bubble th {
  display: none !important;
  /* Hide standard headers */
}

.am-chat-msg--summary .am-chat-bubble tr {
  display: flex !important;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 1px solid #e2e8f0 !important;
  padding: 0.6rem 0.5rem !important;
  background: #ffffff !important;
}

.am-chat-msg--summary .am-chat-bubble tr:nth-child(even) {
  background: #f8fafc !important;
}

.am-chat-msg--summary .am-chat-bubble td {
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  line-height: 1.3;
}

.am-chat-msg--summary .am-chat-bubble td:first-child {
  text-align: left;
  font-weight: 500;
  color: var(--am-gray-700);
  padding-right: 15px !important;
  flex: 1;
}

.am-chat-msg--summary .am-chat-bubble td:last-child {
  text-align: right;
  font-weight: 700;
  color: var(--am-gray-900);
  white-space: nowrap;
}

.am-chat-msg--system .am-chat-bubble {
  background: transparent;
  color: var(--am-gray-600);
  font-style: italic;
  padding: 0;
  font-size: .83rem;
}

.am-typing-indicator .am-chat-bubble {
  padding: 0.65rem 0.9rem;
  min-width: 60px;
}
.am-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.am-typing-dots span {
  width: 6px;
  height: 6px;
  background-color: var(--am-purple);
  border-radius: 50%;
  animation: amTyping 1.4s infinite both;
}
.am-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.am-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes amTyping {
  0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── Streaming Batches (VSME) ────────────────────────────────────────── */
.am-vsme-batch-part {
  margin-bottom: 0;
  padding-bottom: 0;
}

.am-vsme-data-point-title {
  font-size: 1.15rem !important;
  font-weight: 800 !important;
  color: var(--am-gray-900) !important;
  margin-top: 1.5rem !important;
  margin-bottom: 0.5rem !important;
}

.am-vsme-title-divider {
  border: none;
  border-bottom: 2px solid var(--am-purple);
  margin-bottom: 1rem;
  width: 100%;
}

.am-vsme-divider {
  border: none;
  border-bottom: 1px dashed var(--am-gray-200);
  margin: 1.5rem 0;
}

.am-vsme-veredicto {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  background: #f8fafc;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  border: 1px solid var(--am-gray-200);
}

.am-vsme-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.am-vsme-stats-container {
  margin-top: 2rem;
  padding: 1.5rem;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid var(--am-gray-200);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.am-vsme-stats-title {
  font-size: 1.1rem !important;
  font-weight: 700 !important;
  color: var(--am-gray-900) !important;
  margin-bottom: 1.5rem !important;
  text-align: center;
}

.am-vsme-chart-row {
  display: flex;
  align-items: center;
  gap: 2rem;
  justify-content: center;
  flex-wrap: wrap;
}

.am-vsme-chart-wrapper {
  position: relative;
  width: 150px;
  height: 150px;
  flex-shrink: 0;
}

.am-vsme-stats-legend {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--am-gray-700);
}

.am-vsme-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.am-vsme-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.am-vsme-dot-completo {
  background: #6d28d9;
}

.am-vsme-dot-parcial {
  background: white;
  border: 2px solid #6d28d9;
}

.am-vsme-dot-sin-info {
  background: #fca5a5;
}

/* ── Source selector ─────────────────────────────────────────────────── */
.am-chat-source-selector {
  width: 100%;
  padding: .45rem .75rem;
  border: 1px solid var(--am-gray-200);
  border-radius: 8px;
  font-family: var(--am-font);
  font-size: .82rem;
  color: var(--am-gray-800);
  background: #fff;
  outline: none;
  cursor: pointer;
}

.am-chat-source-selector:focus {
  border-color: var(--am-purple);
}

/* ── Input row ───────────────────────────────────────────────────────── */
.am-chat-input-row {
  display: flex;
  gap: .45rem;
  align-items: center;
}

.am-chat-input {
  flex: 1;
  padding: .65rem .9rem;
  border: 1.5px solid var(--am-gray-200);
  border-radius: 10px;
  font-family: var(--am-font);
  font-size: .92rem;
  outline: none;
  transition: border-color var(--am-transition);
  color: var(--am-gray-800);
}

.am-chat-input:focus {
  border-color: var(--am-purple);
  box-shadow: 0 0 0 3px rgba(109, 40, 217, .08);
}

/* ── Icon buttons ────────────────────────────────────────────────────── */
.am-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1.5px solid var(--am-gray-300);
  border-radius: 9px;
  background: #fff;
  color: var(--am-gray-600);
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--am-transition);
  text-decoration: none;
}

.am-icon-btn:hover:not(:disabled) {
  border-color: var(--am-purple);
  color: var(--am-purple);
  background: rgba(109, 40, 217, .05);
  transform: scale(1.05);
}

.am-icon-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.am-icon-btn--primary {
  background: linear-gradient(135deg, var(--am-purple), var(--am-blue));
  border-color: transparent;
  color: #fff;
}

.am-icon-btn--primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--am-purple-lt), var(--am-blue-lt));
  color: #fff;
  border-color: transparent;
  transform: scale(1.05);
}

.am-is-recording {
  background: #fee2e2 !important;
  border-color: #fca5a5 !important;
  color: #991b1b !important;
  animation: pulseRecording 1.5s infinite;
}

/* Prevent the floating orb's gradient from being overwritten by the generic toolbar .am-is-recording state */
.am-floating-btn.am-is-recording {
  background: transparent !important;
  border-color: transparent !important;
  color: inherit !important;
  animation: none !important;
  box-shadow: none !important;
}

@keyframes pulseRecording {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, .4);
  }

  70% {
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.am-is-loading {
  opacity: 0.7;
  pointer-events: none;
}

.am-is-loading svg {
  animation: amSpin 1s linear infinite;
}

@keyframes amSpin {
  100% {
    transform: rotate(360deg);
  }
}

/* ── Chat footer toolbar ─────────────────────────────────────────────── */
.am-chat-footer {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding-top: .1rem;
  flex-wrap: wrap;
}

.am-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .78rem;
  font-weight: 600;
  color: var(--am-gray-600);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.am-toggle-label input[type=checkbox] {
  accent-color: var(--am-purple);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.am-footer-select {
  padding: .3rem .5rem;
  border: 1.5px solid var(--am-gray-200);
  border-radius: 7px;
  font-family: var(--am-font);
  font-size: .78rem;
  color: var(--am-gray-800);
  background: #fff;
  outline: none;
  cursor: pointer;
  transition: border-color var(--am-transition);
}

.am-footer-select:focus {
  border-color: var(--am-purple);
}

.am-footer-spacer {
  flex: 1;
}

.am-chat-status {
  font-size: .78rem;
  color: var(--am-gray-600);
  font-style: italic;
  padding: .1rem 0;
}

.am-text-error {
  color: #dc2626 !important;
}

/* ── Notice ──────────────────────────────────────────────────────────── */
.am-notice {
  padding: .8rem 1.1rem;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 500;
  margin-bottom: 1rem;
}

.am-notice--error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

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

/* Global Dynamic Font Tiering (Applies over default and mobile baselines) */
.am-chat-window.am-font-lvl-1 .am-chat-bubble { font-size: 1.15rem !important; }
.am-chat-window.am-font-lvl-2 .am-chat-bubble { font-size: 1.30rem !important; }
.am-chat-window.am-font-lvl-3 .am-chat-bubble { font-size: 1.45rem !important; }

@media (max-width: 600px) {
  /* ── Mobile Fullscreen App UI ── */
  .am-modal__box {
    width: 100% !important;
    max-width: 100% !important;
    height: 100dvh !important; /* Use dynamic viewport height if possible */
    max-height: 100dvh !important;
    border-radius: 0 !important;
    padding: 1rem .9rem .8rem !important;
    margin: 0 !important;
    display: flex;
    flex-direction: column;
  }

  .am-chat-window {
    max-height: none !important;
    height: 100% !important;
    flex: 1 1 auto; /* Take up all available remaining vertical space */
  }

  /* Typography increases for mobile readability */
  .am-chat-bubble {
    font-size: 16px !important;
    line-height: 1.5 !important;
  }
  
  .am-chat-author {
    font-size: 13px !important;
  }

  /* Ensure text inputs have a minimum size of 16px on iOS to prevent auto-zooming */
  .am-chat-input {
    font-size: 16px !important;
  }
  
  /* Fix cutoff dropdowns in onboarding form */
  .am-onboarding-box select {
    font-size: 16px !important; /* Prevents zoom */
    text-overflow: ellipsis;
    padding-right: 32px !important; /* Space for the native dropdown arrow */
    white-space: nowrap;
    overflow: hidden;
  }

  .am-chat-footer {
    gap: .3rem;
    padding-bottom: env(safe-area-inset-bottom); /* Safe area for modern iOS/Android navigation bars */
  }

  .am-footer-select {
    font-size: .72rem;
    padding: .25rem .4rem;
  }
  
  /* Reset pulsing animation box-shadow to be softer when fullscreen */
  body.am-modal-open .am-modal__box {
    animation: none;
    box-shadow: none;
  }

  .am-hide-on-mobile {
    display: none !important;
  }

  /* Hide the small inner mic button, as the floating orb replaces it on mobile */
  .am-icon-btn.am-js-chat-voice-btn {
    display: none !important;
  }
  
  /* Show the statically positioned orb row beneath the input */
  .am-show-on-mobile {
    display: flex !important;
    justify-content: center;
    margin-top: 15px; /* Adds breathing room below the text input */
    margin-bottom: 5px;
  }

  /* When modal is open on mobile, hide the actual fixed floating button to avoid duplicates */
  body.am-modal-open .am-floating-container {
    display: none !important;
  }
}

/* ── Limit Modal ─────────────────────────────────────────────────────── */
.am-limit-modal {
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.am-limit-modal .am-modal-box {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  padding: 2rem;
  max-width: 90%;
  position: relative;
  animation: amModalIn .28s cubic-bezier(.34, 1.56, .64, 1);
}

.am-js-close-limit {
  position: absolute;
  top: 10px;
  right: 15px;
  background: transparent;
  border: none;
  font-size: 24px;
  color: #64748b;
  cursor: pointer;
  line-height: 1;
}

.am-js-close-limit:hover {
  color: #0f172a;
}

/* ── Print Styles ────────────────────────────────────────────────────── */
@media print {
  .am-floating-container,
  #am-modal,
  #am-onboarding-modal {
    display: none !important;
  }
}

/* ── Inline Chat Mode (extras="insert") ──────────────────────────────── */
.am-inline-chat-container {
  width: 100%;
  position: relative;
  z-index: 1;
  margin: 1rem 0;
}

.am-inline-chat-container .am-modal {
  position: relative !important;
  inset: auto !important;
  z-index: 1 !important;
  display: block !important;
  pointer-events: auto !important;
}

.am-inline-chat-container .am-modal__backdrop {
  display: none !important;
}

.am-inline-chat-container .am-modal__box {
  width: 100% !important;
  max-width: 100% !important;
  max-height: 85vh !important; /* Allow some scrolling if it gets too tall */
  box-shadow: none !important;
  transform: none !important;
  animation: none !important;
  border: 1px solid var(--am-gray-200);
  border-radius: var(--am-radius);
  padding: 0;
  margin: 0;
}

/* Padding to compensate removing box padding */
.am-inline-chat-container .am-modal__header {
  padding: 1.25rem 1.25rem 0.5rem;
}
.am-inline-chat-container .am-chat-window {
  margin: 0 1.25rem;
  max-height: 60vh;
}
.am-inline-chat-container .am-chat-input-row,
.am-inline-chat-container .am-chat-footer {
  margin: 0.75rem 1.25rem;
}

/* Hide close button in inline mode */
.am-inline-chat-container .am-js-modal-close {
  display: none !important;
}

/* Remove aura pulses for inline mode */
body.am-modal-open .am-inline-chat-container .am-modal::after {
  display: none !important;
}
body.am-modal-open .am-inline-chat-container .am-modal__box {
  animation: none !important;
  box-shadow: none !important;
}

/* Provide more space in the header for inline if needed */
.am-inline-chat-container .am-modal__header {
  padding-right: 1.25rem; /* removing close button space */
}

/* ── Chart Generation (extras="chart") ───────────────────────────────── */
.am-chat-chart-container {
  width: 100%;
  max-width: 600px;
  background: #ffffff;
  border-radius: 8px;
  padding: 15px;
  margin: 15px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  border: 1px solid var(--am-gray-200);
}

.am-chat-msg--user .am-chat-chart-container {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
}

/* ── UI/UX Enhancements (Chips, Menus, Smart Scroll, Onboarding) ── */

/* Suggestion Chips */
.am-suggestion-chips {
  display: flex;
  gap: 8px;
  padding: 8px 0 12px;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none;  /* IE and Edge */
}
.am-suggestion-chips::-webkit-scrollbar {
  display: none;
}
.am-suggestion-chip {
  background: rgba(109, 40, 217, 0.08);
  border: 1px solid rgba(109, 40, 217, 0.2);
  color: var(--am-purple);
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.am-suggestion-chip:hover {
  background: var(--am-purple);
  color: white;
  transform: translateY(-2px);
}

/* Smart Scroll Button */
.am-smart-scroll-btn {
  position: absolute;
  bottom: 80px; /* Above input row */
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border: 1px solid var(--am-gray-200);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  color: var(--am-purple);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  z-index: 10;
  display: none; /* Controlled by JS */
  transition: all 0.2s;
}
.am-smart-scroll-btn:hover {
  background: #f8fafc;
  transform: translateX(-50%) scale(1.05);
}

/* Tools Dropdown */
.am-tools-dropdown-container {
  position: relative;
  display: inline-block;
}
.am-tools-dropdown-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  background: white;
  border: 1px solid var(--am-gray-200);
  border-radius: 8px;
  box-shadow: 0 -10px 25px rgba(0,0,0,0.1);
  padding: 8px 0;
  min-width: 180px;
  z-index: 50;
  display: none;
  margin-bottom: 8px;
}
.am-tools-dropdown-menu.am-show {
  display: block;
  animation: amFadeInUp 0.2s ease-out forwards;
}
.am-tools-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 16px;
  background: none;
  border: none;
  font-size: 0.85rem;
  color: var(--am-gray-800);
  cursor: pointer;
  transition: background 0.2s;
}
.am-tools-dropdown-item:hover {
  background: #f8fafc;
  color: var(--am-purple);
}

/* Settings Dropdown (Footer) */
.am-settings-dropdown-container {
  position: relative;
  display: inline-block;
}
.am-settings-dropdown-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  background: white;
  border: 1px solid var(--am-gray-200);
  border-radius: 8px;
  box-shadow: 0 -10px 25px rgba(0,0,0,0.1);
  padding: 12px;
  min-width: 200px;
  z-index: 50;
  display: none;
  margin-bottom: 8px;
}
.am-settings-dropdown-menu.am-show {
  display: block;
  animation: amFadeInUp 0.2s ease-out forwards;
}
.am-settings-group {
  margin-bottom: 12px;
}
.am-settings-group:last-child {
  margin-bottom: 0;
}
.am-settings-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--am-gray-600);
  margin-bottom: 4px;
  text-transform: uppercase;
}
.am-settings-dropdown-menu select {
  width: 100%;
}

/* Onboarding Modal Glassmorphism */
.am-onboarding-modal .am-onboarding-box {
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 16px !important;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255,255,255,0.5) inset !important;
  border: none !important;
}
.am-onboarding-modal .am-form-group label {
  color: var(--am-gray-700);
  font-weight: 600;
}
.am-onboarding-modal .am-form-group input,
.am-onboarding-modal .am-form-group select {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 8px !important;
  transition: all 0.3s ease !important;
}
.am-onboarding-modal .am-form-group input:focus,
.am-onboarding-modal .am-form-group select:focus {
  background: #ffffff !important;
  border-color: var(--am-purple) !important;
  box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.1) !important;
  outline: none;
}
.am-onboarding-modal .am-icon-btn--primary {
  background: linear-gradient(135deg, var(--am-purple), var(--am-blue)) !important;
  box-shadow: 0 4px 15px rgba(109, 40, 217, 0.3) !important;
  transition: all 0.3s ease !important;
}
.am-onboarding-modal .am-icon-btn--primary:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 6px 20px rgba(109, 40, 217, 0.4) !important;
}

/* ── Custom Tooltips ── */
.am-custom-tooltip {
  position: fixed;
  z-index: 999999;
  background: #ffffff;
  color: #334155;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  pointer-events: none;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  border: 1px solid #e2e8f0;
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 0.2s, transform 0.2s;
  visibility: hidden;
}
.am-custom-tooltip.am-tooltip-visible {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}