/**
 * Estilos específicos para el botón de cambio de tema
 * News AI Pal - JavocSoft
 */

/* Animaciones para el ícono del botón */
@keyframes sun-rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(180deg);
    }
}

@keyframes moon-rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(-180deg);
    }
}

/* Mejorar la apariencia del botón */
.theme-toggle-btn {
    position: relative;
    padding: 8px;    
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    color: var(--dark-color);
    background: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    outline: none;
    flex-shrink: 0; /* Evita que el botón se encoja cuando falta espacio */
}

/* Efectos hover y focus */
.theme-toggle-btn:hover {
    background-color: rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.theme-toggle-btn:focus {
    box-shadow: 0 0 0 3px rgba(58, 134, 255, 0.3);
}

.theme-toggle-btn:active {
    transform: translateY(0);
}

/* Los íconos dentro del botón */
.theme-toggle-btn i {
    font-size: 18px;
    transition: transform 0.5s ease, color 0.3s ease;
    /* Aseguramos que el ícono esté centrado */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Efecto de brillo para el icono del sol en modo oscuro */
[data-theme="dark"] .theme-toggle-btn i.fa-sun {
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    color: #fff;
}

/* Aumentar el efecto de brillo al hacer hover */
[data-theme="dark"] .theme-toggle-btn:hover i.fa-sun {
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.7), 0 0 12px rgba(255, 223, 128, 0.6);
    color: #fff;
}

/* Animación al pasar a modo oscuro */
[data-theme="dark"] .theme-toggle-btn i.fa-sun {
    animation: sun-rotate 0.5s ease forwards;
}

/* Animación al pasar a modo claro */
[data-theme="light"] .theme-toggle-btn i.fa-moon {
    animation: moon-rotate 0.5s ease forwards;
}

/* Ajustes para modo oscuro */
[data-theme="dark"] .theme-toggle-btn {
    color: #f8f9fa; /* Color claro para el icono del sol en modo oscuro */
    background-color: rgba(255, 255, 255, 0.05); /* Fondo sutil para mejor contraste */
}

[data-theme="dark"] .theme-toggle-btn:hover {
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff; /* Blanco puro al hacer hover para mejor visibilidad */
}

[data-theme="dark"] .theme-toggle-btn:focus {
    box-shadow: 0 0 0 3px rgba(78, 149, 255, 0.5);
    color: #ffffff;
}

/* Borde sutil para mejor definición */
.theme-toggle-btn {
    border: 1px solid transparent;
}

[data-theme="light"] .theme-toggle-btn:hover {
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .theme-toggle-btn:hover {
    border-color: rgba(255, 255, 255, 0.1);
}

/* Indicador de animación cuando se cambia el tema */
html.theme-transitioning .theme-toggle-btn i {
    transform: scale(1.2);
    transition: transform 0.3s ease;
}

/* Efecto de onda al hacer clic */
.theme-toggle-btn::after {
    content: "";
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: rgba(58, 134, 255, 0.3);
    opacity: 0;
    transform: scale(0);
    transition: all 0.5s ease;
}

.theme-toggle-btn:active::after {
    transform: scale(1.5);
    opacity: 0;
    transition: 0s;
}

/* Retoques para pantallas pequeñas */
@media (max-width: 576px) {
    .theme-toggle-btn {
        margin-right: 0;
        width: 36px;
        height: 36px;
    }
    
    /* Estilos específicos para el botón junto al buscador en móviles */
    .theme-toggle-search {
        margin-right: 3px;
    }
    
    /* Ajuste para dejar más espacio al buscador en móviles */
    header .search-container {
        min-width: 120px;
    }
}

/* Clase adicional para el botón en modo oscuro activo */
.theme-toggle-btn.dark-mode-active {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Estilos específicos para los iconos */
.theme-toggle-btn .sun-icon {
    color: #ffffff;
    font-size: 19px; /* Ligeramente más grande para mejor visibilidad */
}

.theme-toggle-btn .moon-icon {
    color: #333333;
    font-size: 18px;
}

/* Mejor contraste en modo oscuro */
[data-theme="dark"] .theme-toggle-btn {
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

/* Accesibilidad: aseguramos contraste adecuado para lectores de pantalla */
.theme-toggle-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
