/* ============================================================
   BRASA & SAL — chat.css (Fase 2)
   Ventana de chat centrada, estilo app de mensajería.
   Móvil-first: <600px a pantalla casi completa.
   ============================================================ */

/* ---------- Overlay ---------- */
.mc-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(23, 18, 15, 0.65);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 200ms ease;
}

.mc-overlay.is-open { opacity: 1; }

/* ---------- Panel ---------- */
.mc-panel {
  --mc-ancho: min(420px, 100%);
  width: var(--mc-ancho);
  max-width: 420px;
  height: 80vh;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--crema, #F4E9D8);
  color: var(--carbon, #17120F);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.45);
  transform: scale(0.96);
  opacity: 0;
  transition: transform 200ms ease, opacity 200ms ease;
  outline: none;
}

.mc-overlay.is-open .mc-panel { transform: scale(1); opacity: 1; }

/* ---------- Cabecera ---------- */
.mc-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--ceniza, #2A221D);
  color: var(--crema, #F4E9D8);
  flex: 0 0 auto;
}

.mc-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--brasa, #E4572E);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.mc-avatar svg { width: 24px; height: 24px; }

.mc-id { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }

.mc-title {
  font-family: var(--fuente-titulo, 'Fraunces', serif);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mc-status {
  margin: 0;
  font-size: 0.75rem;
  color: rgba(244, 233, 216, 0.75);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.mc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--salvia, #7A8B6F);
  box-shadow: 0 0 0 3px rgba(122, 139, 111, 0.25);
}

.mc-close {
  margin-left: auto;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--crema, #F4E9D8);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 150ms ease;
}
.mc-close:hover { background: rgba(244, 233, 216, 0.14); }

/* ---------- Cuerpo (crema con grano sutil) ---------- */
.mc-body {
  position: relative;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  background-color: var(--crema, #F4E9D8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}

.mc-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1rem 0.9rem 0.75rem;
}
.mc-list:focus-visible { outline: 2px solid var(--brasa, #E4572E); outline-offset: -2px; }

/* ---------- Burbujas ---------- */
.mc-row { display: flex; }
.mc-row--bot  { justify-content: flex-start; }
.mc-row--user { justify-content: flex-end; }

.mc-bubble {
  max-width: 82%;
  padding: 0.55rem 0.75rem 0.35rem;
  font-size: 0.94rem;
  line-height: 1.45;
  border-radius: 14px;
  word-wrap: break-word;
}

.mc-row--bot .mc-bubble {
  background: #FFFBF4;                 /* blanco cálido */
  border: 1px solid rgba(42, 34, 29, 0.10); /* --ceniza al 10% */
  color: var(--carbon, #17120F);
  border-bottom-left-radius: 4px;
}

.mc-row--user .mc-bubble {
  background: var(--brasa, #E4572E);
  color: var(--crema, #F4E9D8);
  border-bottom-right-radius: 4px;
}

/* Agrupación: el emisor consecutivo pierde la "cola" y se pega */
.mc-row--grouped .mc-bubble { border-radius: 14px; }
.mc-row--bot.mc-row--grouped  { margin-top: -0.2rem; }
.mc-row--user.mc-row--grouped { margin-top: -0.2rem; }

.mc-time {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.66rem;
  letter-spacing: 0.02em;
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
}

/* ---------- Indicador "escribiendo…" ---------- */
.mc-typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 0.6rem 0.8rem;
  background: #FFFBF4;
  border: 1px solid rgba(42, 34, 29, 0.10);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: max-content;
}

.mc-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--carbon, #17120F);
  opacity: 0.35;
  animation: mc-pulse 1.2s infinite ease-in-out;
}
.mc-typing span:nth-child(2) { animation-delay: 0.2s; }
.mc-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes mc-pulse {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.3; }
  30%           { transform: translateY(-4px); opacity: 0.85; }
}

/* ---------- Respuestas rápidas (chips) ---------- */
.mc-quick {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.6rem 0.9rem;
  background: var(--crema, #F4E9D8);
  border-top: 1px solid rgba(23, 18, 15, 0.08);
}
.mc-quick[hidden] { display: none; }

.mc-chip {
  font-family: var(--fuente-texto, 'DM Sans', sans-serif);
  font-size: 0.85rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1.5px solid var(--brasa, #E4572E);
  background: transparent;
  color: var(--carbon, #17120F);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, transform 120ms ease;
}
.mc-chip:hover { background: var(--brasa, #E4572E); color: var(--crema, #F4E9D8); }
.mc-chip:active { transform: scale(0.97); }

/* ---------- Pie / composer ---------- */
.mc-composer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0.9rem calc(0.7rem + env(safe-area-inset-bottom, 0px));
  background: #FFFBF4;
  border-top: 1px solid rgba(23, 18, 15, 0.10);
}

.mc-input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--fuente-texto, 'DM Sans', sans-serif);
  font-size: 0.95rem;
  padding: 0.6rem 0.85rem;
  border-radius: 999px;
  border: 1.5px solid rgba(42, 34, 29, 0.2);
  background: var(--crema, #F4E9D8);
  color: var(--carbon, #17120F);
}
.mc-input::placeholder { color: rgba(23, 18, 15, 0.5); }
.mc-input:focus-visible {
  outline: none;
  border-color: var(--brasa, #E4572E);
  box-shadow: 0 0 0 3px rgba(228, 87, 46, 0.22);
}

.mc-send {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--brasa, #E4572E);
  color: var(--crema, #F4E9D8);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 150ms ease, opacity 150ms ease, transform 120ms ease;
}
.mc-send svg { width: 20px; height: 20px; }
.mc-send:hover:not(:disabled) { background: #F0683F; }
.mc-send:active:not(:disabled) { transform: scale(0.94); }
.mc-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Foco visible accesible ---------- */
.mc-panel :focus-visible {
  outline: 2px solid var(--brasa, #E4572E);
  outline-offset: 2px;
}
.mc-head :focus-visible { outline-color: var(--ocre, #D9A441); }

/* ---------- Utilidades ---------- */
.mc-sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

body.mc-lock { overflow: hidden; }

/* ============================================================
   MÓVIL (<600px): 100% ancho, ~92% alto, esquinas superiores
   redondeadas, apoyado en la base.
   ============================================================ */
@media (max-width: 599.98px) {
  .mc-overlay { padding: 0; align-items: flex-end; }
  .mc-panel {
    width: 100%;
    max-width: 100%;
    height: 92vh;
    max-height: 92vh;
    border-radius: 22px 22px 0 0;
  }
}

/* ============================================================
   MOVIMIENTO REDUCIDO
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .mc-overlay,
  .mc-panel,
  .mc-chip,
  .mc-send,
  .mc-close { transition: none !important; }
  .mc-typing span { animation: none !important; opacity: 0.7; }
}

/* ============================================================
   FASE 3 — Componentes del flujo de reserva
   (mc-card, mc-busy, mc-chip--inline, mc-field, mc-btn)
   ============================================================ */

/* ---------- Chips inline (dentro de tarjetas, no en el rail) ---------- */
.mc-chip--inline {
  font-family: var(--fuente-texto, 'DM Sans', sans-serif);
  font-size: 0.82rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1.5px solid var(--brasa, #E4572E);
  background: transparent;
  color: var(--carbon, #17120F);
  cursor: pointer;
  white-space: nowrap;
  transition: background 150ms ease, color 150ms ease, transform 120ms ease;
}
.mc-chip--inline:hover { background: var(--brasa, #E4572E); color: var(--crema, #F4E9D8); }
.mc-chip--inline:active { transform: scale(0.97); }
.mc-chip--inline:focus-visible {
  outline: 2px solid var(--brasa, #E4572E);
  outline-offset: 2px;
}

/* ---------- Contenedor de chips dentro de una tarjeta ---------- */
.mc-card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

/* ---------- Tarjetas (mc-card) ---------- */
.mc-bubble .mc-card,
.mc-card {
  background: #FFFBF4;
  border: 1px solid rgba(42, 34, 29, 0.14);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font-size: 0.92rem;
  color: var(--carbon, #17120F);
  width: 100%;
  box-sizing: border-box;
}

/* Título de tarjeta */
.mc-card-title {
  font-family: var(--fuente-titulo, 'Fraunces', serif);
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.6rem;
  color: var(--carbon, #17120F);
}

/* Lista de datos (clave–valor) dentro de la tarjeta */
.mc-card-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.mc-card-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.88rem;
  border-bottom: 1px solid rgba(42, 34, 29, 0.06);
  padding-bottom: 0.3rem;
}
.mc-card-list li:last-child { border-bottom: none; padding-bottom: 0; }
.mc-card-list li span { color: rgba(23, 18, 15, 0.6); flex-shrink: 0; }
.mc-card-list li strong { text-align: right; word-break: break-word; }

/* Nota al pie de tarjeta */
.mc-card-note {
  font-size: 0.78rem;
  color: rgba(23, 18, 15, 0.55);
  margin: 0.6rem 0 0;
}

/* Código de reserva */
.mc-code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.88rem;
  background: rgba(42, 34, 29, 0.07);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  display: inline-block;
  margin: 0.4rem 0 0.5rem;
  letter-spacing: 0.05em;
}

/* Variante OK (reserva confirmada) */
.mc-card--ok {
  border-color: var(--salvia, #7A8B6F);
  background: #F4F8F2;
}
.mc-card--ok .mc-card-title { color: #4A7040; }

/* Variante error */
.mc-card--error {
  border-color: var(--brasa, #E4572E);
  background: #FDF3F0;
}
.mc-card--error .mc-card-title { color: var(--brasa, #E4572E); }

/* Variante resumen */
.mc-card--summary {
  border-color: var(--ocre, #D9A441);
  background: #FDFAF3;
}

/* ---------- Burbuja transparente para tarjetas (sin fondo doble) ---------- */
.mc-row--bot .mc-bubble:has(.mc-card) {
  background: transparent;
  border: none;
  padding: 0;
}
/* Fallback para navegadores sin :has() */
.mc-bubble--card {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
}

/* ---------- Spinner de ocupado (mc-busy) ---------- */
.mc-busy {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-start;
  padding: 0.5rem 0.9rem 0.75rem;
}
.mc-busy[hidden] { display: none; }

.mc-busy span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brasa, #E4572E);
  opacity: 0.4;
  animation: mc-busy-pulse 1.2s infinite ease-in-out;
}
.mc-busy span:nth-child(2) { animation-delay: 0.2s; }
.mc-busy span:nth-child(3) { animation-delay: 0.4s; }

@keyframes mc-busy-pulse {
  0%, 60%, 100% { transform: scale(1);    opacity: 0.35; }
  30%           { transform: scale(1.35); opacity: 1; }
}

/* ---------- Campo de fecha embebido en el chat (mc-field) ---------- */
.mc-field-wrap {
  background: #FFFBF4;
  border: 1px solid rgba(42, 34, 29, 0.14);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.mc-field-label {
  font-size: 0.88rem;
  font-weight: 500;
  color: rgba(23, 18, 15, 0.7);
}

.mc-field-input {
  font-family: var(--fuente-texto, 'DM Sans', sans-serif);
  font-size: 0.95rem;
  padding: 0.55rem 0.8rem;
  border: 1.5px solid rgba(42, 34, 29, 0.22);
  border-radius: 8px;
  background: var(--crema, #F4E9D8);
  color: var(--carbon, #17120F);
  width: 100%;
  box-sizing: border-box;
}
.mc-field-input:focus-visible {
  outline: none;
  border-color: var(--brasa, #E4572E);
  box-shadow: 0 0 0 3px rgba(228, 87, 46, 0.2);
}

.mc-field-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ---------- Botones reutilizables (mc-btn) ---------- */
.mc-btn {
  font-family: var(--fuente-texto, 'DM Sans', sans-serif);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.45rem 1rem;
  border-radius: 8px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, transform 120ms ease;
  white-space: nowrap;
}
.mc-btn:active { transform: scale(0.97); }
.mc-btn:focus-visible { outline: 2px solid var(--brasa, #E4572E); outline-offset: 2px; }

.mc-btn--primary {
  background: var(--brasa, #E4572E);
  color: var(--crema, #F4E9D8);
  border-color: var(--brasa, #E4572E);
}
.mc-btn--primary:hover { background: #F0683F; border-color: #F0683F; }

.mc-btn--ghost {
  background: transparent;
  color: var(--carbon, #17120F);
  border-color: rgba(42, 34, 29, 0.25);
}
.mc-btn--ghost:hover { background: rgba(42, 34, 29, 0.06); }

/* ---------- Movimiento reducido: anular animaciones nuevas ---------- */
@media (prefers-reduced-motion: reduce) {
  .mc-busy span { animation: none !important; opacity: 0.6; }
}
