body {
  margin: 0;
  font-family: Arial, sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f0f2f5;
}

/* Usuarios conectados fijo */
#userCount {
  position: sticky; /* o fixed */
  top: 0;           /* se queda en la parte superior */
  z-index: 500;     /* sobre los mensajes */
  background: #e9ecef;
  padding: 5px;
  font-weight: bold;
  text-align: center;
  border-bottom: 1px solid #ccc;
}


/* Contenedor principal del chat (modo escritorio centrado) */
#chat-container {
  display: none;
  flex: 1;
  flex-direction: column;
  height: 100vh;
  position: relative;
  max-width: 900px;      /* ancho máximo */
  margin: 0 auto;        /* centra horizontalmente */
  background: #fff;
  border-left: 1px solid #ddd;
  border-right: 1px solid #ddd;
  box-shadow: 0 0 10px rgba(0,0,0,0.05);
}

/* Login centrado */
#login {
  max-width: 400px;
  margin: auto;
  text-align: center;
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

/* Barra superior */
#userCount {
  text-align: center;
  background: #e9ecef;
  padding: 8px;
  font-weight: bold;
  border-bottom: 1px solid #ddd;
}

/* Área de mensajes */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  background: #f8f9fa;
  margin-bottom: 90px;
  display: flex;
  flex-direction: column; /* Asegura que texto y medios estén en columna */
  gap: 10px;
}

/* Mensajes */
.msg {
  display: flex;
  flex-direction: column; /* Texto arriba, medios abajo */
  padding: 6px 10px;
  margin: 4px 0;
  border-radius: 8px;
  max-width: 80%;
  word-wrap: break-word;
}
.you {
  background: #DCF8C6;
  margin-left: auto;
}
.them {
  background: #E5E5EA;
  margin-right: auto;
}
.username {
  font-weight: bold;
  display: block;
  margin-bottom: 2px;
  font-size: 0.85rem;
}
.timestamp {
  font-size: 0.7rem;
  color: #666;
  margin-top: 2px;
}

/* Medios (imágenes, videos, audios) 
#messages img,
#messages video,
#messages audio {
  max-width: 10%;
  border-radius: 5px;
  margin-top: 3px;
  cursor: pointer;
   
}
*/
/* Fotos */
#messages img {
  max-width: 300px; /* o el tamaño que quieras */
  width: auto;
  height: auto;
  border-radius: 5px;
  margin-top: 3px;
  cursor: pointer; /* para abrir modal */
}

/* Videos */
#messages video {
  max-width: 500px; /* tamaño limitado para escritorio */
  width: 90%;
  height: auto;
  border-radius: 5px;
  margin-top: 5px;
  
}

/* Cuando se agrega un video real, se muestra */
#messages video[src] {
  display: block;
}



/* Audios */
#messages audio {
  width: 100%;
  margin-top: 5px;
}





/* Caja inferior (entrada de texto y botones) */
#input-group {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 900px;     /* mismo ancho que el contenedor */
  background: #fff;
  border-top: 1px solid #dee2e6;
  display: flex;
  gap: 5px;
  padding: 5px;
  box-sizing: border-box;
  z-index: 1000;
}

#msg {
  flex: 1;
  padding: 8px;
  border-radius: 5px;
  border: 1px solid #ccc;
}

#send {
  padding: 8px 12px;
  border-radius: 5px;
  border: none;
  background: #007bff;
  color: white;
  cursor: pointer;
}
#send:hover {
  background: #0056b3;
}

#newMsgAlert {
  display: none;
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1001;
}

/* Iconos adjuntar/micrófono */
.input-icon, #audioBtn {
  cursor: pointer;
  font-size: 22px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 2px;
}

.input-icon .selected, #audioBadge {
  position: absolute;
  top: -5px;
  right: -5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: white;
  background: green;
  display: none;
  font-weight: bold;
}

/* Badge grabando */
#audioBadge {
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  background: none;
  color: red;
  font-size: 12px;
}

/* Modal imágenes/videos */
.modal-content {
  background: transparent;
  border: none;
}
.modal-content img,
.modal-content video {
  max-width: 100%;
  border-radius: 5px;
}

/* Versión móvil (mantiene tu estilo original) */
@media (max-width: 600px) {
  #chat-container {
    max-width: 100%;
    border: none;
    box-shadow: none;
  }

  #input-group {
    left: 0;
    transform: none;
    max-width: 100%;
  }

  #msg {
    padding: 6px;
    font-size: 14px;
  }
  #send, #audioBtn, .input-icon {
    font-size: 20px;
  }
  
  .msg-content {
  display: flex;
  flex-direction: column; /* Siempre vertical */
  gap: 5px; /* Separación entre media y texto */
}

.msg img, .msg video, .msg audio {
  max-width: 100%;
  border-radius: 5px;
  margin-top: 3px;
  cursor: pointer;
}

.msg .text {
  margin-top: 5px;
}


/* YOUTUBE */

/* ==== YouTube Responsive ==== */
.youtube-wrapper {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* proporción 16:9 */
  margin-top: 10px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  cursor: pointer;
}

.youtube-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ==== Modal ==== */
.modal-content {
  background-color: #000;
  border: none;
  border-radius: 16px;
}

.modal-body iframe {
  width: 100%;
  height: 60vh;
  border: none;
}
