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

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #6e8efb, #a777e3);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  color: #333;
  padding: 20px;
}

#chat-container {
  width: 90%;
  max-width: 500px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  padding: 1.5rem;
  transition: all 0.3s ease;
}

/* Pantalla de autenticación */
#auth-screen h2 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: #6e8efb;
}

.auth-tabs {
  display: flex;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid #eee;
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 0.8rem;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s;
  color: #666;
}

.auth-tab:hover {
  color: #6e8efb;
}

.auth-tab.active {
  color: #6e8efb;
  border-bottom: 2px solid #6e8efb;
  font-weight: bold;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-group label {
  font-size: 0.9rem;
  color: #666;
}

.auth-form input {
  padding: 0.8rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s;
}

.auth-form input:focus {
  border-color: #6e8efb;
  outline: none;
  box-shadow: 0 0 0 2px rgba(110, 142, 251, 0.2);
}

.auth-button {
  background: #6e8efb;
  color: white;
  font-weight: bold;
  padding: 0.8rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.3s;
  margin-top: 0.5rem;
}

.auth-button:hover {
  background: #5a7df9;
}

.error-message {
  color: #e74c3c;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.success-message {
  color: #2ecc71;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* Pantalla de selección de canal */
#user-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid #eee;
}

#logout-btn {
  background: #f8f8f8;
  color: #666;
  border: 1px solid #ddd;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s;
}

#logout-btn:hover {
  background: #ff6b6b;
  color: white;
  border-color: #ff6b6b;
}

#channels-container {
  margin-bottom: 1.5rem;
}

#channels-container h3 {
  margin-bottom: 1rem;
  color: #6e8efb;
}

#channels-list {
  list-style: none;
  margin-bottom: 1.5rem;
}

#channels-list li {
  padding: 0.8rem;
  border: 1px solid #eee;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#channels-list li:hover {
  background: #f9f9f9;
  border-color: #6e8efb;
}

#channels-list li .channel-name {
  font-weight: bold;
}

#channels-list li .channel-creator {
  font-size: 0.8rem;
  color: #666;
}

.admin-badge {
  background: #6e8efb;
  color: white;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-left: 0.5rem;
}

#create-channel-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

#new-channel-name {
  flex: 1;
  padding: 0.8rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
}

#create-channel-form button {
  padding: 0.8rem;
  background: #6e8efb;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.3s;
}

#create-channel-form button:hover {
  background: #5a7df9;
}

/* Cabecera del chat */
#chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid #eee;
}

#room-name {
  font-size: 1.2rem;
  color: #6e8efb;
}

#leave-btn {
  background: #f8f8f8;
  color: #666;
  border: 1px solid #ddd;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s;
}

#leave-btn:hover {
  background: #ff6b6b;
  color: white;
  border-color: #ff6b6b;
}

/* Controles de administrador */
#admin-controls {
  position: relative;
  display: inline-block;
}

#admin-menu-btn {
  background: #6e8efb;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  z-index: 1;
  border-radius: 6px;
  right: 0;
}

#admin-controls:hover .dropdown-content {
  display: block;
}

.admin-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.8rem;
  border: none;
  background: none;
  cursor: pointer;
}

.admin-btn:hover {
  background-color: #f1f1f1;
}

/* Información del chat */
#chat-info {
  display: flex;
  margin-bottom: 1rem;
}

#users-container {
  flex: 1;
  background: #f9f9f9;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 0.8rem;
  margin-bottom: 1rem;
}

#users-container h4 {
  margin-bottom: 0.8rem;
  color: #6e8efb;
  font-size: 0.9rem;
  border-bottom: 1px solid #eee;
  padding-bottom: 0.5rem;
}

#users-list {
  list-style: none;
  max-height: 100px;
  overflow-y: auto;
}

#users-list li {
  padding: 0.4rem 0;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
}

#users-list li:before {
  content: "•";
  color: #2ecc71;
  margin-right: 0.5rem;
}

.admin-badge {
  background: #6e8efb;
  color: white;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-left: 0.5rem;
}

.guest-badge {
  background: #f39c12;
  color: white;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-left: 0.5rem;
}

/* Ventana de chat */
#chat-window {
  height: 350px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  background: #f9f9f9;
}

#messages {
  list-style: none;
  padding: 0;
  margin: 0;
}

#messages li {
  margin-bottom: 0.8rem;
  padding: 0.8rem 1rem;
  border-radius: 8px;
  max-width: 80%;
  word-break: break-word;
  position: relative;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Estilo para mensajes del sistema */
#messages li.system-message {
  background: #f0f0f0;
  color: #666;
  font-style: italic;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  max-width: 100%;
}

/* Estilo para mensajes propios */
#messages li.my-message {
  background: #dcf8c6;
  margin-left: auto;
}

/* Estilo para mensajes de otros */
#messages li.other-message {
  background: #e3e3e3;
  margin-right: auto;
}

/* Botón para eliminar mensaje - CORREGIDO */
.delete-message-btn {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  background: rgba(255, 107, 107, 0.7);
  color: white;
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

#messages li:hover .delete-message-btn {
  opacity: 1;
}

/* Formulario de envío de mensajes */
#form {
  display: flex;
  gap: 0.8rem;
}

#input {
  flex: 1;
  padding: 0.8rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s;
}

#input:focus {
  border-color: #6e8efb;
  outline: none;
  box-shadow: 0 0 0 2px rgba(110, 142, 251, 0.2);
}

button {
  padding: 0.8rem 1.2rem;
  background: #6e8efb;
  color: white;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.3s;
}

button:hover {
  background: #5a7df9;
}

/* Responsive */
@media (max-width: 600px) {
  #chat-container {
    width: 95%;
    padding: 1rem;
  }

  #chat-window {
    height: 300px;
  }

  #create-channel-form {
    flex-direction: column;
  }
}

/* Timestamp para mensajes */
.message-timestamp {
  font-size: 0.7rem;
  color: #999;
  margin-top: 0.3rem;
  text-align: right;
}

/* Modal para gestión de administradores */
.modal {
  display: block;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
  background-color: #fff;
  margin: 15% auto;
  padding: 20px;
  border-radius: 10px;
  width: 80%;
  max-width: 500px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.close:hover {
  color: #333;
}

.admin-list,
.add-admin {
  margin-top: 1rem;
}

#admins-list {
  list-style: none;
  margin-top: 0.5rem;
}

#admins-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  border-bottom: 1px solid #eee;
}

.remove-admin-btn {
  background: #ff6b6b;
  color: white;
  border: none;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
}

.creator-badge {
  color: #6e8efb;
  font-style: italic;
  margin-left: 0.5rem;
}

#new-admin-input {
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-right: 0.5rem;
}

#add-admin-btn {
  background: #6e8efb;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
}

/* Estilos para usuarios en línea */
.online-users {
  margin-top: 1rem;
}

.online-user {
  display: flex;
  align-items: center;
  margin-bottom: 0.3rem;
}

.online-indicator {
  width: 8px;
  height: 8px;
  background-color: #2ecc71;
  border-radius: 50%;
  margin-right: 0.5rem;
}

/* Estilos para reacciones con emojis */
.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.5rem;
}

.reaction {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all 0.2s;
}

.reaction:hover {
  background: #f0f0f0;
}

.reaction-emoji {
  margin-right: 0.3rem;
}

.reaction-count {
  font-size: 0.7rem;
  color: #666;
}

.reaction-active {
  background: #e3f2fd;
  border-color: #90caf9;
}

.add-reaction-btn {
  font-size: 1rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  color: #999;
  transition: all 0.2s;
}

.add-reaction-btn:hover {
  color: #6e8efb;
}

.emoji-picker {
  bottom: 100%;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 0.5rem;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.3rem;
  z-index: 100;
}

.emoji-option {
  font-size: 1.2rem;
  cursor: pointer;
  text-align: center;
  padding: 0.3rem;
  border-radius: 4px;
  transition: all 0.2s;
}

.emoji-option:hover {
  background: #f0f0f0;
}

.reactions-container {
  position: relative;
  margin-top: 0.5rem;
}
