/* ============================================================
   CHATBOT "ASESOR VIRTUAL" — botón flotante + ventana de chat
   Compatible con PC y celulares. Tema dark.
   ============================================================ */
#rey-root * { box-sizing: border-box; }

/* ── FAB Button ── */
.rey-fab {
  position: fixed;
  bottom: calc(var(--rey-banner-offset, 0px) + 12px);
  right: 12px;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  background: #0b0f19;
  color: #fff;
  border: 2px solid var(--gold, #d4a853);
  border-radius: 50%;
  width: 60px;
  height: 60px;
  padding: 0;
  font-family: inherit;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  transition: width 0.35s ease, border-radius 0.35s ease, gap 0.35s ease, padding 0.35s ease, box-shadow 0.35s ease, transform 0.35s ease;
}

.rey-fab:hover {
  width: 340px;
  border-radius: 999px;
  gap: 10px;
  padding: 0 20px 0 10px;
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(212, 168, 83, 0.4);
}

.rey-fab .rey-fab-icon {
  line-height: 1;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rey-fab-logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: contain;
  background: #0b0f19;
  padding: 2px;
}

.rey-fab .rey-fab-txt {
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  transition: opacity 0.3s ease 0.1s, max-width 0.35s ease;
}

.rey-fab:hover .rey-fab-txt {
  opacity: 1;
  max-width: 280px;
}

/* ── Widget (chat window) ── */
.rey-widget {
  position: fixed;
  bottom: calc(var(--rey-banner-offset, 0px) + 84px);
  right: 12px;
  width: 360px;
  height: min(560px, calc(100vh - 130px));
  background: #0b0f19;
  border: 1px solid rgba(212, 168, 83, 0.2);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9998;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.rey-widget.open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* ── Header ── */
.rey-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #0d1a3a, #0b0f19);
  color: #fff;
  border-bottom: 1px solid rgba(212, 168, 83, 0.15);
}

.rey-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #1a1a2e;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
  flex-shrink: 0;
  overflow: hidden;
  border: 2px solid rgba(212, 168, 83, 0.3);
}

.rey-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
}

.rey-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
  font-family: 'Playfair Display', serif;
  letter-spacing: 0.3px;
}

.rey-header .rey-online {
  font-size: 11px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 5px;
  color: rgba(255,255,255,0.7);
}

.rey-header .rey-online::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
}

.rey-header-info {
  flex: 1;
  min-width: 0;
}

.rey-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
}

.rey-min,
.rey-clear {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #fff;
  opacity: 0.7;
  padding: 4px;
  line-height: 1;
  border-radius: 6px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.rey-min { font-size: 20px; padding: 2px 7px; }
.rey-clear { font-size: 15px; }

.rey-min:hover,
.rey-clear:hover {
  opacity: 1;
  transform: scale(1.15);
}

/* ── Messages area ── */
.rey-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #0b0f19;
}

.rey-msg {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.rey-msg.bot {
  align-self: flex-start;
  background: #1a1f2e;
  color: #e0e0e0;
  border: 1px solid rgba(212, 168, 83, 0.12);
  border-bottom-left-radius: 4px;
}

.rey-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--gold, #d4a853), #c49a3c);
  color: #0b0f19;
  border-bottom-right-radius: 4px;
  font-weight: 600;
}

/* ── Chips ── */
.rey-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 8px 12px;
  background: #0d1220;
  border-top: 1px solid rgba(212, 168, 83, 0.1);
  overflow-x: auto;
  overflow-y: hidden;
  max-height: 46px;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 168, 83, 0.3) transparent;
  -webkit-overflow-scrolling: touch;
}

.rey-chips::-webkit-scrollbar { height: 5px; }
.rey-chips::-webkit-scrollbar-thumb { background: rgba(212, 168, 83, 0.3); border-radius: 999px; }
.rey-chips::-webkit-scrollbar-track { background: transparent; }

.rey-chip {
  flex-shrink: 0;
  white-space: nowrap;
  border: 1px solid rgba(212, 168, 83, 0.25);
  background: #1a1f2e;
  color: #d4d4d4;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  line-height: 1.5;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.rey-chip:hover {
  background: var(--gold, #d4a853);
  border-color: var(--gold, #d4a853);
  color: #0b0f19;
  font-weight: 700;
}

/* ── Input row ── */
.rey-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(212, 168, 83, 0.1);
  background: #0d1220;
}

.rey-input-row input {
  flex: 1;
  border: 1px solid rgba(212, 168, 83, 0.2);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14px;
  background: #1a1f2e;
  color: #e0e0e0;
  outline: none;
  font-family: inherit;
  min-width: 0;
}

.rey-input-row input::placeholder { color: rgba(255,255,255,0.35); }
.rey-input-row input:focus { border-color: var(--gold, #d4a853); }

.rey-send {
  border: none;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  background: var(--gold, #d4a853);
  color: #0b0f19;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.rey-send:hover { transform: scale(1.08); }

/* ── Typing indicator ── */
.rey-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.rey-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(212, 168, 83, 0.5);
  animation: reyBlink 1.2s infinite;
}

.rey-typing span:nth-child(2) { animation-delay: 0.2s; }
.rey-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes reyBlink {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

/* ── Car cards ── */
.rey-car-card {
  align-self: flex-start;
  width: 100%;
  background: #1a1f2e;
  border: 1px solid rgba(212, 168, 83, 0.12);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  gap: 12px;
  padding: 10px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.rey-car-card:hover {
  border-color: var(--gold, #d4a853);
  transform: translateY(-2px);
}

.rey-car-card img {
  width: 92px;
  height: 66px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.rey-car-info { min-width: 0; flex: 1; }
.rey-car-info .rc-name { font-weight: 800; font-size: 14px; color: #e0e0e0; }
.rey-car-info .rc-meta { font-size: 12px; color: rgba(255,255,255,0.45); margin: 2px 0; }
.rey-car-info .rc-price { font-weight: 800; font-size: 15px; color: var(--gold, #d4a853); margin-top: 2px; }

/* ── Result boxes ── */
.rey-result-box {
  align-self: flex-start;
  width: 100%;
  background: #1a1f2e;
  border: 1px solid rgba(212, 168, 83, 0.12);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13.5px;
  color: #e0e0e0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rey-result-box .rl { display: flex; justify-content: space-between; gap: 10px; }
.rey-result-box .rl b { color: rgba(255,255,255,0.45); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.3px; }
.rey-result-box .rv { font-weight: 700; color: #e0e0e0; text-align: right; }
.rey-result-box .rv.gold { color: var(--gold, #d4a853); font-weight: 800; }

/* ── Links ── */
.rey-link {
  color: var(--gold, #d4a853);
  font-weight: 700;
  text-decoration: none;
  font-size: 13.5px;
}

.rey-link:hover { text-decoration: underline; }

/* ── Car lines ── */
.rey-car-line {
  padding: 6px 0;
  border-bottom: 1px dashed rgba(212, 168, 83, 0.1);
  font-size: 14px;
}
.rey-car-line:last-child { border-bottom: none; }
.rey-car-name {
  color: var(--gold, #d4a853);
  font-weight: 700;
  text-decoration: none;
}
.rey-car-name:hover { text-decoration: underline; }
.rey-car-meta { color: rgba(255,255,255,0.45); font-size: 12px; }

/* ── Comparison ── */
.rey-cmp-box {
  align-self: flex-start;
  width: 100%;
  background: #1a1f2e;
  border: 1px solid rgba(212, 168, 83, 0.12);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13px;
  color: #e0e0e0;
}

.rey-cmp-box .rc-title {
  font-weight: 900;
  font-size: 13.5px;
  margin-bottom: 8px;
  color: #e0e0e0;
}

.rey-cmp {
  width: 100%;
  border-collapse: collapse;
}

.rey-cmp th,
.rey-cmp td {
  padding: 6px;
  border-bottom: 1px dashed rgba(212, 168, 83, 0.08);
  text-align: left;
  vertical-align: top;
}

.rey-cmp th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: rgba(255,255,255,0.4);
}

.rey-cmp td.rc-lbl {
  color: rgba(255,255,255,0.45);
  font-size: 11.5px;
  white-space: nowrap;
}

.rey-cmp td.rc-val {
  font-weight: 700;
  color: #e0e0e0;
}

.rey-cmp td.rc-win {
  color: var(--gold, #d4a853);
  font-weight: 800;
}

.rey-cmp-box .rc-verdict {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(212, 168, 83, 0.15);
  font-size: 12.5px;
  color: #e0e0e0;
}

/* ── Mobile ── */
@media (max-width: 480px) {
  .rey-fab {
    bottom: calc(var(--rey-banner-offset, 0px) + 10px);
    right: 10px;
    width: 54px;
    height: 54px;
  }
  .rey-fab:hover {
    width: 280px;
    padding: 0 16px 0 8px;
  }
  .rey-fab-logo { width: 32px; height: 32px; }
  .rey-fab .rey-fab-txt { font-size: 11px; }
  .rey-widget {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }
  .rey-header {
    padding: 12px 12px;
    gap: 10px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }
  .rey-header h3 {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .rey-header .rey-online { font-size: 10px; }
  .rey-avatar { width: 36px; height: 36px; font-size: 17px; }
  .rey-avatar-img { width: 100%; height: 100%; }
  .rey-messages { padding: 10px; gap: 8px; }
  .rey-msg { max-width: 92%; font-size: 13.5px; padding: 9px 12px; }
  .rey-chips {
    flex-wrap: wrap;
    max-height: none;
    padding: 6px 10px;
    gap: 5px;
  }
  .rey-chip { font-size: 11.5px; padding: 4px 9px; }
  .rey-input-row {
    padding: 8px 10px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    gap: 6px;
  }
  .rey-input-row input { padding: 9px 12px; font-size: 16px; }
  .rey-send { width: 38px; height: 38px; font-size: 15px; }
  .rey-cmp-box { font-size: 12px; padding: 10px; }
  .rey-cmp th, .rey-cmp td { padding: 4px; font-size: 11px; }
  .rey-car-line { font-size: 13px; }
  .rey-result-box { font-size: 12.5px; padding: 10px; }
  .rey-car-card { padding: 8px; gap: 8px; }
  .rey-car-card img { width: 72px; height: 52px; }
  .rey-car-info .rc-name { font-size: 13px; }
  .rey-car-info .rc-price { font-size: 13px; }
}
