/* MarketAtlas Chatbot widget v1.1 — dinámico + tipografía compacta */
.ma-chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--ma-green, #166534);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(22, 101, 52, 0.35), 0 2px 8px rgba(0,0,0,0.12);
  transition: transform .25s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow .25s ease,
              background .2s ease;
  animation: ma-chat-pulse 2.6s ease-in-out infinite;
}
@keyframes ma-chat-pulse {
  0%, 100% { box-shadow: 0 6px 24px rgba(22, 101, 52, 0.35), 0 2px 8px rgba(0,0,0,0.12), 0 0 0 0 rgba(22, 101, 52, 0.4); }
  50%      { box-shadow: 0 6px 24px rgba(22, 101, 52, 0.4),  0 2px 8px rgba(0,0,0,0.12), 0 0 0 14px rgba(22, 101, 52, 0); }
}
.ma-chat-toggle:hover {
  transform: translateY(-3px) scale(1.08) rotate(-5deg);
  box-shadow: 0 12px 32px rgba(22, 101, 52, 0.5);
  animation: none;
}
.ma-chat-toggle.is-open {
  animation: none;
  background: #1F1B14;
  transform: rotate(180deg);
}
.ma-chat-toggle.is-open:hover { transform: rotate(180deg) scale(1.05); }
.ma-chat-toggle:focus-visible { outline: 3px solid #B45309; outline-offset: 3px; }
.ma-chat-toggle__close { display: none; }
.ma-chat-toggle.is-open .ma-chat-toggle__open { display: none; }
.ma-chat-toggle.is-open .ma-chat-toggle__close { display: inline; }

.ma-chat-panel {
  position: fixed;
  bottom: 96px; right: 24px;
  z-index: 9001;
  width: 360px; max-width: calc(100vw - 32px);
  height: 540px; max-height: calc(100vh - 140px);
  background: #FAF7F2;
  border: 1px solid #E5E7EB;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.20), 0 8px 24px rgba(0,0,0,0.08);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Lato', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  color: #374151;
  transform-origin: bottom right;
  opacity: 0;
  transform: scale(0.9) translateY(10px);
  transition: opacity .25s ease, transform .3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ma-chat-panel.is-open {
  display: flex;
  animation: ma-chat-panel-in .35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes ma-chat-panel-in {
  from { opacity: 0; transform: scale(0.85) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.ma-chat-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #166534 0%, #14532D 100%);
  color: #fff;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  position: relative;
  overflow: hidden;
}
.ma-chat-header::before {
  content: '';
  position: absolute;
  top: -50%; right: -10%;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 60%);
  pointer-events: none;
  animation: ma-chat-header-shine 8s ease-in-out infinite;
}
@keyframes ma-chat-header-shine {
  0%, 100% { transform: translate(0, 0); }
  50%      { transform: translate(-20px, 15px); }
}
.ma-chat-header__title {
  font-weight: 700;
  font-size: 14px;
  margin: 0;
  letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 8px;
}
.ma-chat-header__title::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  background: #4ADE80;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.8);
  animation: ma-chat-online 2s ease-in-out infinite;
}
@keyframes ma-chat-online {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.6; transform: scale(0.85); }
}
.ma-chat-header__sub {
  font-size: 10px;
  opacity: 0.85;
  margin: 2px 0 0;
}
.ma-chat-header__close {
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
  transition: background .15s ease, transform .15s ease;
}
.ma-chat-header__close:hover { background: rgba(255,255,255,0.15); transform: rotate(90deg); }

.ma-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.ma-chat-messages::-webkit-scrollbar { width: 6px; }
.ma-chat-messages::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 3px; }
.ma-chat-messages::-webkit-scrollbar-thumb:hover { background: #9CA3AF; }

.ma-chat-msg {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  font-size: 13px;
  animation: ma-chat-msg-in .3s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}
@keyframes ma-chat-msg-in {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.ma-chat-msg--bot {
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.ma-chat-msg--user {
  background: linear-gradient(135deg, #DCFCE7 0%, #BBF7D0 100%);
  color: #14532D;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(22, 101, 52, 0.08);
}
.ma-chat-msg a { color: #166534; text-decoration: underline; transition: color .15s ease; }
.ma-chat-msg a:hover { color: #14532D; }
.ma-chat-msg em { color: #B45309; font-style: normal; font-weight: 600; }

.ma-chat-card {
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  border-left: 3px solid #166534;
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 6px;
  transition: transform .2s ease, box-shadow .2s ease, border-left-color .2s ease;
}
.ma-chat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.ma-chat-card--term { border-left-color: #B45309; }
.ma-chat-card--term:hover { border-left-color: #92400E; }
.ma-chat-card__title {
  font-weight: 700;
  color: #111827;
  margin: 0 0 5px;
  font-size: 13px;
}
.ma-chat-card__body {
  font-size: 12px;
  color: #374151;
  margin: 0;
  line-height: 1.5;
}
.ma-chat-card__meta {
  font-size: 10px;
  color: #6B7280;
  margin-top: 6px;
  letter-spacing: 0.02em;
}
.ma-chat-card__link {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #166534;
  text-decoration: none;
  transition: transform .15s ease;
}
.ma-chat-card__link:hover {
  text-decoration: underline;
  transform: translateX(3px);
}

.ma-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}
.ma-chat-suggestion {
  background: #F3F4F6;
  border: 1px solid #E5E7EB;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 11px;
  color: #374151;
  cursor: pointer;
  transition: all .18s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: inherit;
  animation: ma-chat-msg-in .35s ease backwards;
}
.ma-chat-suggestion:nth-child(1) { animation-delay: .05s; }
.ma-chat-suggestion:nth-child(2) { animation-delay: .12s; }
.ma-chat-suggestion:nth-child(3) { animation-delay: .19s; }
.ma-chat-suggestion:nth-child(4) { animation-delay: .26s; }
.ma-chat-suggestion:hover {
  background: #166534;
  color: #fff;
  border-color: #166534;
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 4px 12px rgba(22, 101, 52, 0.25);
}

.ma-chat-typing {
  align-self: flex-start;
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  border-radius: 14px;
  padding: 10px 14px;
  display: inline-flex;
  gap: 4px;
  animation: ma-chat-msg-in .25s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.ma-chat-typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #166534;
  animation: ma-chat-bounce 1.2s infinite ease-in-out;
}
.ma-chat-typing span:nth-child(2) { animation-delay: .15s; }
.ma-chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes ma-chat-bounce {
  0%, 60%, 100% { transform: translateY(0) scale(0.85); opacity: .4; }
  30%           { transform: translateY(-6px) scale(1); opacity: 1; }
}

.ma-chat-form {
  display: flex;
  gap: 8px;
  padding: 11px;
  background: #FFFFFF;
  border-top: 1px solid #E5E7EB;
}
.ma-chat-input {
  flex: 1;
  border: 1px solid #D1D5DB;
  border-radius: 22px;
  padding: 9px 14px;
  font: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.ma-chat-input:focus {
  border-color: #166534;
  box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.12);
}
.ma-chat-input::placeholder { color: #9CA3AF; }
.ma-chat-send {
  background: linear-gradient(135deg, #166534 0%, #14532D 100%);
  border: none;
  color: #fff;
  width: 40px; height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow .15s ease;
}
.ma-chat-send:hover:not(:disabled) {
  transform: scale(1.1) rotate(-15deg);
  box-shadow: 0 4px 12px rgba(22, 101, 52, 0.35);
}
.ma-chat-send:active:not(:disabled) { transform: scale(0.95); }
.ma-chat-send:disabled {
  background: #9CA3AF;
  cursor: not-allowed;
  transform: none;
}

.ma-chat-footer {
  padding: 5px 14px 8px;
  background: #FFFFFF;
  font-size: 9px;
  color: #9CA3AF;
  text-align: center;
  border-top: 1px solid #F3F4F6;
  letter-spacing: 0.02em;
}

@media (max-width: 480px) {
  .ma-chat-toggle { bottom: 16px; right: 16px; width: 52px; height: 52px; font-size: 22px; }
  .ma-chat-panel {
    bottom: 0; right: 0; left: 0;
    width: 100%; max-width: 100%;
    height: 100vh; max-height: 100vh;
    border-radius: 14px 14px 0 0;
    transform-origin: bottom center;
  }
  @keyframes ma-chat-panel-in {
    from { opacity: 0; transform: translateY(40px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}
