:root {
  --rxm-red: #FF0000;
  --rxm-black: #000000;
  --rxm-white: #FFFFFF;
  --rxm-gray-900: #1A1A1A;
  --rxm-gray-700: #4D4D4D;
  --rxm-gray-500: #808080;
  --rxm-gray-300: #CCCCCC;
  --rxm-gray-200: #E0E0E0;
  --rxm-gray-100: #F2F2F2;
  --rxm-gray-50: #F9F9F9;
  --rxm-green: #16A34A;
  --rxm-yellow: #FFD400;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--rxm-black);
  background: var(--rxm-gray-100);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--rxm-gray-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--rxm-gray-500); }

.layout {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 232px;
  background: var(--rxm-black);
  color: var(--rxm-white);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  flex-shrink: 0;
}

.marca { padding: 4px 8px 22px; }
.marca-logo { height: 26px; display: block; }

.sidebar-usuario {
  margin-top: auto;
  padding: 16px 8px 0;
  border-top: 1px solid var(--rxm-gray-900);
}
#usuario-nombre { font-size: 13px; color: var(--rxm-gray-300); margin-bottom: 8px; }
.link-logout {
  background: none;
  border: none;
  color: var(--rxm-gray-300);
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.marca-x { color: var(--rxm-red); }

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--rxm-gray-300);
  padding: 11px 12px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover:not(.disabled) { background: var(--rxm-gray-900); color: var(--rxm-white); }

.nav-item.activo {
  color: var(--rxm-white);
  background: var(--rxm-red);
}

.nav-item.disabled {
  color: var(--rxm-gray-700);
  cursor: default;
}

.tag {
  font-size: 10px;
  background: var(--rxm-gray-700);
  color: var(--rxm-white);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
}

main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 20px; }

.check-historico {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--rxm-gray-700);
  margin: -12px 0 16px;
  cursor: pointer;
  width: fit-content;
}
.check-historico input { cursor: pointer; }

.tabs-plataforma {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -8px 0 20px;
  border-bottom: 1px solid var(--rxm-gray-100);
  padding-bottom: 12px;
}

.tab-plataforma.tab-proximamente {
  cursor: default;
  opacity: 0.45;
}

.panel-comentarios {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 4px;
}
.comentario-item {
  background: var(--rxm-white);
  border: 1px solid var(--rxm-gray-100);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.comentario-autor { font-weight: 700; font-size: 13px; margin-bottom: 2px; }
.comentario-texto { font-size: 14px; margin-bottom: 6px; }
.comentario-meta { font-size: 11px; color: var(--rxm-gray-500); margin-bottom: 8px; }
.comentario-derivado { color: var(--rxm-green, #1a9c4b); font-weight: 600; }
.comentario-respuesta { font-size: 12.5px; color: var(--rxm-gray-700); font-style: italic; }
.comentario-form { display: flex; gap: 8px; }
.comentario-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--rxm-gray-300);
  border-radius: 6px;
  font-size: 13px;
}
h2 { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; margin: 24px 0 10px; color: var(--rxm-gray-500); }

.card {
  background: var(--rxm-white);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 8px rgba(0, 0, 0, 0.04);
}

/* Chat */
.chat-layout { display: flex; gap: 16px; height: calc(100vh - 68px); }
.contactos {
  width: 300px;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--rxm-white);
  border-radius: 10px;
  padding: 10px 10px 24px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 8px rgba(0, 0, 0, 0.04);
}
.avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--rxm-white);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
}
.avatar-grande { width: 48px; height: 48px; font-size: 15px; }
.avatar-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #25d366;
  border: 2px solid var(--rxm-white);
  display: flex;
  align-items: center;
  justify-content: center;
}
.conversacion {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--rxm-white);
  border-radius: 10px;
  padding: 16px;
  min-width: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 8px rgba(0, 0, 0, 0.04);
}
.mensajes {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  margin: 0 -16px;
  background: var(--rxm-gray-100);
}
/* Ancho completo: el tope del globo lo pone .msg-wrap (max-w-[78%] en el JS),
   así el avatar chico queda pegado a la burbuja y no al borde del panel. */
.msg-fila { display: flex; align-items: flex-end; gap: 6px; width: 100%; }
.avatar-mini { width: 22px; height: 22px; font-size: 9px; flex-shrink: 0; }
.msg.cargando { color: var(--rxm-gray-700); font-style: italic; }
.bot-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 12px 5px 8px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.bot-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.bot-toggle-punto { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.bot-toggle-on { background: rgba(22, 163, 74, 0.12); color: var(--rxm-green); }
.bot-toggle-on .bot-toggle-punto { background: var(--rxm-green); }
.bot-toggle-off { background: var(--rxm-gray-100); color: var(--rxm-gray-700); }
.bot-toggle-off .bot-toggle-punto { background: var(--rxm-gray-500); }

input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--rxm-gray-300);
  width: 100%;
}
textarea { min-height: 140px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--rxm-gray-500); }
button.primario {
  background: var(--rxm-red);
  color: var(--rxm-white);
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.12s ease, transform 0.05s ease;
}
button.primario:hover { filter: brightness(1.08); }
button.primario:active { transform: scale(0.98); }
button.secundario {
  background: var(--rxm-gray-100);
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.12s ease;
}
button.secundario:hover { background: var(--rxm-gray-300); }
#btn-mic, #btn-adjuntar, #btn-emoji { flex-shrink: 0; }
#btn-mic.grabando { background: var(--rxm-red); color: var(--rxm-white); }

.emoji-contenedor { position: relative; flex-shrink: 0; }
.emoji-picker {
  display: none;
  position: absolute;
  bottom: 44px;
  right: 0;
  width: 220px;
  max-height: 180px;
  overflow-y: auto;
  background: var(--rxm-white);
  border: 1px solid var(--rxm-gray-300);
  border-radius: 8px;
  padding: 8px;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10;
}
.emoji-picker.abierto { display: grid; }
.emoji-opcion {
  background: none;
  border: none;
  font-size: 18px;
  padding: 4px;
  cursor: pointer;
  border-radius: 4px;
}
.emoji-opcion:hover { background: var(--rxm-gray-100); }

.msg-adjunto-img { max-width: 240px; max-height: 320px; border-radius: 10px; display: block; }
.msg-adjunto-doc { display: block; margin-bottom: 4px; color: inherit; }
.msg-adjunto-foto {
  padding: 0;
  border: none;
  background: none;
  cursor: zoom-in;
  display: block;
  margin-bottom: 4px;
  border-radius: 10px;
  overflow: hidden;
  transition: filter 0.12s ease;
}
.msg-adjunto-foto:hover { filter: brightness(0.92); }
.msg-adjunto-audio { display: block; width: 260px; max-width: 100%; margin-bottom: 4px; }
.msg-adjunto-video { display: block; max-width: 260px; border-radius: 10px; margin-bottom: 4px; }

/* Visor de fotos a pantalla completa: la idea es que mirar una foto acá sea igual de
   rápido que en el WhatsApp del celular (click, flechas, Escape para cerrar). */
.visor-fotos {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
}
.visor-img {
  max-width: calc(100vw - 160px);
  max-height: calc(100vh - 120px);
  object-fit: contain;
  border-radius: 6px;
}
.visor-cerrar {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  color: var(--rxm-white);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
}
.visor-cerrar:hover { background: rgba(255, 255, 255, 0.15); }
.visor-flecha {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: var(--rxm-white);
  font-size: 40px;
  line-height: 1;
  width: 52px;
  height: 72px;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s ease;
}
.visor-flecha:hover { background: rgba(255, 255, 255, 0.28); }
.visor-pie {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  color: var(--rxm-white);
  font-size: 13px;
}
.visor-descargar { color: var(--rxm-white); font-weight: 600; text-decoration: underline; }

.campo { margin-bottom: 12px; }
.campo label { display: block; font-size: 12px; color: var(--rxm-gray-700); margin-bottom: 4px; }

.tabs {
  display: inline-flex;
  gap: 2px;
  margin-bottom: 18px;
  background: var(--rxm-gray-100);
  padding: 4px;
  border-radius: 9px;
}
.tab {
  padding: 7px 16px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--rxm-gray-700);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.tab:hover:not(.activo) { color: var(--rxm-black); }
.tab.activo { background: var(--rxm-white); color: var(--rxm-black); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }

.vacio { color: var(--rxm-gray-700); font-size: 14px; padding: 40px; text-align: center; }

.campo-check label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--rxm-black); }
.campo-check input { width: auto; }

.switch-activo {
  font-size: 12px;
  font-weight: 400;
  color: var(--rxm-gray-700);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}
.switch-activo input { width: auto; }

.ejemplo-row { display: flex; gap: 8px; margin-bottom: 8px; }
.ejemplo-row input { flex: 1; }
.ejemplo-row button { flex-shrink: 0; }

.dia-row {
  display: grid;
  grid-template-columns: 140px 1fr 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}
.dia-row label { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.dia-row input[type="checkbox"] { width: auto; }

.oculto { display: none; }

.herramienta-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rxm-gray-100);
}
.herramienta-row:last-child { border-bottom: none; }
.herramienta-nombre { font-size: 14px; font-weight: 600; }
.herramienta-detalle { font-size: 12px; color: var(--rxm-gray-700); }
.herramienta-estado { margin-left: auto; font-size: 13px; color: var(--rxm-gray-700); }

.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-verde { background: #16A34A; }
.dot-gris { background: var(--rxm-gray-300); }

.tag-verde { background: #16A34A; color: var(--rxm-white); }
.tag-tipo { background: var(--rxm-black); color: var(--rxm-white); margin-right: 8px; }

.conv-canal { font-size: 12px; color: var(--rxm-gray-700); margin-bottom: 6px; }
.conv-etiquetas { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }

.canal-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  padding: 10px 0;
  border-bottom: 1px solid var(--rxm-gray-100);
}
.canal-row .campo { flex: 1 1 160px; }
.canal-row:last-of-type { border-bottom: none; }
.canal-row .campo { margin-bottom: 0; }
.chip-etapa {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--rxm-gray-300);
  background: var(--rxm-white);
  color: var(--rxm-gray-700);
  cursor: pointer;
  transition: filter 0.12s ease;
}
.chip-etapa[style*="background"]:hover { filter: brightness(0.95); }

.seguimiento-row { padding: 12px 0; border-bottom: 1px solid var(--rxm-gray-100); }
.seguimiento-row:last-child { border-bottom: none; }
.seguimiento-contacto { font-size: 13px; font-weight: 600; }
.seguimiento-contenido { font-size: 14px; margin: 4px 0; }
.seguimiento-fecha { font-size: 12px; color: var(--rxm-gray-700); }

.embudo-layout { display: flex; gap: 12px; align-items: flex-start; }
.embudo-col {
  flex: 1;
  background: var(--rxm-white);
  border-radius: 10px;
  padding: 12px;
  min-width: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 8px rgba(0, 0, 0, 0.04);
}
.embudo-col h2 { margin-top: 0; }
.embudo-card {
  background: var(--rxm-gray-100);
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  margin-bottom: 8px;
  transition: box-shadow 0.12s ease;
}
.embudo-card:hover { box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1); }

.metricas-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat-card {
  background: var(--rxm-white);
  border-radius: 10px;
  padding: 18px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 8px rgba(0, 0, 0, 0.04);
}
.stat-numero { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.stat-label { font-size: 12px; color: var(--rxm-gray-700); margin-top: 4px; }

.banners-avisos {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
}
.banner-aviso {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--rxm-red);
  color: var(--rxm-white);
  padding: 10px 12px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}
.banner-icono { font-size: 18px; flex-shrink: 0; }
.banner-texto { flex: 1; min-width: 0; }
.banner-titulo { font-size: 10px; font-weight: 700; letter-spacing: 0.03em; opacity: 0.9; }
.banner-nombre { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.banner-recordar {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: var(--rxm-white);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}
.banner-recordar:hover { background: rgba(255, 255, 255, 0.32); }
.banner-cerrar {
  background: none;
  border: none;
  color: var(--rxm-white);
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0.8;
  padding: 2px 4px;
}
.banner-cerrar:hover { opacity: 1; }
