/* ═══════════════════════════════════════════
   ZONA GEMELOS 🎭 — Chat Messages & Input
   ═══════════════════════════════════════════ */
#chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  margin: 0;
  padding: 0;
  position: relative;
  background: transparent;
}
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: calc(28vh + 4px) 4px 2px;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  scroll-behavior: smooth;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 8%, black 100%);
  mask-image: linear-gradient(to bottom, transparent 12%, black 18%, black 100%);
}
#chat-messages::-webkit-scrollbar { width: 3px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb { background: rgba(138,94,255,0.2); border-radius: 3px; }

/* ─── AVATAR de otros usuarios ─── */
.msg-avatar {
  width: 20px; height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  border: 1px solid rgba(255,255,255,0.06);
  overflow: hidden;
}
.msg-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

/* ─── WRAPPER para alinear avatar + burbuja ─── */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  max-width: 88%;
  margin-bottom: 1px;
}
.msg-row.own {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.msg-row.other {
  align-self: flex-start;
}
.msg-row.group-start {
  margin-top: 4px;
}

/* ─── BURBUJAS GLASS ULTRA ─── */
.msg {
  padding: 3px 7px;
  border-radius: 10px;
  font-size: 11px;
  line-height: 1.3;
  word-wrap: break-word;
  position: relative;
  max-width: 100%;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: msgFloat 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes msgFloat {
  0% { opacity: 0; transform: translateY(12px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── BURBUJA PROPIA (derecha) ─── */
.msg.own {
  background: linear-gradient(135deg, rgba(138,94,255,0.2), rgba(107,63,204,0.12));
  border: 0.5px solid rgba(138,94,255,0.15);
  border-bottom-right-radius: 4px;
  box-shadow:
    0 4px 16px rgba(138,94,255,0.08),
    inset 0 1px 0 rgba(255,255,255,0.06);
}
.msg.own::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: -5px;
  width: 10px;
  height: 10px;
  background: rgba(138,94,255,0.15);
  border-radius: 0 0 10px 0;
  clip-path: polygon(0 0, 100% 100%, 0 100%);
  border-right: 0.5px solid rgba(138,94,255,0.1);
  border-bottom: 0.5px solid rgba(138,94,255,0.1);
}
.msg.own.tail-hide::after { display: none; }
.msg.own.tail-hide {
  border-bottom-right-radius: 18px;
}

/* ─── BURBUJA DE OTRO (izquierda) ─── */
.msg.other {
  background: rgba(255,255,255,0.04);
  border: 0.5px solid rgba(255,255,255,0.06);
  border-bottom-left-radius: 4px;
  box-shadow:
    0 4px 16px rgba(0,0,0,0.1),
    inset 0 1px 0 rgba(255,255,255,0.04);
}
.msg.other::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: -5px;
  width: 10px;
  height: 10px;
  background: rgba(255,255,255,0.04);
  border-radius: 0 0 0 10px;
  clip-path: polygon(100% 0, 0 100%, 100% 100%);
  border-left: 0.5px solid rgba(255,255,255,0.04);
  border-bottom: 0.5px solid rgba(255,255,255,0.04);
}
.msg.other.tail-hide::after { display: none; }
.msg.other.tail-hide {
  border-bottom-left-radius: 18px;
}

.msg-nick {
  font-size: 9px;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 1px;
  letter-spacing: -0.2px;
}
.msg-text { color: var(--text); text-shadow: 0 1px 2px rgba(0,0,0,0.2); }

.msg-time {
  font-size: 7px;
  color: rgba(255,255,255,0.2);
  margin-top: 1px;
  text-align: right;
  letter-spacing: 0.2px;
  opacity: 0;
  transition: opacity 0.2s;
}
.msg-row:hover .msg-time { opacity: 1; }
.msg-time.visible { opacity: 0.5; }

.msg-check {
  display: inline-block;
  margin-left: 2px;
  font-size: 10px;
  opacity: 0.5;
}

/* ─── BOTÓN SCROLL TO BOTTOM ─── */
#scroll-bottom {
  position: absolute;
  bottom: 62px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(138,94,255,0.2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 0.5px solid rgba(138,94,255,0.1);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  animation: floatUp 0.3s ease-out;
}
#scroll-bottom.show { display: flex; }
#scroll-bottom:active { transform: scale(0.9); }
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(10px) scale(0.8); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── CHAT INPUT — Crystal Glass ─── */
#chat-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px max(10px, env(safe-area-inset-bottom, 10px));
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 30;
  background: transparent;
}
#chat-input {
  flex: 1;
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 0.5px solid rgba(255,255,255,0.08);
  border-radius: 22px;
  padding: 11px 18px;
  color: #fff;
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: all 0.25s ease;
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,0.04),
    0 2px 8px rgba(0,0,0,0.1);
}
#chat-input:focus {
  border-color: rgba(138,94,255,0.3);
  background: rgba(255,255,255,0.06);
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,0.06),
    0 0 20px rgba(138,94,255,0.06);
}
#chat-input::placeholder { color: rgba(255,255,255,0.2); }

#send-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #6b3fcc);
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow:
    0 4px 16px rgba(138,94,255,0.25),
    inset 0 1px 0 rgba(255,255,255,0.15);
  position: relative;
  overflow: hidden;
}
#send-btn::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.15) 0%, transparent 50%);
  pointer-events: none;
}
#send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(138,94,255,0.35);
}
#send-btn:active { transform: scale(0.92); }

.msg-gif {
  width: 90px;
  max-width: 100px;
  max-height: 90px;
  border-radius: 8px;
  display: block;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
