/* Mangora Chat: verde MANGORA (#072f26) y plata, como el resto de la plataforma. */
:root {
  --verde: #072f26;
  --verde-2: #0d4a3c;
  --acento: #1f9d6f;
  --fondo: #f5f5f7;
  --panel: #ffffff;
  --linea: #e3e3e8;
  --texto: #1d1d1f;
  --suave: #6e6e73;
  --mio: #d9f2e6;
  --suyo: #ffffff;
  --peligro: #c62828;
  --fondo-chat: #eceef1;
  --sombra: 0 1px 2px rgba(0, 0, 0, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #0b0f0e;
    --panel: #151a19;
    --linea: #262d2b;
    --texto: #f2f2f2;
    --suave: #9aa3a0;
    --mio: #0f4a3a;
    --suyo: #1d2422;
    --fondo-chat: #0e1312;
    --sombra: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--texto);
  background: var(--fondo);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ entrar */
body.entrar {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 24px 16px;
  background: var(--verde);
}
.tarjeta {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border-radius: 20px;
  padding: 32px 24px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  text-align: center;
}
.tarjeta .logo { border-radius: 18px; }
.tarjeta h1 { margin: 12px 0 2px; font-size: 26px; letter-spacing: -.02em; }
.sub { margin: 0 0 24px; color: var(--suave); }
.tarjeta form { display: grid; gap: 10px; text-align: left; }
.tarjeta label { font-weight: 600; font-size: 13px; color: var(--suave); }
.tarjeta input {
  width: 100%;
  border: 1px solid var(--linea);
  background: var(--fondo);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 17px;
  outline: none;
}
.tarjeta input:focus { border-color: var(--acento); box-shadow: 0 0 0 3px rgba(31, 157, 111, .2); }
#codigo { letter-spacing: .5em; text-align: center; font-size: 24px; font-variant-numeric: tabular-nums; }
.prefijo { display: flex; align-items: stretch; }
.prefijo span {
  display: grid; place-items: center;
  padding: 0 12px;
  border: 1px solid var(--linea); border-right: 0;
  border-radius: 12px 0 0 12px;
  background: var(--linea);
  color: var(--suave);
  font-weight: 600;
}
.prefijo input { border-radius: 0 12px 12px 0; }
.primario {
  margin-top: 6px;
  border: 0;
  border-radius: 12px;
  padding: 13px;
  background: var(--verde);
  color: #fff;
  font-weight: 600;
  font-size: 16px;
}
.primario:disabled { opacity: .6; cursor: wait; }
.fila { display: flex; justify-content: space-between; }
.enlace { border: 0; background: none; color: var(--acento); padding: 6px 0; font-weight: 600; }
.enlace:disabled { color: var(--suave); cursor: default; font-weight: 400; }
.nota { margin: 0; color: var(--suave); font-size: 14px; }
.ayuda { margin: -4px 0 0; font-size: 13px; color: var(--suave); }
.ayuda.bien { color: var(--acento); }
.ayuda.mal, .error { color: var(--peligro); }
.error { min-height: 1.2em; margin: 12px 0 0; font-size: 14px; }
.pie { margin: 16px 0 0; font-size: 12px; color: var(--suave); }

/* --------------------------------------------------------------- app */
body.app { overflow: hidden; }
.marco {
  display: grid;
  grid-template-columns: minmax(300px, 400px) 1fr;
  height: 100dvh;
  max-width: 1500px;
  margin: 0 auto;
  background: var(--panel);
}
.lado { display: flex; flex-direction: column; border-right: 1px solid var(--linea); min-height: 0; }
.barra {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--verde);
  color: #fff;
  min-height: 58px;
}
.marca { flex: 1; font-size: 17px; letter-spacing: -.01em; }
.icono {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border: 0; border-radius: 50%;
  background: transparent;
  color: inherit;
  flex: none;
}
.icono:hover { background: rgba(255, 255, 255, .12); }
.avatar-boton { border: 0; padding: 0; background: none; border-radius: 50%; }
.avatar {
  display: grid; place-items: center;
  flex: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: #c7d3cf center / cover no-repeat;
  color: var(--verde);
  font-weight: 700;
  font-size: 16px;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.chico { width: 36px; height: 36px; font-size: 14px; }
.avatar.grande { width: 96px; height: 96px; font-size: 34px; margin: 0 auto; }
.buscar-lista { padding: 8px 12px; border-bottom: 1px solid var(--linea); }
.buscar-lista input, .campo {
  width: 100%;
  border: 0;
  background: var(--fondo);
  border-radius: 10px;
  padding: 9px 12px;
  outline: none;
}
.permiso {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 12px;
  background: #fff8e1;
  color: #5d4300;
  font-size: 13px;
}
.permiso button { border: 0; border-radius: 8px; padding: 6px 10px; background: var(--verde); color: #fff; }
.lista { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.lista li {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--linea);
}
.lista li:hover { background: var(--fondo); }
.lista li.activo { background: var(--fondo); box-shadow: inset 3px 0 var(--acento); }
.lista .medio { flex: 1; min-width: 0; }
.lista .arriba, .lista .abajo { display: flex; gap: 8px; align-items: baseline; }
.lista .nombre { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lista .hora { font-size: 12px; color: var(--suave); flex: none; }
.lista .vista { flex: 1; color: var(--suave); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lista .contador {
  flex: none;
  min-width: 20px; height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--acento);
  color: #fff;
  font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
}
.lista li.sin-leer .hora { color: var(--acento); font-weight: 600; }
.vacio { padding: 24px; text-align: center; color: var(--suave); }

.conversacion { display: flex; flex-direction: column; min-height: 0; background: var(--fondo-chat); position: relative; }
.bienvenida {
  margin: auto;
  text-align: center;
  color: var(--suave);
}
.bienvenida img { border-radius: 24px; opacity: .9; }
.bienvenida h2 { color: var(--texto); margin: 12px 0 4px; }
.titulo-chat {
  flex: 1;
  display: flex; align-items: center; gap: 10px;
  border: 0; background: none; color: #fff;
  text-align: left;
  min-width: 0;
  padding: 0;
}
.titulo-chat .t { display: grid; min-width: 0; }
.titulo-chat strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titulo-chat small { opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.volver { font-size: 30px; line-height: 1; display: none; }

.mensajes {
  flex: 1;
  overflow-y: auto;
  padding: 12px 6% 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overscroll-behavior: contain;
}
.dia {
  align-self: center;
  margin: 10px 0 6px;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--panel);
  color: var(--suave);
  font-size: 12px;
  box-shadow: var(--sombra);
}
.burbuja {
  max-width: min(75%, 560px);
  padding: 6px 9px 4px;
  border-radius: 12px;
  background: var(--suyo);
  box-shadow: var(--sombra);
  align-self: flex-start;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  margin-top: 6px;
}
.burbuja.seguida { margin-top: 0; }
.burbuja.mia { align-self: flex-end; background: var(--mio); }
.burbuja .autor { display: block; font-size: 13px; font-weight: 700; color: var(--acento); white-space: nowrap; }
.burbuja .meta {
  float: right;
  margin: 6px 0 -2px 10px;
  font-size: 11px;
  color: var(--suave);
  white-space: nowrap;
}
.burbuja .meta .check { margin-left: 3px; letter-spacing: -3px; }
.burbuja .meta .check.leido { color: #2b8cff; }
.burbuja .meta .check.pendiente { letter-spacing: 0; }
.burbuja.fallo { outline: 1px solid var(--peligro); }
.burbuja img.foto {
  display: block;
  max-width: 100%;
  width: 320px;
  max-height: 420px;
  object-fit: cover;
  border-radius: 8px;
  margin: 0 0 2px;
  background: var(--linea);
  cursor: zoom-in;
}
.burbuja audio { display: block; width: 260px; max-width: 100%; height: 40px; }
.aviso-chat {
  align-self: center;
  margin: 8px 0;
  padding: 4px 12px;
  border-radius: 8px;
  background: rgba(7, 47, 38, .08);
  color: var(--suave);
  font-size: 13px;
  text-align: center;
}
.cargar-mas { align-self: center; border: 0; background: var(--panel); border-radius: 14px; padding: 6px 14px; margin: 6px; color: var(--acento); }

.escribir, .grabando {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 8px 10px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--fondo);
  border-top: 1px solid var(--linea);
}
.escribir .icono, .grabando .icono { color: var(--suave); }
.escribir .icono:hover, .grabando .icono:hover { background: var(--linea); }
.escribir .enviar, .grabando .enviar { background: var(--verde); color: #fff; }
.escribir .enviar:hover, .grabando .enviar:hover { background: var(--verde-2); }
.adjuntar { cursor: pointer; }
#texto {
  flex: 1;
  resize: none;
  max-height: 140px;
  border: 0;
  border-radius: 20px;
  padding: 10px 14px;
  background: var(--panel);
  outline: none;
  line-height: 1.35;
}
.grabando { align-items: center; }
.grabando #tiempo-audio { flex: 1; font-variant-numeric: tabular-nums; }
.punto { width: 10px; height: 10px; border-radius: 50%; background: var(--peligro); animation: latido 1s infinite; }
@keyframes latido { 50% { opacity: .2; } }

/* ------------------------------------------------------------ dialogos */
dialog {
  border: 0;
  border-radius: 16px;
  padding: 0;
  width: min(440px, calc(100vw - 32px));
  max-height: min(640px, calc(100dvh - 32px));
  background: var(--panel);
  color: var(--texto);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dlg { display: flex; flex-direction: column; max-height: inherit; }
.dlg header { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--linea); }
.dlg header h3 { flex: 1; margin: 0; font-size: 17px; }
.dlg header .icono { color: var(--suave); }
.dlg .cuerpo { padding: 14px 16px; overflow-y: auto; display: grid; gap: 10px; }
.dlg .pie-dlg { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--linea); }
.boton { border: 0; border-radius: 10px; padding: 9px 14px; background: var(--fondo); font-weight: 600; }
.boton.verde { background: var(--verde); color: #fff; }
.boton.rojo { background: none; color: var(--peligro); }
.boton:disabled { opacity: .5; cursor: default; }
.personas { list-style: none; margin: 0; padding: 0; }
.personas li { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-radius: 10px; }
.personas li.tocable { cursor: pointer; }
.personas li.tocable:hover { background: var(--fondo); }
.personas .medio { flex: 1; min-width: 0; display: grid; }
.personas .medio small { color: var(--suave); }
.personas .rol { font-size: 12px; color: var(--acento); font-weight: 600; }
.personas .acciones { display: flex; gap: 4px; }
.personas .acciones button { border: 0; background: none; color: var(--suave); font-size: 13px; padding: 4px 6px; border-radius: 6px; }
.personas .acciones button:hover { background: var(--fondo); color: var(--texto); }
.elegidos { display: flex; flex-wrap: wrap; gap: 6px; }
.elegidos span { background: var(--mio); border-radius: 14px; padding: 4px 10px; font-size: 13px; cursor: pointer; }
.perfil { text-align: center; display: grid; gap: 8px; }
.perfil small { color: var(--suave); }
.etiqueta { font-size: 13px; font-weight: 600; color: var(--suave); }
.visor { background: #000; display: grid; place-items: center; }
.visor img { max-width: 100%; max-height: calc(100dvh - 120px); display: block; }

.aviso {
  position: fixed;
  left: 50%; bottom: 90px;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: #1d1d1f;
  color: #fff;
  font-size: 14px;
  z-index: 10;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .3);
}

/* ------------------------------------------------------------ celular */
@media (max-width: 760px) {
  .marco { grid-template-columns: 1fr; }
  .conversacion { display: none; }
  .marco.en-chat .lado { display: none; }
  .marco.en-chat .conversacion { display: flex; }
  .volver { display: grid; }
  .mensajes { padding: 10px 10px 6px; }
  .burbuja { max-width: 85%; }
  .burbuja img.foto { width: 240px; }
}
