/* MensaCrypt — tema cyberpunk, layout estilo WhatsApp */
:root {
  --bg: #05010f;
  --bg2: #120428;
  --panel: rgba(18, 6, 46, 0.92);
  --panel-solid: #10052a;
  --neon-cyan: #00fff7;
  --neon-pink: #ff00e0;
  --neon-purple: #7b2bff;
  --text: #d8f7ff;
  --dim: #6f8aa8;
  --ok: #2aff8a;
  --err: #ff2a5f;
  --mono: "Courier New", ui-monospace, monospace;
  --border: rgba(0, 255, 247, .22);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }
body {
  background:
    radial-gradient(ellipse at 20% 0%, rgba(123, 43, 255, .25), transparent 55%),
    radial-gradient(ellipse at 85% 100%, rgba(255, 0, 224, .18), transparent 55%),
    linear-gradient(var(--bg), var(--bg2));
  color: var(--text);
  font-family: var(--mono);
  overflow: hidden;
}
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(0, 255, 247, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 247, .05) 1px, transparent 1px);
  background-size: 42px 42px;
  pointer-events: none;
}

.hidden { display: none !important; }
.dim { color: var(--dim); }
.small { font-size: .72rem; line-height: 1.6; }
.msg-ok { color: var(--ok); margin-top: 8px; font-size: .8rem; }
.msg-err { color: var(--err); margin-top: 8px; font-size: .8rem; }

/* ============================== LOGIN ============================== */
.auth-wrap {
  height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 16px; position: relative; z-index: 1;
}
header.brand { text-align: center; padding: 12px 0 6px; }
header.brand img { width: 150px; filter: drop-shadow(0 0 18px rgba(0,255,247,.5)); }
header.brand h1 {
  font-size: 1.8rem; letter-spacing: .35em; margin-top: 8px;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink), var(--neon-purple));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
header.brand p.tag { color: var(--dim); letter-spacing: .22em; font-size: .7rem; margin-top: 6px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 0 24px rgba(0, 255, 247, .12);
  padding: 24px;
  backdrop-filter: blur(6px);
}
.auth-panel { width: min(430px, 94vw); margin-top: 18px; }
.panel h2 {
  color: var(--neon-cyan); font-size: .95rem; letter-spacing: .2em;
  border-bottom: 1px solid rgba(255, 0, 224, .3); padding-bottom: 10px; margin-bottom: 16px;
}

label { display: block; color: var(--dim); font-size: .7rem; letter-spacing: .15em; margin: 12px 0 4px; }
input[type="text"], input[type="tel"], input[type="email"] {
  width: 100%; padding: 10px 13px;
  background: rgba(2, 0, 12, .8); color: var(--text);
  border: 1px solid rgba(123, 43, 255, .5); border-radius: 6px;
  font-family: var(--mono); font-size: .92rem; outline: none;
}
input:focus { border-color: var(--neon-cyan); box-shadow: 0 0 12px rgba(0, 255, 247, .3); }

button {
  margin-top: 14px; padding: 11px 22px; cursor: pointer;
  background: linear-gradient(90deg, rgba(0,255,247,.15), rgba(255,0,224,.15));
  color: var(--neon-cyan);
  border: 1px solid var(--neon-cyan); border-radius: 6px;
  font-family: var(--mono); font-size: .85rem; letter-spacing: .15em; text-transform: uppercase;
  transition: all .15s; width: 100%;
}
button:hover { box-shadow: 0 0 16px rgba(0, 255, 247, .55); }
button.secondary { color: var(--neon-pink); border-color: var(--neon-pink); }
button.mini { width: auto; padding: 7px 14px; font-size: .7rem; margin-top: 8px; }
button.danger { color: var(--err); border-color: var(--err); }
button:disabled { opacity: .45; cursor: wait; box-shadow: none; filter: saturate(.4); }

.spinner {
  display: inline-block; width: 13px; height: 13px; margin-right: 8px;
  vertical-align: -2px; border-radius: 50%;
  border: 2px solid rgba(0, 255, 247, .25);
  border-top-color: var(--neon-cyan);
  border-right-color: var(--neon-pink);
  animation: mc-spin .7s linear infinite;
}
@keyframes mc-spin { to { transform: rotate(360deg); } }

footer.legal { margin-top: 26px; text-align: center; color: var(--dim); font-size: .66rem; line-height: 1.7; }
footer.legal a { color: var(--neon-cyan); text-decoration: none; }

/* ---- selector de idioma ---- */
.lang-bar { width: min(430px, 94vw); display: flex; justify-content: flex-end; }
.lang-select {
  background: rgba(2,0,12,.8); color: var(--neon-cyan);
  border: 1px solid rgba(123,43,255,.5); border-radius: 6px;
  font-family: var(--mono); font-size: .8rem; padding: 6px 10px; width: auto;
}

/* ---- asistente de login ---- */
.wizard-step { animation: mc-fade .25s ease; }
@keyframes mc-fade { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
.wizard-body { color: var(--text); font-size: .9rem; line-height: 1.7; margin: 12px 0 6px; }
.wizard-hint { color: var(--dim); font-size: .8rem; line-height: 1.6; margin: 4px 0 14px; }
.wizard-nav { display: flex; gap: 10px; }
.wizard-nav button { flex: 1; }
.linklike {
  width: auto; background: none; border: none; box-shadow: none;
  color: var(--neon-pink); text-transform: none; letter-spacing: 0;
  font-size: .78rem; margin-top: 12px; padding: 4px; text-decoration: underline;
}
.linklike:hover { box-shadow: none; }

/* ---- selector de país ---- */
.phone-row { display: flex; gap: 8px; }
.country-btn {
  width: auto; margin: 0; white-space: nowrap; padding: 10px 12px;
  font-size: .95rem; letter-spacing: 0; text-transform: none;
}
.phone-row input { flex: 1; }
.country-dropdown {
  margin-top: 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel-solid); padding: 8px; max-height: 260px; display: flex; flex-direction: column;
}
.country-dropdown input { margin-bottom: 6px; }
.country-list { overflow-y: auto; }
.country-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 6px; cursor: pointer; font-size: .85rem;
}
.country-item:hover { background: rgba(123,43,255,.15); }
.country-item .c-dial { color: var(--dim); margin-left: auto; }

/* ============================== APP ============================== */
.app { display: flex; height: 100vh; position: relative; z-index: 1; }

.avatar {
  width: 42px; height: 42px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--neon-purple); background: var(--bg);
  box-shadow: 0 0 8px rgba(123, 43, 255, .4); flex-shrink: 0;
}
.avatar.big { width: 84px; height: 84px; }
.icon-btn {
  width: auto; margin: 0; padding: 8px 11px; font-size: 1rem;
  background: transparent; border: 1px solid transparent; color: var(--neon-cyan);
}
.icon-btn:hover { border-color: var(--neon-cyan); box-shadow: 0 0 10px rgba(0,255,247,.4); }
.icon-btn.send { border-color: var(--neon-cyan); background: rgba(0,255,247,.12); }

/* ---- Sidebar ---- */
.sidebar {
  width: 340px; min-width: 280px; height: 100%;
  background: var(--panel-solid);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.me-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  background: rgba(123, 43, 255, .08);
}
.me-info { flex: 1; min-width: 0; }
.me-name { color: var(--neon-cyan); font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-phone { color: var(--dim); font-size: .7rem; }

.newchat-bar { display: flex; gap: 6px; padding: 10px 12px 0; }
.newchat-bar input { flex: 1; }
/* input.search (no .search a secas): debe ganar a `input[type="text"]
   { width: 100% }`, que sumado a los márgenes desbordaba el sidebar y el
   campo de búsqueda pisaba la conversación de la derecha. */
input.search { margin: 10px 12px; width: calc(100% - 24px); }

.chat-list { flex: 1; overflow-y: auto; padding: 4px 8px; }
.chat-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; margin-bottom: 4px;
}
.chat-item:hover, .chat-item.active {
  border-color: var(--neon-purple); background: rgba(123,43,255,.12);
}
.chat-item .ci-body { flex: 1; min-width: 0; }
.chat-item .ci-top { display: flex; justify-content: space-between; align-items: baseline; }
.chat-item .ci-name { color: var(--neon-cyan); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .ci-time { color: var(--dim); font-size: .62rem; margin-left: 6px; flex-shrink: 0; }
.chat-item .ci-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 3px; }
.chat-item .ci-last { color: var(--dim); font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  background: var(--neon-pink); color: #14001f; font-size: .62rem; font-weight: bold;
  border-radius: 10px; padding: 1px 7px; margin-left: 6px; flex-shrink: 0;
  box-shadow: 0 0 8px rgba(255, 0, 224, .6);
}
.sidebar-foot {
  padding: 8px; text-align: center; color: var(--ok); font-size: .58rem;
  letter-spacing: .1em; border-top: 1px dashed rgba(42, 255, 138, .35);
}

/* ---- Conversación ---- */
.thread { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.thread-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; text-align: center; padding: 20px; color: var(--text);
}
.thread-empty img { width: 140px; opacity: .8; filter: drop-shadow(0 0 14px rgba(0,255,247,.4)); }
.thread-main { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.thread-head {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: rgba(18, 6, 46, .85);
}
.peer-info { flex: 1; min-width: 0; }
.peer-name { color: var(--neon-cyan); font-size: .95rem; }
.peer-status { color: var(--dim); font-size: .68rem; }
.peer-status.online { color: var(--ok); }

.messages {
  flex: 1; overflow-y: auto; padding: 16px 22px;
  display: flex; flex-direction: column; gap: 6px;
}
.bubble {
  max-width: 66%; padding: 9px 13px; border-radius: 10px; font-size: .88rem;
  word-wrap: break-word; line-height: 1.45;
}
.bubble.me {
  align-self: flex-end;
  background: rgba(0, 255, 247, .1); border: 1px solid rgba(0, 255, 247, .4);
  border-bottom-right-radius: 3px;
}
.bubble.them {
  align-self: flex-start;
  background: rgba(255, 0, 224, .08); border: 1px solid rgba(255, 0, 224, .35);
  border-bottom-left-radius: 3px;
}
.bubble.system {
  align-self: center; color: var(--dim); font-size: .68rem;
  background: rgba(111, 138, 168, .08); border: 1px dashed rgba(111, 138, 168, .3);
}
.bubble .meta {
  display: flex; justify-content: flex-end; gap: 5px; align-items: center;
  color: var(--dim); font-size: .6rem; margin-top: 4px;
}
.ticks { letter-spacing: -2px; font-size: .72rem; color: var(--dim); }
.ticks.read { color: var(--ok); text-shadow: 0 0 6px rgba(42,255,138,.6); }

.composer {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 14px; border-top: 1px solid var(--border);
  background: rgba(18, 6, 46, .85);
}
.composer input[type="text"] { flex: 1; }

/* ---- Ajustes ---- */
.settings {
  width: 360px; min-width: 300px; height: 100%; overflow-y: auto;
  background: var(--panel-solid); border-left: 1px solid var(--border);
  padding: 0 18px 30px;
}
.settings-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 0; border-bottom: 1px solid var(--border); margin-bottom: 6px;
  position: sticky; top: 0; background: var(--panel-solid);
}
.settings-head h2 { color: var(--neon-cyan); letter-spacing: .25em; font-size: .95rem; }
.settings section { margin-top: 20px; }
.settings h3 {
  color: var(--neon-pink); font-size: .72rem; letter-spacing: .2em;
  border-bottom: 1px dashed rgba(255,0,224,.3); padding-bottom: 6px; margin-bottom: 10px;
}
.profile-edit { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.session-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1px solid rgba(123,43,255,.35); border-radius: 8px; margin-bottom: 6px;
  font-size: .74rem;
}
.session-row .online-dot { color: var(--ok); }
.check { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--text); }
.block-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px; border: 1px solid rgba(255,42,95,.35); border-radius: 8px;
  margin-bottom: 6px; font-size: .78rem;
}

/* ---- Overlay de llamada ---- */
.call-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: radial-gradient(ellipse at 50% 30%, rgba(123,43,255,.25), #02000a 70%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.call-overlay .remote-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #02000a;
}
.call-overlay .remote-video.audio-only { display: none; }
.call-overlay .local-video {
  position: absolute; top: 18px; right: 18px; width: 150px; height: 200px;
  object-fit: cover; border-radius: 12px; border: 2px solid var(--neon-cyan);
  box-shadow: 0 0 18px rgba(0,255,247,.5); background: #02000a; z-index: 2;
}
.call-info {
  position: relative; z-index: 2; text-align: center;
  background: rgba(2,0,12,.55); padding: 20px 34px; border-radius: 14px;
  border: 1px solid var(--border); backdrop-filter: blur(4px);
}
.call-peer-name {
  font-size: 1.6rem; letter-spacing: .1em;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.call-status { color: var(--text); margin-top: 8px; letter-spacing: .1em; }
.call-e2ee { color: var(--ok); font-size: .62rem; letter-spacing: .12em; margin-top: 12px; }
.call-actions {
  position: absolute; bottom: 42px; z-index: 3;
  display: flex; gap: 22px;
}
.call-btn {
  width: 64px; height: 64px; border-radius: 50%; margin: 0; padding: 0;
  font-size: 1.5rem; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--neon-cyan); background: rgba(0,255,247,.12); color: var(--neon-cyan);
}
.call-btn.off { opacity: .4; border-color: var(--dim); color: var(--dim); }
.call-btn.accept { border-color: var(--ok); color: var(--ok); background: rgba(42,255,138,.15); }
.call-btn.hangup {
  border-color: var(--err); color: var(--err); background: rgba(255,42,95,.15);
  transform: rotate(135deg);
}
.call-btn.hangup { font-size: 1.4rem; }

/* ---- móvil ---- */
@media (max-width: 860px) {
  .sidebar { width: 100%; position: absolute; inset: 0; z-index: 5; }
  .app.chat-open .sidebar { display: none; }
  .settings { position: absolute; right: 0; top: 0; z-index: 6; width: min(360px, 100vw); }
}
