/* Asistente conversacional — design system "Cápsula · Oscuro Elegante" */

.ai-open {
  position: fixed;
  bottom: 22px;
  right: 22px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #0E0C0A;
  color: #C9A961;
  border: 1px solid rgba(201, 169, 97, 0.45);
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  z-index: 998;
  transition: transform 0.18s, box-shadow 0.18s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ai-open:hover { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(0,0,0,0.45); }
.ai-open[hidden] { display: none !important; }

.ai-overlay {
  position: fixed; inset: 0;
  background: rgba(14, 12, 10, 0.55);
  z-index: 999;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.ai-overlay.is-open { opacity: 1; pointer-events: auto; }

.ai-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(440px, 100vw);
  background: #1C1815;
  color: #F2EBE0;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  display: flex; flex-direction: column;
  box-shadow: -10px 0 36px rgba(0, 0, 0, 0.45);
  border-left: 1px solid rgba(201, 169, 97, 0.25);
  transform: translateX(100%);
  transition: transform 0.24s ease;
  z-index: 1000;
}
.ai-panel.is-open { transform: translateX(0); }

.ai-head {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(201, 169, 97, 0.22);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #0E0C0A;
}
.ai-head__title {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 1.05rem; color: #F2EBE0; letter-spacing: 0.01em;
}
.ai-head__title small {
  display: block; font-family: 'Inter', sans-serif;
  font-size: 0.72rem; letter-spacing: 0.06em; color: #A89B89;
  text-transform: uppercase; margin-top: 2px;
}
.ai-head__actions { display: flex; gap: 4px; }
.ai-head__btn {
  background: transparent; color: #A89B89; border: 0;
  padding: 6px 10px; border-radius: 6px; cursor: pointer;
  font-size: 13px; font-family: inherit; transition: color 0.12s, background 0.12s;
}
.ai-head__btn:hover { color: #C9A961; background: rgba(201, 169, 97, 0.08); }
.ai-head__btn--close { font-size: 18px; line-height: 1; padding: 4px 10px; }

.ai-body {
  flex: 1; overflow-y: auto;
  padding: 18px 20px 14px;
  display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
}
.ai-body::-webkit-scrollbar { width: 6px; }
.ai-body::-webkit-scrollbar-thumb { background: rgba(201, 169, 97, 0.30); border-radius: 4px; }

.ai-empty {
  text-align: center; color: #A89B89;
  padding: 32px 12px; font-size: 13px; line-height: 1.6;
  font-family: 'Newsreader', Georgia, serif; font-style: italic;
}
.ai-empty strong { color: #C9A961; font-style: normal; }

.ai-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 10px;
  line-height: 1.55;
  font-size: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.ai-msg--user {
  background: rgba(201, 169, 97, 0.16);
  color: #F2EBE0;
  align-self: flex-end;
  border-top-right-radius: 3px;
}
.ai-msg--assistant {
  background: #0E0C0A;
  color: #F2EBE0;
  align-self: flex-start;
  border-top-left-radius: 3px;
  border: 1px solid rgba(201, 169, 97, 0.16);
}

.ai-action {
  align-self: flex-start;
  background: #0E0C0A;
  border: 1px solid rgba(201, 169, 97, 0.30);
  border-left: 3px solid #C9A961;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12.5px;
  max-width: 92%;
}
.ai-action__name {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: #C9A961; margin-bottom: 6px;
}
.ai-action__items {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 4px;
}
.ai-action__item {
  display: flex; gap: 10px; padding: 6px 8px;
  border-radius: 6px;
  background: rgba(201, 169, 97, 0.04);
  text-decoration: none; color: #F2EBE0;
  transition: background 0.12s;
  font-size: 12.5px; line-height: 1.4;
}
.ai-action__item:hover { background: rgba(201, 169, 97, 0.12); color: #C9A961; }
.ai-action__item-meta { color: #A89B89; font-size: 11px; }

.ai-action__link {
  display: inline-block; margin-top: 6px;
  color: #C9A961; text-decoration: none;
  font-size: 12px; font-weight: 600;
}
.ai-action__link:hover { text-decoration: underline; }

.ai-action__error {
  color: #F87171; font-size: 12px; margin-top: 4px;
}

.ai-typing {
  align-self: flex-start; padding: 10px 14px;
  background: #0E0C0A;
  border: 1px solid rgba(201, 169, 97, 0.16);
  border-radius: 10px;
  border-top-left-radius: 3px;
  color: #A89B89; font-size: 13px; font-style: italic;
}
.ai-typing::after {
  content: '·'; animation: aiDots 1s infinite steps(4); margin-left: 2px;
}
@keyframes aiDots {
  0% { content: '·'; }
  25% { content: '··'; }
  50% { content: '···'; }
  75% { content: '····'; }
}

.ai-foot {
  border-top: 1px solid rgba(201, 169, 97, 0.22);
  padding: 12px 16px;
  background: #0E0C0A;
  display: flex; gap: 8px; align-items: flex-end;
}
.ai-foot textarea {
  flex: 1; resize: none;
  background: #1C1815; color: #F2EBE0;
  border: 1px solid rgba(201, 169, 97, 0.30);
  border-radius: 8px; padding: 10px 12px;
  font-family: inherit; font-size: 14px; line-height: 1.5;
  outline: none; min-height: 44px; max-height: 140px;
  transition: border-color 0.12s;
}
.ai-foot textarea:focus { border-color: #C9A961; }
.ai-foot__send {
  background: #C9A961; color: #0E0C0A; border: 0;
  border-radius: 8px; padding: 10px 16px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: opacity 0.12s, transform 0.08s;
}
.ai-foot__send:hover:not(:disabled) { transform: translateY(-1px); }
.ai-foot__send:disabled { opacity: 0.5; cursor: wait; }
.ai-foot__hint {
  font-size: 11px; color: #A89B89;
  padding: 4px 16px 12px;
  background: #0E0C0A;
  border-top: 1px solid rgba(201, 169, 97, 0.10);
}

@media (max-width: 600px) {
  .ai-panel { width: 100vw; }
  .ai-open { bottom: 16px; right: 16px; width: 50px; height: 50px; }
}
