/* Wuasalo — hoja de estilos única (sin frameworks, como el guasalo: sobrio) */
:root {
  --fondo: #14161a;
  --panel: #1d2026;
  --panel-2: #262a32;
  --borde: #333945;
  --texto: #e8e9ec;
  --texto-suave: #9aa0ac;
  --acento: #2fa376;
  --acento-osc: #25825e;
  --rosa: #e77d9e;
  --peligro: #d05b5b;
  --radio: 14px;
  --sombra: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font: 15px/1.45 system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none; /* evita el "tirón" de recarga en móviles */
}
#app {
  height: 100vh; /* respaldo para navegadores sin dvh */
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* Las pantallas de formulario se centran cuando caben y se desplazan cuando no */
#app:has(> .caja-form) { overflow-y: auto; }
a { color: var(--acento); text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* ---- arranque ---- */
.arranque { margin: auto; text-align: center; color: var(--texto-suave); }

/* ---- formularios ---- */
.caja-form {
  width: min(400px, 92vw);
  margin: auto;
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 28px;
}
.caja-form .logo { display: block; margin: 0 auto 8px; }
.caja-form h1 { text-align: center; font-size: 26px; margin: 0 0 2px; }
.caja-form .eslogan { text-align: center; color: var(--texto-suave); margin: 0 0 18px; font-size: 13px; }
label { display: block; margin: 12px 0 4px; color: var(--texto-suave); font-size: 13px; }
input[type="text"], input[type="password"], input[type="datetime-local"], textarea, select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--borde);
  color: var(--texto);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--acento); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--acento); color: #fff; border: 0; border-radius: 10px;
  padding: 11px 16px; font-weight: 600; width: 100%; margin-top: 16px;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.secundario { background: var(--panel-2); color: var(--texto); border: 1px solid var(--borde); }
.btn.peligro { background: var(--peligro); }
.btn.mini { width: auto; margin: 0; padding: 7px 12px; font-size: 13px; }
.form-pie { text-align: center; margin-top: 14px; font-size: 14px; color: var(--texto-suave); }
.nota { color: var(--texto-suave); font-size: 12.5px; margin: 8px 0 0; }
.error-msg { color: #ff9c9c; background: rgba(208, 91, 91, 0.12); border: 1px solid rgba(208, 91, 91, 0.4);
  border-radius: 8px; padding: 8px 10px; margin-top: 10px; font-size: 13.5px; display: none; }
.error-msg.visible { display: block; }

/* ---- barra superior ---- */
.barra {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border-bottom: 1px solid var(--borde);
  padding: 10px 14px; min-height: 56px; flex-shrink: 0;
}
.barra img { width: 34px; height: 34px; }
.barra .titulo { font-weight: 700; font-size: 17px; }
.barra .sub { color: var(--texto-suave); font-size: 12px; }
.barra .espacio { flex: 1; }
.barra button.icono {
  background: none; border: 0; color: var(--texto); font-size: 20px; padding: 6px 8px; border-radius: 8px;
}
.barra button.icono:hover { background: var(--panel-2); }

/* ---- lista de chats ---- */
.lista-scroll { flex: 1; overflow-y: auto; }
.chat-item {
  display: flex; gap: 12px; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid rgba(51, 57, 69, 0.5);
  cursor: pointer; user-select: none;
}
.chat-item:hover { background: var(--panel); }
.chat-item .avatar {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--panel-2); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; color: var(--acento); flex-shrink: 0;
}
.chat-item .cuerpo { flex: 1; min-width: 0; }
.chat-item .fila1 { display: flex; justify-content: space-between; gap: 8px; }
.chat-item .nombre { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .hora { color: var(--texto-suave); font-size: 12px; flex-shrink: 0; }
.chat-item .vista { color: var(--texto-suave); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .badge {
  background: var(--acento); color: #fff; border-radius: 999px;
  font-size: 12px; font-weight: 700; padding: 1px 8px; margin-left: 6px;
}
.chat-item .muerto { font-size: 12px; color: var(--rosa); }
.lista-vacia { text-align: center; color: var(--texto-suave); padding: 48px 20px; }
.lista-vacia img { opacity: 0.7; margin-bottom: 8px; }

/* ---- vista de chat ---- */
.vista-chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.mensajes { flex: 1; overflow-y: auto; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 2px; }
.burbuja {
  max-width: min(72%, 560px); padding: 8px 12px; border-radius: 16px;
  margin-top: 2px; position: relative; word-wrap: break-word; white-space: pre-wrap;
  animation: pop-burbuja 0.18s ease-out;
}
@keyframes pop-burbuja { from { opacity: 0; transform: translateY(6px) scale(0.96); } }
.burbuja.in { background: var(--panel-2); align-self: flex-start; border-bottom-left-radius: 4px; }
.burbuja.out { background: var(--acento-osc); align-self: flex-end; border-bottom-right-radius: 4px; }
.burbuja .meta { display: flex; gap: 6px; justify-content: flex-end; align-items: center; font-size: 11px; color: rgba(255,255,255,0.65); margin-top: 2px; }
.burbuja.in .meta { color: var(--texto-suave); }
.burbuja .de-quien { font-size: 12px; font-weight: 700; color: var(--rosa); margin-bottom: 2px; }
.burbuja img.foto { max-width: 100%; border-radius: 10px; display: block; cursor: zoom-in; }
.burbuja.sistema { align-self: center; background: none; color: var(--texto-suave); font-size: 12.5px; text-align: center; }
.burbuja.programada { outline: 1px dashed var(--rosa); }
.hora-chivo { text-align: center; color: var(--texto-suave); font-size: 12px; margin: 10px 0 4px; }

.compositor {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--borde); flex-shrink: 0;
}
.compositor textarea {
  flex: 1; resize: none; max-height: 132px; min-height: 44px; border-radius: 16px;
  padding: 11px 14px; background: var(--panel-2);
}
.compositor button.enviar {
  background: var(--acento); border: 0; color: #fff; font-size: 18px;
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
}
.compositor button.adj { background: var(--panel-2); border: 1px solid var(--borde); color: var(--texto);
  width: 44px; height: 44px; border-radius: 50%; font-size: 17px; flex-shrink: 0; }
.entrada-oculta { display: none; }

/* ---- panel de acciones / modales ---- */
.panel {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: flex-end; justify-content: center; z-index: 40;
}
@media (min-width: 600px) { .panel { align-items: center; } }
.panel .contenido {
  background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio) var(--radio) 0 0;
  width: min(480px, 100vw); padding: 18px; max-height: 82dvh; overflow-y: auto;
}
@media (min-width: 600px) { .panel .contenido { border-radius: var(--radio); } }
.panel h3 { margin: 4px 0 12px; }
.panel .fila-opciones { display: flex; flex-direction: column; gap: 8px; }
.panel .opciones-ttl { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.chip {
  background: var(--panel-2); border: 1px solid var(--borde); color: var(--texto);
  border-radius: 999px; padding: 7px 14px; font-size: 13px;
}
.chip.activo { background: var(--acento); border-color: var(--acento); color: #fff; }

/* ---- ajustes y varios ---- */
.seccion { padding: 16px; max-width: 640px; margin: 0 auto; width: 100%; }
.seccion h2 { font-size: 18px; margin: 22px 0 8px; }
.tarjeta {
  background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 14px 16px; margin-bottom: 10px;
}
.tarjeta .fila { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 6px 0; }
.codigo {
  font-family: ui-monospace, Consolas, monospace; font-size: 13px; word-break: break-all;
  background: var(--panel-2); border-radius: 8px; padding: 10px;
}
.tabla-priv { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabla-priv th, .tabla-priv td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--borde); vertical-align: top; }
.tabla-priv th { color: var(--texto-suave); font-weight: 600; white-space: nowrap; }

/* ---- toasts ---- */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #2c313a; color: var(--texto); border: 1px solid var(--borde);
  padding: 10px 18px; border-radius: 999px; box-shadow: var(--sombra); font-size: 14px;
  animation: aparecer 0.18s ease-out;
}
@keyframes aparecer { from { opacity: 0; transform: translateY(8px); } }

/* visor de imagen */
.visor-foto { position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 70;
  display: flex; align-items: center; justify-content: center; }
.visor-foto img { max-width: 94vw; max-height: 92dvh; }
.spin { display: inline-block; animation: girar 1s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }

/* ==================== MÓVIL (iPhone / Android) ==================== */
@media (max-width: 480px) {
  .caja-form { width: 100%; max-width: 100%; border-radius: 0; border-left: 0; border-right: 0; padding: 22px 18px; }
  .burbuja { max-width: 86%; }
  .barra { padding: 8px 10px; }
  .seccion { padding: 12px; }
  .compositor { gap: 6px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
  .compositor button.adj, .compositor button.enviar { width: 42px; height: 42px; }
  .mensajes { padding: 10px 10px 4px; }
}
/* El logo de bienvenida saluda */
.caja-form .logo { animation: guasalo-saluda 2.6s ease-in-out infinite; transform-origin: 50% 80%; }
@keyframes guasalo-saluda { 0%, 100% { transform: rotate(0deg); } 8% { transform: rotate(-6deg); } 16% { transform: rotate(5deg); } 24% { transform: rotate(-3deg); } 30% { transform: rotate(0deg); } }

/* ==================== AVATARES CON FOTO ==================== */
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar.grande { width: 84px; height: 84px; border-radius: 50%; overflow: hidden; background: var(--panel-2);
  display: flex; align-items: center; justify-content: center; font-size: 34px; font-weight: 700; color: var(--acento); }

/* ==================== PANEL DE EMOJIS ==================== */
.emoji-panel { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 38dvh; overflow-y: auto; }
.emoji-panel button { background: none; border: 0; font-size: 26px; padding: 6px 0; border-radius: 8px; }
.emoji-panel button:active, .emoji-panel button:hover { background: var(--panel-2); transform: scale(1.18); transition: transform 0.08s; }
.emoji-titulo { color: var(--texto-suave); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; margin: 8px 0 4px; grid-column: 1 / -1; }

/* ==================== LOGROS ==================== */
.toast-logro {
  background: linear-gradient(135deg, #245f46, #2fa376);
  color: #fff; border: 1px solid #35c98d;
  padding: 12px 20px; border-radius: 14px; box-shadow: var(--sombra);
  font-size: 14.5px; display: flex; gap: 10px; align-items: center;
  animation: logro-entra 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.toast-logro .icono-logro { font-size: 26px; animation: logro-brinca 0.6s ease 0.15s; }
.toast-logro b { display: block; font-size: 15px; }
.toast-logro small { opacity: 0.85; }
@keyframes logro-entra { from { opacity: 0; transform: translateY(18px) scale(0.85); } }
@keyframes logro-brinca { 0%, 100% { transform: none; } 40% { transform: scale(1.35) rotate(-8deg); } 70% { transform: scale(0.95) rotate(4deg); } }

/* Botón enviar con vida */
.compositor button.enviar:active { transform: scale(0.88); }
.compositor button.enviar { transition: transform 0.1s; }

/* ==================== LLAMADAS Y VIDEOLLAMADAS ==================== */
.llamada-fondo { position:fixed; inset:0; background:#0c0e11; z-index:80; display:flex; flex-direction:column; }
.llamada-fondo.timbrando { animation: timbre-fondo 1.6s ease-in-out infinite; }
@keyframes timbre-fondo { 0%, 100% { background:#0c0e11; } 50% { background:#17211b; } }
.llamada-centro { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; z-index:1; }
.llamada-avatar { width:120px; height:120px; border-radius:50%; background:var(--panel-2); color:var(--acento);
  font-size:52px; font-weight:700; display:flex; align-items:center; justify-content:center;
  animation: logro-brinca 1.8s ease infinite; }
.llamada-fondo:not(.timbrando) .llamada-avatar { animation: none; }
.llamada-nombre { font-size:24px; font-weight:700; }
.llamada-estado { color:var(--texto-suave); font-size:15px; display:flex; gap:10px; }
#llamada-duracion:empty { display:none; }
.llamada-controles { display:flex; gap:22px; justify-content:center; padding:26px 0 calc(34px + env(safe-area-inset-bottom)); }
.btn-llamada { width:64px; height:64px; border-radius:50%; border:0; font-size:26px; cursor:pointer;
  background:var(--panel-2); color:var(--texto); box-shadow:var(--sombra); transition:transform 0.1s; }
.btn-llamada:active { transform: scale(0.9); }
.btn-llamada.colgar { background:#d64b4b; color:#fff; }
.btn-llamada.aceptar { background:var(--acento); color:#fff; animation: logro-brinca 1.4s ease infinite; }

/* ==================== TIRAS DE EFECTOS EN LLAMADA ==================== */
.efectos-tira { position:absolute; left:0; right:0; bottom:118px; z-index:5;
  background:rgba(20,22,26,.92); border-top:1px solid var(--borde);
  padding:12px 16px; display:flex; flex-direction:column; gap:8px;
  animation: aparecer 0.15s ease-out; }
.efectos-titulo { color:var(--texto-suave); font-size:12.5px; text-transform:uppercase; letter-spacing:.05em; }
.efectos-tira .opciones-ttl { gap:8px; }
.efectos-tira .chip { font-size:14px; padding:8px 14px; }

/* ==================== NOTAS DE VOZ ==================== */
.btn-voz { width:40px; height:40px; border-radius:50%; border:0; background:rgba(255,255,255,.14);
  font-size:18px; cursor:pointer; display:inline-flex; align-items:center; justify-content:center; }
.compositor button.enviar.grabando { background:#d64b4b; animation: logro-brinca 1s ease infinite; }

/* ==================== RESPONDER + REACCIONES ==================== */
.respuesta-preview { display:flex; justify-content:space-between; align-items:center; gap:10px;
  background:var(--panel); border-top:1px solid var(--borde); border-left:3px solid var(--acento);
  padding:8px 14px; font-size:13px; }
.cita { border-left:3px solid var(--acento); background:rgba(47,163,118,.08); border-radius:6px;
  padding:4px 8px; font-size:12.5px; margin-bottom:4px; color:var(--texto-suave); overflow:hidden; }
.reacciones { display:flex; gap:4px; flex-wrap:wrap; margin-top:3px; }
.chip-reaccion { background:var(--panel); border:1px solid var(--borde); border-radius:999px;
  padding:1px 8px; font-size:13px; }
.ventas-pill { color:#f4b860; font-size:11px; }

/* ==================== MODO MERCADO ==================== */
.tarjeta-anuncio { background:rgba(0,0,0,.18); border:1px solid var(--borde); border-radius:12px;
  padding:10px; min-width:200px; display:flex; flex-direction:column; gap:4px; }
.tarjeta-anuncio .pill { align-self:flex-start; }
.tarjeta-anuncio .pill.ok { background:rgba(47,163,118,.18); color:#59d6a2; padding:1px 10px; border-radius:999px; font-size:12px; }
.tarjeta-anuncio .pill.bad { background:rgba(208,91,91,.18); color:#ff9c9c; padding:1px 10px; border-radius:999px; font-size:12px; text-decoration:line-through; }

/* ==================== ESTADOS (24 h) ==================== */
.fila-estados { display:flex; gap:14px; padding:14px 16px 6px; overflow-x:auto; border-bottom:1px solid var(--borde); }
.estado-item { display:flex; flex-direction:column; align-items:center; gap:4px; cursor:pointer; min-width:56px; user-select:none; }
.estado-item small { color:var(--texto-suave); font-size:11px; max-width:60px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.estado-ring { position:relative; border-radius:50%; padding:2.5px; background:var(--borde); }
.estado-item.tiene .estado-ring { background:linear-gradient(135deg,#2fa376,#35c98d); }
.estado-mas { position:absolute; right:-2px; bottom:-2px; width:20px; height:20px; border-radius:50%;
  background:var(--acento); color:#fff; font-weight:700; font-size:15px; line-height:19px; text-align:center; border:2px solid var(--fondo); }
.estado-barra { position:absolute; top:16px; left:16px; right:16px; height:4px; background:rgba(255,255,255,.25); border-radius:99px; overflow:hidden; }
@keyframes estado-vida { from { width:100%; } to { width:0%; } }
.estado-cab { position:absolute; top:30px; left:18px; right:18px; display:flex; gap:10px; align-items:center; color:#fff; }
.estado-centro { flex:1; display:flex; align-items:center; justify-content:center; padding:80px 16px 40px; }
.estado-texto { font-size:26px; font-weight:600; text-align:center; max-width:640px; white-space:pre-wrap; }

/* Pantalla previa a la llamada (estilo Meet) */
.nivel-medidor { display:flex; align-items:flex-end; gap:3px; height:38px; }
.nivel-barra { width:6px; height:3px; border-radius:3px; background:var(--acento); transition: height .08s ease-out; }
.sel-dispositivo { background:var(--panel-2); border:1px solid var(--borde); color:var(--texto);
  border-radius:10px; padding:8px 10px; font:13px inherit; max-width:240px; }
