/* Design System & Global Styles */
:root {
  --bg-dark: #0f0c1b;
  --bg-card: rgba(25, 20, 45, 0.6);
  --bg-input: rgba(10, 8, 20, 0.5);
  --primary-color: #8b5cf6; /* Neon Purple */
  --primary-glow: rgba(139, 92, 246, 0.4);
  --accent-color: #ec4899; /* Neon Pink */
  --accent-glow: rgba(236, 72, 153, 0.4);
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --success-color: #10b981;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(139, 92, 246, 0.6);
  --glass-blur: blur(12px);
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Outfit', sans-serif;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

body {
  background: radial-gradient(circle at top right, #1e1145 0%, var(--bg-dark) 60%);
  color: var(--text-main);
  height: 100vh;
  height: 100dvh; /* Altura dinámica del viewport en móviles */
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color);
}

/* Glassmorphism Card Utility */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: var(--transition-smooth);
  color: #fff;
  outline: none;
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary-color) 0%, #6d28d9 100%);
  box-shadow: 0 4px 14px var(--primary-glow);
}
.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--primary-glow);
  filter: brightness(1.1);
}

.accent-btn {
  background: linear-gradient(135deg, var(--accent-color) 0%, #be185d 100%);
  box-shadow: 0 4px 14px var(--accent-glow);
}
.accent-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--accent-glow);
  filter: brightness(1.1);
}

/* Input Fields */
input[type="text"], input[type="search"], input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-main);
  font-size: 0.95rem;
  transition: var(--transition-smooth);
  outline: none;
}
input[type="text"]:focus, input[type="search"]:focus, input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.2);
}

/* Utility Hidden */
.hidden {
  display: none !important;
}

/* ---------------- LOGIN OVERLAY ---------------- */
.overlay-container {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 8, 20, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 40px 30px;
  text-align: center;
  animation: fadeIn 0.4s ease-out;
}

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

.logo-area {
  margin-bottom: 30px;
}
.logo-icon {
  font-size: 3.5rem;
  margin-bottom: 10px;
  filter: drop-shadow(0 0 10px var(--primary-glow));
  animation: pulse 2s infinite ease-in-out;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.logo-area h1 {
  font-size: 2.2rem;
  font-weight: 700;
  background: linear-gradient(to right, var(--text-main), var(--primary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}
.logo-area p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

.form-group {
  text-align: left;
  margin-bottom: 25px;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
#join-btn {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
}

/* ---------------- APP MAIN LAYOUT ---------------- */
.app-layout {
  display: flex;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* Altura dinámica del viewport en móviles */
  background: var(--bg-dark);
}

/* Browser Section (Left) */
.browser-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  border-right: 1px solid var(--border-color);
  background: #000;
}

.browser-navbar {
  height: 60px;
  background: rgba(20, 15, 38, 0.9);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 15px;
  gap: 12px;
  z-index: 10;
}

.nav-buttons {
  display: flex;
  gap: 6px;
}
.nav-icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  font-size: 0.9rem;
}
.nav-icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(1.05);
}

.address-bar-container {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 0 14px;
  gap: 8px;
  height: 38px;
}
.lock-icon {
  font-size: 0.85rem;
  color: var(--success-color);
}
#address-bar {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  height: 100%;
  font-size: 0.9rem;
}

#go-btn {
  height: 38px;
  padding: 0 18px;
  border-radius: 20px;
  font-size: 0.9rem;
}

/* Viewport Area */
.screen-viewport-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  background: #000;
}

.video-wrapper {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  max-width: calc((100vh - 60px) * 16 / 9); /* Limitada por la altura disponible en PC */
  max-height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
}

.app-layout.chat-collapsed .video-wrapper {
  max-width: calc((100vh - 108px) * 16 / 9); /* Altura descontando barra de navegación y cabecera de chat colapsada en PC */
}

#browser-video {
  width: 100%;
  height: 100%;
  object-fit: fill; /* Fill the 16:9 box */
}

#browser-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: default;
  background: transparent;
}

/* Spinner Overlay */
.spinner-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 15px;
  color: var(--text-main);
  z-index: 5;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Sidebar Section (Right) */
.sidebar-section {
  width: 380px;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: rgba(15, 10, 30, 0.85);
  backdrop-filter: var(--glass-blur);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), height 0.3s cubic-bezier(0.4, 0, 0.2, 1), flex 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sidebar collapsed rules (unified for both desktop and mobile) */
.sidebar-section.collapsed #users-section {
  display: none !important;
}
.sidebar-section.collapsed .chat-messages,
.sidebar-section.collapsed .typing-indicator,
.sidebar-section.collapsed .chat-form {
  display: none !important;
}
.sidebar-section.collapsed .chat-toggle-btn span {
  transform: rotate(180deg);
}

/* Desktop layout changes when collapsed */
.app-layout.chat-collapsed {
  flex-direction: column;
}
.app-layout.chat-collapsed .browser-section {
  height: auto;
  border-right: none;
  border-bottom: 1px solid var(--border-color);
}
.app-layout.chat-collapsed .sidebar-section.collapsed {
  width: 100% !important;
  height: 48px !important;
  flex: none !important;
  border-left: none;
  border-top: 1px solid var(--border-color);
}


.room-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.room-info h2 {
  font-size: 1.15rem;
  font-weight: 700;
}
.online-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.online-indicator .dot {
  width: 8px;
  height: 8px;
  background: var(--success-color);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--success-color);
}

.control-btn {
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
}
.control-btn.control-active {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success-color);
  border-color: rgba(16, 185, 129, 0.4);
}
.control-btn.control-inactive {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
}

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 12px 20px 6px 20px;
}

/* User list */
.users-list-wrapper {
  border-bottom: 1px solid var(--border-color);
  max-height: 120px;
  overflow-y: auto;
  padding-bottom: 10px;
}
.users-list {
  padding: 0 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.user-badge {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.user-badge.self-user {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.4);
  font-weight: 500;
}
.user-avatar {
  font-size: 0.85rem;
}

/* Chat container */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 15px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(25, 20, 45, 0.4);
  flex-shrink: 0;
}

.chat-header .section-title {
  padding: 0;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-main);
}

.chat-toggle-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.chat-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--primary-color);
  transform: scale(1.05);
}

.chat-toggle-btn span {
  display: inline-block;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}


.chat-messages {
  flex: 1;
  padding: 10px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: messageIn 0.25s ease-out;
}

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

.message.other-message {
  align-self: flex-start;
}
.message.my-message {
  align-self: flex-end;
}

.message .msg-sender {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 3px;
  padding: 0 4px;
}
.message.my-message .msg-sender {
  text-align: right;
}

.message .msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-word;
}
.message.other-message .msg-bubble {
  background: rgba(255, 255, 255, 0.08);
  border-top-left-radius: 2px;
}
.message.my-message .msg-bubble {
  background: linear-gradient(135deg, var(--primary-color) 0%, #6d28d9 100%);
  color: #fff;
  border-top-right-radius: 2px;
  box-shadow: 0 3px 10px rgba(139, 92, 246, 0.25);
}

.system-message {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--border-color);
  padding: 8px 12px;
  border-radius: 8px;
  text-align: center;
  margin: 4px 0;
  line-height: 1.35;
}

.chat-form {
  padding: 15px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
}
.chat-form input {
  flex: 1;
  background: var(--bg-input);
  border-radius: 20px;
  padding: 10px 16px;
  height: 40px;
}
.send-btn {
  background: var(--primary-color);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  font-size: 1rem;
}
.send-btn:hover {
  transform: scale(1.08);
  background: #7c3aed;
  box-shadow: 0 0 10px var(--primary-glow);
}

/* ---------------- RESPONSIVE STYLING (MOBILE FIRST FOR CHAT / VERTICAL) ---------------- */
@media (max-width: 800px) {
  .app-layout {
    flex-direction: column;
  }
  
  .browser-section {
    flex: none;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  
  .browser-navbar {
    height: 52px;
    padding: 0 10px;
    gap: 8px;
  }
  .nav-icon-btn {
    width: 32px;
    height: 32px;
  }
  .address-bar-container {
    height: 34px;
    padding: 0 10px;
  }
  #go-btn {
    height: 34px;
    padding: 0 14px;
  }

  .screen-viewport-container {
    flex: none;
    background: #000;
    width: 100%;
  }

  .sidebar-section {
    width: 100%;
    flex: 1;
    min-height: 0;
    border-top: 1px solid var(--border-color);
  }
  .sidebar-section.collapsed {
    flex: none !important;
    height: 48px !important;
    overflow: hidden;
  }
  .app-layout.chat-collapsed .browser-section {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .app-layout.chat-collapsed .screen-viewport-container {
    flex: 1;
    min-height: 0;
  }
  .app-layout.chat-collapsed .video-wrapper {
    max-width: calc((100dvh - 100px) * 16 / 9) !important;
  }
  .chat-messages {
    padding: 8px 15px; /* Reducir padding de mensajes */
    gap: 8px;
  }
  .chat-form {
    padding: 8px 15px; /* Reducir padding del formulario */
  }
}

/* Botón de Menú de Opciones */
.menu-icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  font-size: 1.3rem;
  color: #fff;
  flex-shrink: 0;
}
.menu-icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(1.05);
}

/* Contenedor Dropdown del Menú */
.browser-dropdown-menu {
  position: absolute;
  top: 55px;
  right: 15px;
  background: rgba(20, 15, 38, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 260px;
  padding: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 999;
}

/* Fila de acciones rápidas (atrás, adelante, recargar, fullscreen) */
.menu-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.zoom-controls-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  justify-items: stretch;
  gap: 8px;
  margin-top: 4px;
}

.zoom-level-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary-color);
  text-align: center;
  background: rgba(139, 92, 246, 0.1);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(139, 92, 246, 0.2);
  min-width: 60px;
  display: inline-block;
}

.menu-action-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  font-size: 0.75rem;
  line-height: 1.2;
  transition: var(--transition-smooth);
}
.menu-action-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--primary-color);
}

.menu-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 4px 0;
}

/* Botones tipo lista en el menú */
.menu-list-btn {
  background: rgba(167, 139, 250, 0.1);
  border: 1px solid rgba(167, 139, 250, 0.2);
  border-radius: 8px;
  padding: 10px;
  color: var(--primary-light);
  cursor: pointer;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-smooth);
}
.menu-list-btn:hover {
  background: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
}

@media (max-width: 768px) {
  .browser-dropdown-menu {
    top: 48px;
    right: 10px;
    width: 240px;
  }
  .menu-icon-btn {
    width: 34px;
    height: 34px;
    font-size: 1.1rem;
  }
}

/* Limpiar estilos de input type="search" para que actúe como texto plano */
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
  display: none;
}

/* Indicador de escritura del chat */
.typing-indicator {
  font-size: 0.8rem;
  color: var(--primary-light);
  padding: 4px 20px;
  font-style: italic;
  animation: typingBlink 1.5s infinite ease-in-out;
  min-height: 20px;
}

@keyframes typingBlink {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ---------------- MÓVIL EN MODO HORIZONTAL (LANDSCAPE) ---------------- */
@media (max-width: 950px) and (orientation: landscape) {
  .app-layout {
    flex-direction: row !important;
  }
  
  .browser-section {
    flex: 1 !important;
    height: 100% !important;
    border-right: 1px solid var(--border-color) !important;
    border-bottom: none !important;
  }
  
  .app-layout.chat-collapsed .browser-section {
    flex: 1 !important;
    height: 100% !important;
    border-right: 1px solid var(--border-color) !important;
    border-bottom: none !important;
  }
  
  .browser-navbar {
    height: 52px;
    padding: 0 10px;
    gap: 8px;
  }
  
  .screen-viewport-container {
    flex: 1 !important;
    height: calc(100% - 52px) !important;
  }
  
  .video-wrapper {
    max-width: calc((var(--browser-height, 100dvh) - 52px) * 16 / 9) !important;
  }
  
  .app-layout.chat-collapsed .screen-viewport-container {
    flex: 1 !important;
  }
  
  .sidebar-section {
    width: 280px !important;
    height: 100% !important;
    border-top: none !important;
    border-left: 1px solid var(--border-color) !important;
  }
  
  /* Cuando el chat está colapsado en horizontal */
  .sidebar-section.collapsed {
    width: 48px !important;
    height: 100% !important;
    flex: none !important;
  }
  
  .app-layout.chat-collapsed .sidebar-section.collapsed {
    width: 48px !important;
    height: 100% !important;
    flex: none !important;
    border-left: 1px solid var(--border-color) !important;
    border-top: none !important;
  }
  
  .sidebar-section.collapsed .chat-header {
    justify-content: center !important;
    padding: 0 !important;
    height: 48px !important;
  }
  
  .sidebar-section.collapsed .chat-header .section-title {
    display: none !important;
  }

  /* Rotación del botón en horizontal */
  .chat-toggle-btn span {
    transform: rotate(-90deg); /* Apunta a la derecha cuando está abierto (para colapsar a la derecha) */
  }
  
  .sidebar-section.collapsed .chat-toggle-btn span {
    transform: rotate(90deg) !important; /* Apunta a la izquierda cuando está cerrado (para expandir a la izquierda) */
  }
}

/* Animación pulsante para el botón del teclado */
.menu-icon-btn.pulsing {
  border-color: var(--primary-color) !important;
  box-shadow: 0 0 12px var(--primary-glow) !important;
  animation: borderPulse 1.5s infinite ease-in-out;
}

@keyframes borderPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 var(--primary-glow);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 0 14px 4px var(--primary-glow);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 var(--primary-glow);
  }
}

/* Botón flotante para activar el sonido de forma premium */
.unmute-overlay-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  background: rgba(139, 92, 246, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 14px 28px;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(139, 92, 246, 0.5);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: pulseButton 2s infinite;
}

.unmute-overlay-btn:hover {
  background: rgba(139, 92, 246, 1);
  transform: translate(-50%, -50%) scale(1.05);
  box-shadow: 0 12px 35px rgba(139, 92, 246, 0.7);
}

@keyframes pulseButton {
  0% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.7);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(139, 92, 246, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0);
  }
}

/* ---------------- CHAT HISTORY OVERLAY ---------------- */
.chat-history-card {
  width: 90%;
  max-width: 800px;
  height: 80vh;
  max-height: 750px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: rgba(18, 14, 36, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  animation: modalFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 16px;
}

.history-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.history-icon {
  font-size: 1.6rem;
}

.history-title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
  background: linear-gradient(135deg, #fff 0%, var(--text-muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.close-history-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-main);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.close-history-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  transform: rotate(90deg);
}

.history-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 8px;
  scroll-behavior: smooth;
}

/* History Scrollbar */
.history-content::-webkit-scrollbar {
  width: 6px;
}

.history-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 3px;
}

.history-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.history-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* History Message Items */
.history-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px;
  border-radius: 12px;
  transition: background-color 0.2s ease;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.02);
}

.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
}

.history-item-user {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-item-time {
  color: var(--text-muted);
  font-family: monospace;
}

.history-item-body {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-main);
  word-break: break-word;
}

/* Color variations */
.history-item.event-join {
  background: rgba(16, 185, 129, 0.04);
  border-left: 3px solid rgba(16, 185, 129, 0.5);
}
.history-item.event-join .history-item-user {
  color: #10b981;
}

.history-item.event-leave {
  background: rgba(239, 68, 68, 0.04);
  border-left: 3px solid rgba(239, 68, 68, 0.5);
}
.history-item.event-leave .history-item-user {
  color: #ef4444;
}

.history-item.event-message {
  background: rgba(139, 92, 246, 0.04);
  border-left: 3px solid rgba(139, 92, 246, 0.5);
}
.history-item.event-message .history-item-user {
  color: #a78bfa;
}

/* Responsive adjustment */
@media (max-width: 767px) {
  .chat-history-card {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
    padding: 16px;
  }
  .history-title {
    font-size: 1.2rem;
  }
}

/* ---------------- PANTALLA PRINCIPAL / LOBBY (FULL PAGE) ---------------- */
.lobby-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 100;
  background: radial-gradient(circle at top right, #1e1145 0%, var(--bg-dark) 60%);
  display: flex;
  flex-direction: column;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

.lobby-card {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  border-radius: 0;
  border: none;
  display: flex;
  flex-direction: column;
  padding: 24px 36px;
  gap: 20px;
  overflow: hidden;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  animation: fadeIn 0.4s ease-out;
}


.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 18px;
}

.lobby-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  font-size: 2.5rem;
  filter: drop-shadow(0 0 10px var(--primary-glow));
}

.brand-text h1 {
  font-size: 1.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 0%, var(--primary-color) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

#open-private-modal-btn {
  padding: 11px 22px;
  font-size: 0.98rem;
  font-weight: 600;
  border-radius: 14px;
  box-shadow: 0 4px 18px rgba(108, 92, 231, 0.45);
  transition: var(--transition-smooth);
}
#open-private-modal-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(108, 92, 231, 0.65);
}


.user-profile-widget {

  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 12px;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.username-badge {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary-color);
}

.small-btn {
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: 8px;
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}
.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.danger-btn {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}
.danger-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* Tabs */
.lobby-tabs {
  display: flex;
  gap: 10px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 4px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  transition: var(--transition-smooth);
  border-bottom: 2px solid transparent;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  background: rgba(139, 92, 246, 0.08);
}

/* Tab Content Areas */
.tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding-right: 4px;
}

.rooms-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input-wrapper input {
  width: 100%;
  padding-left: 38px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Rooms Grid */
.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.room-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: var(--transition-smooth);
  position: relative;
}

.room-card:hover {
  transform: translateY(-4px);
  border-color: rgba(139, 92, 246, 0.4);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.room-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.room-card-icon {
  font-size: 1.8rem;
}

.room-user-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--success-color);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.room-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.room-card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
  flex: 1;
}

.room-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.2);
  padding: 6px 10px;
  border-radius: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Private Rooms Container */
.private-rooms-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 10px;
}

.glass-card-sub {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.glass-card-sub h3 {
  font-size: 1.2rem;
  color: var(--text-main);
}

.glass-card-sub p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Name Change Modal */
.modal-card {
  width: 90%;
  max-width: 440px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: modalFadeIn 0.25s ease-out;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-body p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.room-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: var(--primary-color);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}


