:root {
  --primary: #00b894;
  --bg: #181818;
  --header: #222;
  --card: #23272f;
  --accent: #ff7675; 
  --success: #2ecc71; 
  --text: #fff;
  --nav-bg: #23272f;
  --nav-active: #00b894;
  --card-border-radius: 12px;
  --grid-gap: 10px;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overscroll-behavior-y: contain; 
}

body.reel-active {
    overflow: hidden; 
}
body.reel-active #main-header,
body.reel-active #main-bottom-nav {
    display: none; 
}


header#main-header {
  background: var(--header); padding: 1rem; text-align: center;
  box-shadow: 0 2px 8px #0002; position: sticky; top: 0; z-index: 100;
}

h1 { margin: 0; font-size: 1.5rem; letter-spacing: 1px; font-weight: 700; color: var(--primary); }
h2 { text-align: center; margin: 1.5rem 0 1rem 0; color: var(--primary); font-size: 1.3rem; font-weight: 700; }

main { flex: 1; overflow-x: hidden; }
body:not(.reel-active) main { padding-bottom: 70px; }


.wallpapers-grid { padding: var(--grid-gap); box-sizing: border-box; }
.standard-grid { display: grid; /* Empieza con 2 columnas y puede crecer a más en pantallas grandes */grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); 
    gap: var(--grid-gap); 
}
.carousel-content { display: flex; gap: var(--grid-gap); transition: transform 0.3s ease-in-out; }
.carousel-content .wallpaper-card { min-width: 150px; flex: 0 0 auto; max-width: 180px; }

.wallpaper-card {
  background: var(--card); border-radius: var(--card-border-radius); overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2); display: flex; flex-direction: column;
  align-items: center; position: relative; transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
  animation: fadeIn 0.5s ease-out; width: 100%; box-sizing: border-box;
}
.wallpaper-card:hover { transform: translateY(-4px) scale(1.02); box-shadow: 0 6px 18px rgba(0,0,0,0.3); }
.wallpaper-card img { width: 100%; height: auto; aspect-ratio: 9/16; object-fit: cover; display: block; border-bottom: 1px solid #333; }

.download-btn {
  background: var(--primary); color: var(--bg); border: none; padding: 0.6rem 1rem; margin: 0.75rem;
  border-radius: 8px; font-size: 0.9rem; cursor: pointer; width: calc(100% - 1.5rem);
  transition: background 0.2s, transform 0.1s; font-weight: 600; box-shadow: 0 2px 6px rgba(0, 184, 148, 0.2); box-sizing: border-box;
}
.download-btn:active { transform: scale(0.97); }

.heart-btn {
  position: absolute; top: 8px; right: 8px; background: rgba(30,30,30,0.6); border: none;
  border-radius: 50%; padding: 6px; cursor: pointer; z-index: 2; transition: background 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.heart-btn .material-icons { font-size: 1.5rem; color: #fff; transition: color 0.2s, transform 0.2s; }
.heart-btn.favorited .material-icons { color: var(--accent); animation: pop 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28); }

@keyframes pop { 0%, 100% { transform: scale(1);} 50% { transform: scale(1.4);} }
@keyframes fadeIn { from { opacity: 0; transform: translateY(15px);} to { opacity: 1; transform: translateY(0);} }

.loader { text-align: center; padding: 1.5rem; color: #aaa; font-size: 1.1rem; }
.empty-msg { text-align: center; color: #888; margin-top: 2rem; font-size: 1.1rem; padding: 1rem; }

.bottom-nav#main-bottom-nav {
  position: fixed; bottom: 0; left: 0; width: 100%; background: var(--nav-bg);
  display: flex; justify-content: space-around; align-items: stretch; height: 60px;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.2); z-index: 200; 
  border-top-left-radius: 16px; border-top-right-radius: 16px;
}
.nav-btn {
  background: none; border: none; color: #aaa; font-size: 0.75rem; flex: 1; display: flex;
  flex-direction: column; align-items: center; justify-content: center; padding: 4px 0;
  cursor: pointer; transition: color 0.2s; outline: none; line-height: 1.2;
}
.nav-btn .material-icons { font-size: 1.6rem; margin-bottom: 2px; }
.nav-btn.active { color: var(--nav-active); }

.view { display: none; animation: fadeIn 0.3s; }
.view.active { display: block; }
body:not(.reel-active) .view { padding: 0 var(--grid-gap); } 


.categories-list {
  display: flex; gap: 8px; padding: 12px var(--grid-gap) 8px var(--grid-gap);
  overflow-x: auto; margin-bottom: 8px; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.categories-list::-webkit-scrollbar { display: none; }
.category-btn {
  background: var(--card); color: var(--text); border: 1px solid var(--primary); border-radius: 20px;
  padding: 0.5rem 1rem; font-size: 0.9rem; cursor: pointer; font-weight: 500;
  transition: background 0.2s, color 0.2s, transform 0.1s; white-space: nowrap; flex-shrink: 0;
}
.category-btn.active, .category-btn:hover { background: var(--primary); color: var(--bg); transform: scale(1.03); }
.category-btn:active { transform: scale(0.97); }

.fullscreen-modal {
  display: none; position: fixed; z-index: 1000; 
  left: 0; top: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.92);
  justify-content: center; align-items: center; animation: fadeIn 0.2s;
}
.fullscreen-modal.active { display: flex; }
.fullscreen-content {
  position: relative; width: 90vw; height: 85vh; max-width: 600px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.fullscreen-content img {
  max-width: 100%; max-height: calc(100% - 70px); border-radius: var(--card-border-radius);
  box-shadow: 0 4px 24px rgba(0,0,0,0.5); object-fit: contain;
}
.fullscreen-actions { display: flex; gap: 1rem; justify-content: center; align-items: center; margin-top: 1rem; width: 100%;}
.fullscreen-actions .download-btn { width: auto; padding: 0.6rem 1.2rem;}
.fullscreen-actions .heart-btn { position: static; background: rgba(50,50,50,0.7);}
.fullscreen-actions .close-btn { background: var(--accent);}
.close-btn { color: #fff; border: none; border-radius: 50%; padding: 0.6rem; font-size: 1.5rem; cursor: pointer; transition: background 0.2s; display: flex; align-items: center; justify-content: center;}
.close-btn:hover { background: #d63031; }

.pagination { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin: 1.5rem var(--grid-gap) 1rem var(--grid-gap); padding: 0.5rem; background-color: var(--card); border-radius: var(--card-border-radius);}
.pag-btn { background: var(--primary); color: var(--bg); border: none; border-radius: 8px; padding: 0.5rem 0.8rem; font-size: 0.9rem; cursor: pointer; font-weight: 600; transition: background 0.2s, opacity 0.2s; display: flex; align-items: center; gap: 0.3rem;}
.pag-btn .material-icons { font-size: 1.2rem; }
.pag-btn:disabled { background: #555; color: #888; cursor: not-allowed; opacity: 0.7; }
#random-page { color: var(--text); font-size: 0.9rem; font-weight: 500; }

.carousel { display: flex; align-items: center; overflow: hidden; position: relative; padding: 0 var(--grid-gap); margin: 0 calc(-1 * var(--grid-gap)); }
.carousel-btn {
  background: rgba(30, 30, 30, 0.5); color: #fff; border: none; border-radius: 50%;
  width: 36px; height: 36px; cursor: pointer; position: absolute; z-index: 5;
  top: 50%; transform: translateY(-50%); display: flex; align-items: center; justify-content: center;
  transition: background-color 0.2s;
}
.carousel-btn:hover { background: rgba(0, 184, 148, 0.7); }
.carousel-btn .material-icons { font-size: 24px; }
.carousel-btn.left { left: calc(var(--grid-gap) + 5px) ; }
.carousel-btn.right { right: calc(var(--grid-gap) + 5px); }

.ui-message-toast {
  position: fixed; bottom: 20px; 
  left: 50%; transform: translateX(-50%);
  color: white; padding: 12px 20px; border-radius: 8px;
  z-index: 2000; box-shadow: 0 2px 10px rgba(0,0,0,0.2); font-size: 0.9rem; text-align: center;
  opacity: 0; transition: opacity 0.3s ease-in-out, bottom 0.3s ease-in-out; pointer-events: none;
}
.ui-message-toast.show { opacity: 1; bottom: 30px; pointer-events: auto; }
body.reel-active .ui-message-toast { bottom: 20px; } 
body:not(.reel-active) .ui-message-toast { bottom: 75px; } 


/* --- Estilos para Modo Reel --- */
#reel-mode {
    height: 100vh; width: 100vw; overflow: hidden; 
    background-color: #000; padding: 0; position: fixed; 
    top: 0; left: 0; z-index: 150; 
}

.exit-reel-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 160; 
    background-color: rgba(30, 30, 30, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
}
.exit-reel-btn:hover {
    background-color: rgba(50, 50, 50, 0.9);
}
.exit-reel-btn .material-icons {
    font-size: 24px;
}


#reel-container {
    width: 100%; height: 100%; overflow-y: scroll;
    scroll-snap-type: y mandatory; -webkit-overflow-scrolling: touch;
}

.reel-item {
    width: 100%; height: 100vh; scroll-snap-align: start; 
    position: relative; background-size: cover; background-position: center center;
    background-repeat: no-repeat; 
    display: flex; 
    align-items: flex-end;
    padding: 20px; box-sizing: border-box;
}
.reel-item::before {
    content: ''; position: absolute; bottom: 0; left: 0; right: 0;
    height: 30%; background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
    pointer-events: none; 
}
.reel-actions {
    position: absolute;
    right: 15px;
    top: 50%; 
    transform: translateY(-50%);
    z-index: 10; 
    display: flex;
    flex-direction: column; 
    gap: 20px; 
    align-items: center; 
}
.reel-actions .action-btn {
    background-color: rgba(40, 40, 40, 0.75); color: white; border: none;
    border-radius: 50%; width: 55px; height: 55px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background-color 0.2s, transform 0.1s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
.reel-actions .action-btn:active { transform: scale(0.9); }
.reel-actions .action-btn .material-icons { font-size: 28px; } 
.reel-actions .action-btn.favorited .material-icons { color: var(--accent); }

#reel-loader {
    position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
    color: white; background-color: rgba(0,0,0,0.5); padding: 8px 15px; border-radius: 5px;
}

@media (max-width: 600px) {
  h1 { font-size: 1.3rem; } h2 { font-size: 1.1rem; }
  .standard-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
  .carousel-content .wallpaper-card { min-width: 130px; }
  .download-btn { font-size: 0.8rem; padding: 0.5rem 0.8rem; }
  .heart-btn .material-icons { font-size: 1.3rem; }
  .nav-btn { font-size: 0.7rem; } .nav-btn .material-icons { font-size: 1.5rem; }
  .fullscreen-content img { max-height: calc(100% - 60px); }
  .fullscreen-actions { margin-top: 0.8rem; gap: 0.8rem;}
  .pagination { margin: 1rem var(--grid-gap); } .pag-btn { padding: 0.4rem 0.6rem; font-size: 0.8rem; } #random-page { font-size: 0.8rem;}

  .reel-actions { 
    gap: 15px; 
    right: 10px;
  }
  .reel-actions .action-btn { width: 50px; height: 50px; }
  .reel-actions .action-btn .material-icons { font-size: 24px; }
  .exit-reel-btn { top: 10px; left: 10px; width: 35px; height: 35px; }
  .exit-reel-btn .material-icons { font-size: 20px; }
}

@media (max-width: 380px) {
    .standard-grid { grid-template-columns: repeat(2, 1fr); }
    .carousel-content .wallpaper-card { min-width: 120px; }
}


/* --- ESTILOS PARA EL NUEVO MENÚ DE IDIOMAS --- */

/* Contenedor principal del switcher */
.language-switcher {
  position: absolute;
  top: 50%;
  right: 15px;
  transform: translateY(-50%);
  z-index: 110;
}

/* Botón principal que muestra la bandera actual */
.lang-switcher-btn {
  background-color: var(--card);
  color: var(--text);
  border: 1px solid #444;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 1.2rem; /* Aumenta el tamaño de la bandera */
  transition: background-color 0.2s;
}

.lang-switcher-btn:hover {
  background-color: #3a3f47;
}

.lang-switcher-btn .material-icons {
  font-size: 20px;
  transition: transform 0.3s ease;
}

/* Rotar la flecha cuando el menú está abierto */
.language-switcher.open .lang-switcher-btn .material-icons {
	transform: rotate(180deg);
}

/* Submenú que contiene las opciones */
.lang-submenu {
  display: none; /* Oculto por defecto */
  position: absolute;
  top: calc(100% + 5px); /* Aparece debajo del botón */
  right: 0;
  background-color: var(--card);
  border: 1px solid #444;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  width: 150px;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Mostrar el submenú cuando el contenedor tiene la clase 'open' */
.language-switcher.open .lang-submenu {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* Opciones de idioma individuales */
.lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background-color 0.2s;
}

.lang-option:hover {
  background-color: var(--primary);
  color: var(--bg);
}

.lang-option .flag {
  font-size: 1.2rem;
}

/* Ajuste para el header para que no se solape el título */
header#main-header {
  position: relative;
  padding-right: 70px; /* Asegura espacio para el botón */
}


/* --- ESTILOS PARA LA NUEVA NOTIFICACIÓN DE BIENVENIDA --- */

/* Contenedor de la notificación */
.welcome-notification {
    position: fixed;
    top: 20px;
    right: -100%; /* Empieza fuera de la pantalla */
    width: calc(100% - 40px);
    max-width: 350px;
    background-color: var(--card);
    color: var(--text);
    padding: 15px;
    border-radius: var(--card-border-radius);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 3000;
    transition: right 0.8s cubic-bezier(0.25, 0.8, 0.25, 1); /* Transición suave */
    border-left: 5px solid var(--primary);
}

/* Párrafo dentro de la notificación */
.welcome-notification p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.4;
    flex-grow: 1; /* Ocupa el espacio restante */
}

/* Icono de información */
.welcome-notification > .material-icons {
    font-size: 24px;
    color: var(--primary);
}

/* Botón de cierre */
.close-notification-btn {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
}

.close-notification-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Clase que se añade con JS para mostrar la notificación */
.welcome-notification.show {
    right: 20px;
}