:root {
  --bg-principal: #0f0f0f;
  --bg-tarjetas: #1f1f1f;
  --bg-inputs: #272727;
  --rojo-yt: #ff0000;
  --texto-blanco: #f1f1f1;
  --texto-gris: #aaa;
}

body {
  background-color: var(--bg-principal);
  color: var(--texto-blanco);
  font-family: 'Roboto', Arial, sans-serif;
  margin: 0;
  padding: 0;
}

header {
  background-color: var(--bg-principal);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid #222;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 22px;
  font-weight: bold;
  color: var(--texto-blanco);
  letter-spacing: -1px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.logo-beta {
  font-size: 10px;
  color: var(--texto-gris);
  font-weight: normal;
  margin-top: 2px;
  letter-spacing: 0;
}

.logo span { 
  color: var(--rojo-yt); 
}

/* BUSQUEDA EN HEADER */
.busqueda-header {
  display: flex;
  flex: 0 1 500px;
  margin: 0 15px;
}

.busqueda-header input {
  flex: 1;
  background-color: #121212;
  border: 1px solid #333;
  color: white;
  padding: 8px 15px;
  border-radius: 40px 0 0 40px;
  outline: none;
  font-size: 15px;
}

.busqueda-header button {
  background-color: #222;
  border: 1px solid #333;
  border-left: none;
  color: white;
  padding: 0 15px;
  border-radius: 0 40px 40px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.busqueda-header button:hover { background-color: #333; }

nav button {
  background: none;
  border: none;
  color: var(--texto-blanco);
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  border-radius: 20px;
  margin-left: 5px;
  transition: background 0.2s;
}

/* Resaltar botón de registro cuando no hay sesión */
nav button.btn-highlight {
  background-color: var(--texto-blanco);
  color: black;
  font-weight: bold;
}

nav button:hover, nav button.active {
  background-color: var(--bg-inputs);
}

main {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.seccion {
  display: none;
}

.seccion.active {
  display: block;
}

/* GRID DE TARJETAS */
.grid-videos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.tarjeta-video {
  background-color: transparent;
  cursor: pointer;
}

.tarjeta-video img {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 12px;
  object-fit: cover;
  background-color: #333;
}

.info-video {
  display: flex;
  margin-top: 10px;
  gap: 12px;
}

.avatar-falso {
  width: 36px;
  height: 36px;
  background-color: #444;
  border-radius: 50%;
}

.detalles-video h3 {
  margin: 0 0 4px 0;
  font-size: 14px;
  line-height: 20px;
}

.detalles-video p {
  margin: 0;
  font-size: 12px;
  color: var(--texto-gris);
}

/* CONTENEDOR REPRODUCTOR PRO */
.contenedor-reproductor {
  max-width: 854px;
  margin: 0 auto;
}

/* Asegurar que el contenedor de ajustes sea el punto de referencia */
.settings-container {
  position: relative;
}

/* REPRODUCTOR PROFESIONAL */
.video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: black;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.video-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.custom-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
  padding: 10px 15px;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 10;
}

.video-wrapper:hover .custom-controls {
  opacity: 1;
}

/* Estado de inactividad: oculta controles y cursor */
.video-wrapper.inactive {
  cursor: none;
}
.video-wrapper.inactive .custom-controls {
  opacity: 0 !important;
}

.progress-area {
  height: 4px;
  width: 100%;
  background: rgba(255,255,255,0.2);
  cursor: pointer;
  margin-bottom: 10px;
  transition: height 0.1s;
}

.progress-area:hover { height: 6px; }

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--rojo-yt);
  position: relative;
}

.progress-bar span {
  position: absolute;
  right: -6px;
  top: -4px;
  width: 14px;
  height: 14px;
  background: var(--rojo-yt);
  border-radius: 50%;
  display: none;
}

.progress-area:hover .progress-bar span { display: block; }

.controls-list { display: flex; justify-content: space-between; align-items: center; }
.controls-left, .controls-right { display: flex; align-items: center; gap: 12px; }

.ctrl-btn {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 5px;
  transition: transform 0.1s;
}
.ctrl-btn:hover { transform: scale(1.1); }

.vol-slider { width: 60px; height: 3px; cursor: pointer; accent-color: white; }
.time-display { font-size: 13px; color: #eee; font-family: monospace; }

.settings-menu {
  display: none; /* OCULTO POR DEFECTO */
  position: absolute;
  bottom: 50px;  /* Aparece arriba de la barra */
  right: 0;
  background: rgba(28, 28, 28, 0.98);
  border: 1px solid #444;
  border-radius: 8px;
  padding: 12px;
  min-width: 180px;
  z-index: 2000;
  box-shadow: 0 4px 20px rgba(0,0,0,0.8);
}

.settings-menu.show {
  display: block; /* SOLO SE MUESTRA CON ESTA CLASE */
}

.menu-section p {
  margin: 0 0 8px 0;
  font-size: 12px;
  color: var(--texto-gris);
  text-transform: uppercase;
  border-bottom: 1px solid #333;
  padding-bottom: 4px;
}

.menu-section div {
  display: flex;
  flex-direction: column; /* OPCIONES EN VERTICAL */
  gap: 4px;
  margin-bottom: 12px;
}

.menu-section button {
  background: transparent;
  border: none;
  color: white;
  text-align: left;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.menu-section button:hover {
  background: #444;
}

.menu-section button.active {
  color: var(--rojo-yt);
  font-weight: bold;
  background: rgba(255, 0, 0, 0.1);
}

.quality-container { position: relative; }
.quality-menu {
  position: absolute;
  bottom: 45px;
  right: 0;
  background: rgba(28, 28, 28, 0.95);
  border-radius: 8px;
  padding: 8px;
  display: none;
  min-width: 140px;
  border: 1px solid #444;
}
.quality-menu.show { display: block; }
.quality-menu button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  color: white; padding: 8px; cursor: pointer; font-size: 13px;
}
.quality-menu button:hover { background: #444; }
.quality-menu button.active { color: var(--rojo-yt); font-weight: bold; }

.meta-video { margin-top: 20px; }

/* Eliminamos el bloque roto que estaba aquí */

/* FORMULARIOS DE SUBIDA */
.formulario-perfil {
  background-color: var(--bg-tarjetas);
  padding: 30px;
  border-radius: 16px;
  max-width: 500px;
  margin: 0 auto;
}

.grupo-form {
  margin-bottom: 20px;
}

.grupo-form label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--texto-gris);
}

.grupo-form input[type="text"], .grupo-form textarea {
  width: 100%;
  padding: 10px;
  box-sizing: border-box;
  background-color: var(--bg-inputs);
  border: 1px solid #3c3c3c;
  border-radius: 8px;
  color: white;
  font-size: 14px;
}

.btn-guardar {
  background-color: var(--texto-blanco);
  color: black;
  border: none;
  padding: 10px 20px;
  font-weight: bold;
  border-radius: 20px;
  cursor: pointer;
  width: 100%;
}

/* SECCIÓN HISTORIAL */
.lista-historial {
  max-width: 500px; 
  margin: 20px auto 0 auto;
  background-color: var(--bg-tarjetas);
  border-radius: 12px;
  padding: 15px;
}

.item-historial {
  padding: 10px;
  border-bottom: 1px solid #333;
  font-size: 14px;
}

/* ESTILO PARA CANALES EN BÚSQUEDA */
.tarjeta-canal-busqueda {
  transition: background 0.2s;
  border-radius: 12px;
}

.tarjeta-canal-busqueda:hover {
  background-color: #1a1a1a;
}

/* REPRODUCTOR MEJORADO (WATCH) */
.watch-container {
  display: flex;
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px;
  flex-wrap: wrap;
}

.watch-main { flex: 2; min-width: 300px; }
.watch-sidebar { flex: 1; min-width: 300px; }

.interacciones {
  display: flex;
  gap: 15px;
  align-items: center;
  margin-top: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid #333;
}

.btn-like {
  background: #272727;
  border: none;
  color: white;
  padding: 8px 16px;
  border-radius: 18px;
  cursor: pointer;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-like.active { color: #3ea6ff; background: #3f3f3f; }
.btn-like img {
  width: 18px;
  height: 18px;
  filter: brightness(0) invert(1); /* Hace la imagen blanca */
}

.seccion-comentarios { margin-top: 20px; }
.input-comentario {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid #333;
  color: white;
  padding: 8px 0;
  margin-bottom: 10px;
  outline: none;
}

.comentario-item { padding: 12px 0; border-bottom: 1px solid #222; }

/* AVISOS Y ADMIN */
.banner-aviso {
  background: var(--rojo-yt);
  color: white;
  padding: 10px;
  text-align: center;
  font-weight: bold;
  font-size: 14px;
  z-index: 200;
}

.badge-verificado {
  width: 18px;
  height: 18px;
  margin-left: 5px;
  vertical-align: middle;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  background: var(--bg-tarjetas);
}
.admin-table th, .admin-table td { padding: 12px; border: 1px solid #333; text-align: left; }
.admin-btn { padding: 5px 10px; border-radius: 4px; border: none; cursor: pointer; font-size: 12px; margin-right: 5px; }

/* ESTILOS CANAL EN WATCH */
.info-canal-watch {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 15px 0;
}

.canal-detalles-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.btn-sus-watch {
  background: #fff;
  color: #000;
  border: none;
  padding: 8px 16px;
  border-radius: 18px;
  font-weight: bold;
  cursor: pointer;
}

.btn-sus-watch.subbed {
  background: #272727;
  color: #fff;
}

/* BARRA DE PROGRESO DE SUBIDA */
.progreso-container {
  width: 100%;
  height: 10px;
  background: #1a1a1a;
  border-radius: 10px;
  margin: 10px 0 20px 0;
  overflow: hidden;
  border: 1px solid #333;
  display: none; /* Se muestra al iniciar la subida */
}
.progreso-barra {
  width: 0%;
  height: 100%;
  background: var(--rojo-yt);
  transition: width 0.3s;
  box-shadow: 0 0 8px rgba(255, 0, 0, 0.4);
}

/* IMAGEN DE DONACIÓN */
.btn-donar-flotante {
  position: fixed;
  bottom: 0;
  left: 0;
  right: auto;
  z-index: 1000;
}
.btn-donar-flotante img {
  width: 22vw;
  max-width: 350px;
  height: auto; /* Mantiene la proporción de la imagen */
  display: block;
  opacity: 0.8;
  transition: opacity 0.3s, transform 0.3s;
}
.btn-donar-flotante:hover img { opacity: 1; transform: scale(1.02); }

/* FORMULARIO DE PERFIL (LOGIN/REGISTRO) */
.formulario-perfil {
  background-color: #1a1a1a; /* Un poco más oscuro que bg-tarjetas para contraste */
  padding: 40px;
  border-radius: 16px;
  max-width: 400px; /* Un poco más estrecho para un look minimalista */
  margin: 50px auto; /* Centrado vertical y horizontal */
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6); /* Sombra suave */
  border: 1px solid #2a2a2a; /* Borde sutil */
}

.login-logo-container {
  text-align: center;
  margin-bottom: 20px;
}

.login-logo-container h1 {
  color: var(--rojo-yt);
  font-size: 32px;
  margin: 0;
  line-height: 1;
}

.login-logo-container .logo-beta {
  font-size: 12px;
  color: var(--texto-gris);
  display: block;
}

.formulario-perfil h3 {
  font-size: 20px;
  color: var(--texto-blanco);
  margin-bottom: 30px;
}

.formulario-perfil .grupo-form label {
  font-size: 13px;
  color: #bbb;
  margin-bottom: 6px;
}

.formulario-perfil input[type="text"],
.formulario-perfil input[type="password"],
.formulario-perfil textarea {
  background-color: #0d0d0d; /* Fondo de input más oscuro */
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  padding: 12px 15px;
  color: white;
  font-size: 15px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.formulario-perfil input[type="text"]:focus,
.formulario-perfil input[type="password"]:focus,
.formulario-perfil textarea:focus {
  border-color: var(--rojo-yt);
  box-shadow: 0 0 0 2px rgba(255, 0, 0, 0.3);
}

.formulario-perfil .btn-guardar {
  background-color: var(--rojo-yt); /* Botón principal rojo */
  color: white;
  font-size: 16px;
  padding: 12px 20px;
  border-radius: 8px;
  transition: background-color 0.2s;
}
.formulario-perfil .btn-guardar:hover {
  background-color: #cc0000;
}

.formulario-perfil #texto-cambiar-modo {
  font-size: 13px;
  color: #888;
}
.formulario-perfil #texto-cambiar-modo span {
  color: var(--rojo-yt); /* Enlace de cambio de modo en rojo */
  font-weight: bold;
  text-decoration: none; /* Quitamos el subrayado por defecto */
}
.formulario-perfil #texto-cambiar-modo span:hover {
  text-decoration: underline; /* Subrayado al pasar el ratón */
}

/* SWITCHER DE IDIOMA MEJORADO (DROPDOWN) */
.lang-main-btn {
  background: var(--bg-inputs);
  border: 1px solid #333;
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  margin-left: 10px;
  transition: background 0.2s;
}
.lang-main-btn:hover { background: #333; }

.lang-dropdown {
  display: none;
  position: absolute;
  top: 45px;
  right: 0;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 8px;
  min-width: 120px;
  z-index: 2000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.lang-dropdown.show { display: block; }
.lang-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: #eee;
  padding: 10px;
  cursor: pointer;
  font-size: 14px;
  border-radius: 4px;
}
.lang-dropdown button:hover { background: #333; }

/* SWITCHER DE IDIOMA MEJORADO (DROPDOWN) */
.lang-main-btn {
  background: var(--bg-inputs);
  border: 1px solid #333;
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  margin-left: 10px;
  transition: background 0.2s;
}
.lang-main-btn:hover { background: #333; }

.lang-dropdown {
  display: none;
  position: absolute;
  top: 45px;
  right: 0;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 8px;
  min-width: 120px;
  z-index: 2000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.lang-dropdown.show { display: block; }
.lang-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: #eee;
  padding: 10px;
  cursor: pointer;
  font-size: 14px;
  border-radius: 4px;
}
.lang-dropdown button:hover { background: #333; }
.formulario-perfil textarea {
  resize: vertical;
}

/* ICONOS DE IMAGEN */
.icono-btn {
  width: 18px;
  height: 18px;
  object-fit: contain;
  filter: brightness(0) invert(1); /* Hace la imagen blanca para fondos oscuros */
}

/* ====== RESPONSIVIDAD PARA TABLETS Y MÓVILES ====== */

/* Ajustes generales para tablets (hasta 1024px) */
@media (max-width: 1024px) {
  .watch-container {
    gap: 15px;
    padding: 10px;
  }
  
  .btn-donar-flotante img {
    max-width: 250px;
  }
}

/* Ajustes para móviles (hasta 768px) */
@media (max-width: 768px) {
  header {
    flex-wrap: wrap;
    padding: 10px 15px;
    gap: 10px;
  }

  .busqueda-header {
    order: 3; /* El buscador baja a una fila propia */
    flex: 1 1 100%;
    margin: 0;
  }

  nav {
    display: flex;
    width: auto;
    gap: 5px;
  }

  nav button {
    padding: 6px 12px;
    font-size: 13px;
  }

  .watch-main, .watch-sidebar {
    flex: 1 1 100%; /* Ocupan todo el ancho al apilarse */
  }

  .formulario-perfil {
    margin: 20px 15px;
    padding: 25px;
  }

  .btn-donar-flotante img {
    width: 45vw;
    max-width: 180px;
  }
}

/* Ajustes para móviles pequeños (hasta 480px) */
@media (max-width: 480px) {
  .logo {
    font-size: 18px;
  }

  .grid-videos {
    grid-template-columns: 1fr; /* Una sola columna para que el video se vea grande */
  }

  .info-canal-watch {
    flex-wrap: wrap;
  }
  
  .btn-sus-watch {
    width: 100%;
    margin-top: 10px;
  }
}

/* MENU DE USUARIO (ESQUINA SUPERIOR) */
.user-menu-container { position: relative; display: inline-block; margin-left: 10px; vertical-align: middle; }
.user-avatar-btn {
  width: 34px; height: 32px; border-radius: 50%; object-fit: cover;
  cursor: pointer; border: 1px solid #333; transition: transform 0.2s;
}
.user-avatar-btn:hover { transform: scale(1.05); border-color: #555; }
.user-dropdown {
  display: none; position: absolute; top: 45px; right: 0;
  background: #1a1a1a; border: 1px solid #333; border-radius: 12px;
  min-width: 220px; z-index: 2000; box-shadow: 0 10px 40px rgba(0,0,0,0.7);
  overflow: hidden;
}
.user-dropdown.show { display: block; }
.user-dropdown a, .user-dropdown button {
  display: block; width: 100%; padding: 12px 20px; text-align: left;
  background: transparent; border: none; color: #eee; text-decoration: none;
  font-size: 14px; cursor: pointer; transition: background 0.2s;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: #2a2a2a; }

/* Evitar parpadeo del menú al cargar */
.user-logged-in nav > a, 
.user-logged-in nav > button,
.user-logged-in nav > #btn-cerrar-sesion, 
.user-logged-in #nombre-usuario-nav {
  display: none !important;
}

/* ESTILOS WIKI */
.wiki-container { max-width: 900px; margin: 40px auto; line-height: 1.6; }
.wiki-section { background: #1a1a1a; padding: 25px; border-radius: 12px; margin-bottom: 25px; border: 1px solid #333; }
.wiki-section h2 { color: var(--rojo-yt); margin-top: 0; display: flex; align-items: center; gap: 10px; }
.wiki-section h3 { color: white; margin-bottom: 10px; }
.wiki-step { margin-bottom: 15px; padding-left: 20px; border-left: 3px solid var(--bg-inputs); }
.wiki-step strong { color: #3ea6ff; }
.wiki-badge { background: #333; padding: 2px 8px; border-radius: 4px; font-size: 12px; }

/* Ajustes de tipografía en Watch */
#reproductor-titulo {
  font-size: 28px !important;
  margin-bottom: 5px;
}
#reproductor-canal-nombre {
  font-size: 14px !important;
}