/* Liberty — widget de chat IA. Usa los tokens del tema (tokens.css debe
   cargar antes). Carbón + dorado, coherente con header/footer. */

.liberty-chat {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: 9999;
  font-family: var(--font-body);
}

.liberty-chat-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-pill);
  background: var(--color-charcoal);
  color: var(--color-ivory);
  border: 1px solid var(--color-gold-line-dark);
  box-shadow: var(--shadow-dark-md);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}

.liberty-chat-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.55);
}

.liberty-chat-toggle svg {
  width: 26px;
  height: 26px;
}

.liberty-chat-toggle .liberty-chat-icon-close {
  display: none;
}

.liberty-chat[data-open="true"] .liberty-chat-icon-open {
  display: none;
}

.liberty-chat[data-open="true"] .liberty-chat-icon-close {
  display: block;
}

.liberty-chat-panel {
  position: absolute;
  right: 0;
  bottom: 68px;
  width: min(380px, calc(100vw - 2 * var(--container-pad)));
  height: min(560px, calc(100vh - 140px));
  background: var(--color-paper-card);
  border: var(--hairline-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease);
}

.liberty-chat[data-open="true"] .liberty-chat-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.liberty-chat-header {
  background: var(--color-charcoal);
  color: var(--color-ivory);
  padding: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-bottom: 1px solid var(--color-gold-line-dark);
}

.liberty-chat-header-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.2;
}

.liberty-chat-header-subtitle {
  font-size: var(--text-xs);
  color: var(--color-ivory-muted);
  margin-top: 2px;
}

.liberty-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: var(--color-paper);
}

.liberty-chat-msg {
  max-width: 86%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  word-wrap: break-word;
}

.liberty-chat-msg p {
  margin: 0 0 var(--space-2);
}

.liberty-chat-msg p:last-child {
  margin-bottom: 0;
}

.liberty-chat-msg ul {
  margin: var(--space-2) 0;
  padding-left: 1.1em;
}

.liberty-chat-msg a {
  color: var(--color-gold-deep);
  text-decoration: underline;
}

.liberty-chat-msg--user {
  align-self: flex-end;
  background: var(--color-charcoal);
  color: var(--color-ivory);
  border-bottom-right-radius: var(--radius-sm);
}

.liberty-chat-msg--assistant {
  align-self: flex-start;
  background: var(--color-paper-card);
  color: var(--color-ink);
  border: var(--hairline-soft);
  border-bottom-left-radius: var(--radius-sm);
}

.liberty-chat-msg--assistant a {
  color: var(--color-gold-deep);
}

.liberty-chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: var(--space-3) var(--space-4);
}

.liberty-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-ink-faint);
  animation: liberty-chat-bounce 1.2s infinite ease-in-out;
}

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

@keyframes liberty-chat-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.liberty-chat-whatsapp {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: calc(-1 * var(--space-2));
  padding: var(--space-2) var(--space-4);
  background: transparent;
  color: var(--color-gold-deep);
  border: 1px solid var(--color-gold-line-light);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease);
}

.liberty-chat-whatsapp:hover {
  background: var(--color-gold-line-light);
}

.liberty-chat-form {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3);
  border-top: var(--hairline-soft);
  background: var(--color-paper-card);
}

.liberty-chat-input {
  flex: 1;
  resize: none;
  border: var(--hairline-soft);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-ink);
  background: var(--color-paper);
  max-height: 90px;
}

.liberty-chat-input:focus {
  outline: none;
  border-color: var(--color-gold-deep);
}

.liberty-chat-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--color-charcoal);
  color: var(--color-ivory);
  border: none;
  cursor: pointer;
  transition: opacity var(--duration-fast) var(--ease);
}

.liberty-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.liberty-chat-send svg {
  width: 18px;
  height: 18px;
}

.liberty-chat-disclaimer {
  font-size: 10px;
  color: var(--color-ink-faint);
  text-align: center;
  padding: 0 var(--space-3) var(--space-2);
  background: var(--color-paper-card);
}

@media (max-width: 480px) {
  .liberty-chat {
    right: var(--space-3);
    bottom: var(--space-3);
  }
  .liberty-chat-panel {
    width: calc(100vw - 2 * var(--space-3));
    height: min(70vh, 560px);
  }
}
