/* ============================================================
   M&M Autopartes — Demo del asistente virtual
   Paleta inspirada en mmautopartes.com.ar (azul + cyan + blanco)
   con acentos cálidos para CTAs.
   ============================================================ */

:root {
  /* Paleta M&M */
  --brand: #1c4d8a;
  --brand-deep: #103260;
  --brand-light: #3F88C5;
  --brand-soft: #d6e6f5;
  --brand-bg: #f4f7fb;
  --accent: #ec5b3a;          /* Rojo Moura suave para CTAs */
  --accent-deep: #c4422a;
  --success: #2cb67d;
  --warning: #f5b400;

  /* Neutrales */
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-soft: #f0f4f9;
  --border: #d8e2ed;
  --border-light: #e9eef5;
  --text: #0f1e33;
  --text-soft: #506678;
  --text-faint: #8a99a8;

  /* Burbujas */
  --bot: #ffffff;
  --bot-border: #d8e2ed;
  --user: var(--brand);
  --user-text: #ffffff;

  --shadow: 0 1px 2px rgba(15, 30, 51, 0.04), 0 4px 16px rgba(15, 30, 51, 0.06);
  --shadow-soft: 0 1px 3px rgba(15, 30, 51, 0.05);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-bubble: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Layout principal — desktop con sidebars, mobile single column */
.layout {
  display: grid;
  grid-template-columns: 1fr;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  min-height: 100dvh;
}

@media (min-width: 1024px) {
  .layout {
    grid-template-columns: 280px minmax(0, 1fr) 280px;
    gap: 20px;
    padding: 20px;
  }
}

/* ============================================================
   COLUMNA CENTRAL — el chat
   ============================================================ */

.chat-shell {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  min-height: 100dvh;
  border: 1px solid var(--border);
}

@media (min-width: 1024px) {
  .chat-shell {
    border-radius: 18px;
    overflow: hidden;
    min-height: calc(100dvh - 40px);
    box-shadow: var(--shadow);
  }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
  color: white;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar__avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: var(--brand);
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.topbar__titles { min-width: 0; line-height: 1.2; }

.topbar__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__subtitle {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 5px;
}

.topbar__status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.85);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.12);
  padding: 5px 10px;
  border-radius: 999px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(44, 182, 125, 0.25);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(44, 182, 125, 0.25); }
  50% { box-shadow: 0 0 0 6px rgba(44, 182, 125, 0.1); }
}

.disclaimer {
  background: #fff8e1;
  border-bottom: 1px solid #f3deaf;
  padding: 9px 18px;
  font-size: 12px;
  color: #6e5614;
  line-height: 1.45;
}

.disclaimer strong { color: #5b4509; font-weight: 600; }

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  background:
    linear-gradient(180deg, var(--brand-bg) 0%, transparent 200px),
    var(--surface);
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  gap: 3px;
  animation: fade-in 0.22s ease-out both;
}

.message--user { align-self: flex-end; align-items: flex-end; }
.message--bot { align-self: flex-start; align-items: flex-start; }

.message__bubble {
  padding: 9px 14px;
  border-radius: var(--radius-bubble);
  line-height: 1.5;
  font-size: 14.5px;
  word-wrap: break-word;
  box-shadow: var(--shadow-soft);
}

.message--user .message__bubble {
  background: var(--user);
  color: var(--user-text);
  border-bottom-right-radius: 6px;
}

.message--bot .message__bubble {
  background: var(--bot);
  border: 1px solid var(--bot-border);
  border-bottom-left-radius: 6px;
  color: var(--text);
}

.message__bubble p { margin: 0 0 4px; }
.message__bubble p:last-child { margin-bottom: 0; }

.message__bubble code {
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 12.5px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  padding: 1px 6px;
  border-radius: 5px;
  font-weight: 500;
}

.message--user .message__bubble code {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.message__bubble strong { font-weight: 600; }

.message__time {
  font-size: 10.5px;
  color: var(--text-faint);
  padding: 0 4px;
}

/* Typing indicator */
.typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 11px 18px !important;
}

.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand-light);
  opacity: 0.5;
  animation: typing-bounce 1.2s infinite ease-in-out both;
}

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

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 0.95; }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Composer */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  bottom: 0;
}

.composer__input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  background: var(--surface);
  color: var(--text);
  max-height: 120px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer__input:focus {
  border-color: var(--brand-light);
  box-shadow: 0 0 0 3px rgba(63, 136, 197, 0.15);
}

.composer__input::placeholder { color: var(--text-faint); }

.composer__send {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(28, 77, 138, 0.25);
}

.composer__send:hover:not(:disabled) { background: var(--brand-deep); }
.composer__send:active:not(:disabled) { transform: scale(0.94); }
.composer__send:disabled { background: #aebac6; cursor: not-allowed; box-shadow: none; }

.error {
  background: #fde8e8 !important;
  border: 1px solid #f5b5b5 !important;
  color: #8a1f1f !important;
}

/* ============================================================
   SIDEBARS — desktop only
   ============================================================ */

.sidebar {
  display: none;
}

@media (min-width: 1024px) {
  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-self: start;
    position: sticky;
    top: 20px;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

.card__title {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card__title-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
}

/* Card vendedor */
.vendedor {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.vendedor__avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-light), var(--brand));
  color: white;
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--success);
  position: relative;
}

.vendedor__info { min-width: 0; }
.vendedor__name { font-weight: 600; font-size: 14.5px; margin: 0 0 2px; line-height: 1.2; }
.vendedor__role { font-size: 12px; color: var(--text-soft); margin: 0; }
.vendedor__online {
  font-size: 11.5px;
  color: var(--success);
  margin: 4px 0 0;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}

/* Badges */
.badges { display: flex; flex-direction: column; gap: 8px; }
.badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--brand-soft);
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--brand-deep);
}
.badge__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: var(--brand);
}
.badge--accent {
  background: rgba(236, 91, 58, 0.08);
  color: var(--accent-deep);
}
.badge--accent .badge__icon { fill: var(--accent); }

/* Marcas grid */
.marcas {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.marca {
  background: var(--brand-bg);
  border: 1px solid var(--border-light);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  color: var(--text-soft);
  text-align: center;
  font-weight: 500;
}

/* Stats card */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-light);
}
.stat-row:last-child { border-bottom: none; }
.stat-row__label { font-size: 12px; color: var(--text-soft); }
.stat-row__value { font-size: 16px; font-weight: 600; color: var(--brand-deep); font-variant-numeric: tabular-nums; }

/* Más vendido */
.top-pieza {
  background: linear-gradient(135deg, #fff7f2 0%, #fff 100%);
  border: 1px solid #fdd5c5;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  margin-top: 8px;
}
.top-pieza__label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--accent-deep); font-weight: 600; margin-bottom: 3px; }
.top-pieza__name { font-weight: 600; color: var(--text); }
.top-pieza__sub { font-size: 11.5px; color: var(--text-soft); margin-top: 2px; }

/* Footer info */
.location {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.5;
}
.location svg { flex-shrink: 0; margin-top: 2px; fill: var(--brand); }
.location strong { color: var(--text); display: block; font-weight: 600; font-size: 13px; }

/* CTA card */
.cta-card {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
  color: white;
  border: 0;
}
.cta-card .card__title { color: rgba(255,255,255,0.65); }
.cta-card__text { font-size: 13.5px; line-height: 1.5; margin: 0 0 8px; }
.cta-card__highlight { font-weight: 600; }

/* Subtle "powered by" */
.powered {
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
  padding: 10px 0;
}
.powered strong { color: var(--brand); font-weight: 600; }

/* Mobile fixes */
@media (max-width: 1023px) {
  .chat-shell { border: none; border-radius: 0; }
  body { background: var(--surface); }
}

@media (max-width: 480px) {
  .chat { padding: 14px; }
  .composer { padding: 10px 12px 12px; }
  .topbar { padding: 12px 14px; }
  .disclaimer { padding: 9px 14px; font-size: 11.5px; }
}
