/* REDIMED · Asistente IA (Redy)
   Componente autónomo: se activa o desactiva desde window.REDIMED_ASSISTANT_CONFIG.
   No depende de Tailwind ni de brand.css. */

:root {
  --ra-navy: #011d3c;
  --ra-teal: #02666a;
  --ra-gold: #c4a708;
  --ra-paper: #f5f8f8;
  --ra-line: rgba(78, 104, 99, 0.18);
  --ra-sage: #4e6863;
}

.ra-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 70;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  height: 58px;
  padding: 0 1.1rem 0 0.55rem;
  border: 0;
  border-radius: 9999px;
  background: var(--ra-navy);
  color: #fff;
  font: 600 0.8rem/1 "Open Sans", system-ui, sans-serif;
  box-shadow: 0 18px 40px -18px rgba(1, 29, 60, 0.75);
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.ra-launcher:hover { transform: translateY(-2px); box-shadow: 0 24px 48px -20px rgba(1, 29, 60, 0.8); }
.ra-launcher:focus-visible { outline: 3px solid var(--ra-gold); outline-offset: 3px; }
.ra-launcher img { width: 34px; height: 34px; display: block; }
.ra-launcher-dot {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 10px;
  height: 10px;
  border-radius: 9999px;
  background: #34c38f;
  border: 2px solid var(--ra-navy);
}
.ra-launcher--hidden { display: none; }

.ra-panel {
  position: fixed;
  right: 20px;
  bottom: 92px;
  z-index: 71;
  display: flex;
  flex-direction: column;
  width: min(384px, calc(100vw - 32px));
  height: min(580px, calc(100vh - 140px));
  background: #fff;
  border: 1px solid var(--ra-line);
  border-radius: 20px;
  box-shadow: 0 40px 80px -30px rgba(1, 29, 60, 0.55);
  overflow: hidden;
  opacity: 0;
  transform: translateY(10px) scale(0.985);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.26s cubic-bezier(0.22, 0.7, 0.2, 1);
}
.ra-panel.is-open { opacity: 1; transform: none; pointer-events: auto; }

.ra-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.85rem 0.9rem 0.85rem 1rem;
  background: var(--ra-navy);
  color: #fff;
}
.ra-head img { width: 40px; height: 40px; flex: none; }
.ra-head-name { font: 700 0.95rem/1.2 "Montserrat", system-ui, sans-serif; letter-spacing: -0.01em; }
.ra-head-status {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.2rem;
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.62);
}
.ra-head-status i { width: 6px; height: 6px; border-radius: 9999px; background: #34c38f; display: inline-block; }
.ra-close {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
}
.ra-close:hover { background: rgba(255, 255, 255, 0.16); }
.ra-close:focus-visible { outline: 2px solid var(--ra-gold); outline-offset: 2px; }

.ra-body {
  flex: 1;
  min-height: 180px;
  overflow-y: auto;
  padding: 1rem;
  background: var(--ra-paper);
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.ra-msg {
  max-width: 88%;
  padding: 0.7rem 0.85rem;
  border-radius: 14px;
  font-size: 0.8rem;
  line-height: 1.55;
}
.ra-msg--bot { background: #fff; border: 1px solid var(--ra-line); color: var(--ra-navy); border-bottom-left-radius: 5px; }
.ra-msg--user { align-self: flex-end; background: var(--ra-navy); color: #fff; border-bottom-right-radius: 5px; }
.ra-msg strong { font-weight: 700; }

.ra-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.ra-chip {
  border: 1px solid rgba(2, 102, 106, 0.28);
  background: #fff;
  color: var(--ra-teal);
  border-radius: 9999px;
  padding: 0.4rem 0.7rem;
  font: 600 0.7rem/1.2 "Open Sans", system-ui, sans-serif;
  cursor: pointer;
  text-align: left;
}
.ra-chip:hover { background: rgba(2, 102, 106, 0.06); border-color: var(--ra-teal); }
.ra-chip:focus-visible { outline: 2px solid var(--ra-gold); outline-offset: 2px; }

.ra-results { display: flex; flex-direction: column; gap: 0.5rem; }
.ra-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem;
  background: #fff;
  border: 1px solid var(--ra-line);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.ra-card:hover { border-color: rgba(2, 102, 106, 0.4); transform: translateY(-1px); }
.ra-card:focus-visible { outline: 2px solid var(--ra-gold); outline-offset: 2px; }
.ra-card img {
  width: 46px;
  height: 46px;
  flex: none;
  object-fit: contain;
  border-radius: 8px;
  background: var(--ra-paper);
}
.ra-card-name { font-size: 0.75rem; font-weight: 700; color: var(--ra-navy); line-height: 1.35; }
.ra-card-spec { font-size: 0.66rem; color: var(--ra-sage); margin-top: 0.1rem; }
.ra-card-price { font-size: 0.72rem; font-weight: 700; color: var(--ra-navy); margin-top: 0.15rem; }
.ra-card-price span { font-weight: 500; color: var(--ra-sage); }

.ra-foot { border-top: 1px solid var(--ra-line); padding: 0.6rem 0.7rem 0.55rem; background: #fff; }
.ra-form { display: flex; align-items: center; gap: 0.4rem; }
.ra-input {
  flex: 1;
  min-width: 0;
  height: 40px;
  border: 1px solid rgba(78, 104, 99, 0.28);
  border-radius: 11px;
  padding: 0 0.7rem;
  font: 400 0.78rem/1 "Open Sans", system-ui, sans-serif;
  color: var(--ra-navy);
}
.ra-input::placeholder { color: rgba(78, 104, 99, 0.65); }
.ra-input:focus { outline: none; border-color: var(--ra-teal); box-shadow: 0 0 0 3px rgba(2, 102, 106, 0.13); }
.ra-send {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 11px;
  background: var(--ra-teal);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.ra-send:hover { background: var(--ra-navy); }
.ra-send:focus-visible { outline: 2px solid var(--ra-gold); outline-offset: 2px; }
.ra-note {
  margin: 0.45rem 0 0;
  font-size: 0.62rem;
  color: rgba(78, 104, 99, 0.85);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.ra-note a { color: var(--ra-teal); font-weight: 600; text-decoration: none; }
.ra-note a:hover { text-decoration: underline; }

.ra-typing { display: inline-flex; gap: 3px; padding: 0.15rem 0; }
.ra-typing i {
  width: 5px;
  height: 5px;
  border-radius: 9999px;
  background: rgba(78, 104, 99, 0.55);
  animation: ra-bounce 1s infinite ease-in-out;
}
.ra-typing i:nth-child(2) { animation-delay: 0.15s; }
.ra-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes ra-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.55; }
  30% { transform: translateY(-3px); opacity: 1; }
}

@media (max-width: 480px) {
  .ra-launcher { right: 12px; bottom: 12px; }
  .ra-panel { right: 12px; left: 12px; bottom: 82px; width: auto; height: calc(100vh - 110px); max-height: 620px; }
  .ra-launcher-label { display: none; }
  .ra-launcher { padding: 0 0.65rem; }
}

@media (prefers-reduced-motion: reduce) {
  .ra-panel, .ra-launcher { transition: none; }
  .ra-typing i { animation: none; }
}
