/*
=================================================================
APYMECO - SISTEMA DE TEMAS CLARO/OSCURO
=================================================================

PALETA DE COLORES:

MODO OSCURO (actual):
--bg: #2E2D34            (Fondo principal)
--card: #222226          (Fondo de tarjetas/footer)
--text: #FFFFFF          (Texto principal)
--muted: #D1D2D3         (Texto secundario/bordes)
--primary: #00847B       (Color primario/enlaces)
--primary-hover: #C0A062 (Color primario hover)
--primary-variant: #02928C / #05706B (Variantes del primario)
--border: #D1D2D3        (Bordes)
--nav-bg: #2E2D34        (Fondo navegación)
--footer-bg: #222226     (Fondo footer)
--shadow: #333333        (Sombras)

MODO CLARO:
--bg: #F7F7F8            (Fondo principal)
--card: #FFFFFF          (Fondo de tarjetas)
--text: #1F2328          (Texto principal)
--muted: #59636E         (Texto secundario)
--primary: #2AA9A1       (Color primario - versión más clara de #00847B)
--primary-hover: #B8941C (Color primario hover - versión más oscura de #C0A062)
--primary-variant: #35B5AD / #248A82 (Variantes del primario)
--border: #E3E5E8        (Bordes)
--nav-bg: #FFFFFF        (Fondo navegación)
--footer-bg: #F0F1F3     (Fondo footer)
--shadow: rgba(31, 35, 40, 0.15) (Sombras sutiles)

=================================================================
*/

/* Variables CSS - Sistema por defecto (respeta prefers-color-scheme) */
:root {
    /* Modo oscuro por defecto */
    --bg: #2E2D34;
    --card: #222226;
    --text: #FFFFFF;
    --muted: #D1D2D3;
    --primary: #00847B;
    --primary-hover: #C0A062;
    --primary-variant-1: #02928C;
    --primary-variant-2: #05706B;
    --border: #D1D2D3;
    --nav-bg: #2E2D34;
    --footer-bg: #222226;
    --shadow: #333333;
    --input-bg: #E6E6E6;
    --input-text: #3E3E3F;
    
    /* Transiciones suaves */
    --transition-theme: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Modo claro - aplicado cuando el sistema prefiere claro Y no hay selección manual */
@media (prefers-color-scheme: light) {
    :root {
        --bg: #F7F7F8;
        --card: #FFFFFF;
        --text: #1F2328;
        --muted: #59636E;
        --primary: #2AA9A1;
        --primary-hover: #B8941C;
        --primary-variant-1: #35B5AD;
        --primary-variant-2: #248A82;
        --border: #E3E5E8;
        --nav-bg: #FFFFFF;
        --footer-bg: #222226;
        --shadow: rgba(31, 35, 40, 0.15);
        --input-bg: #FFFFFF;
        --input-text: #1F2328;
    }
}

/* Tema oscuro explícito */
:root[data-theme="dark"] {
    --bg: #2E2D34;
    --card: #222226;
    --text: #FFFFFF;
    --muted: #D1D2D3;
    --primary: #00847B;
    --primary-hover: #C0A062;
    --primary-variant-1: #02928C;
    --primary-variant-2: #05706B;
    --border: #D1D2D3;
    --nav-bg: #2E2D34;
    --footer-bg: #222226;
    --shadow: #333333;
    --input-bg: #E6E6E6;
    --input-text: #3E3E3F;
}

/* Tema claro explícito */
:root[data-theme="light"] {
    --bg: #f5f6f7;
    --card: #FFFFFF;
    --text: #1F2328;
    --muted: #59636E;
    --primary: #2AA9A1;
    --primary-hover: #B8941C;
    --primary-variant-1: #35B5AD;
    --primary-variant-2: #248A82;
    --border: #222226;
    --nav-bg: #FFFFFF;
    --footer-bg: #222226;
    --shadow: rgba(31, 35, 40, 0.15);
    --input-bg: #FFFFFF;
    --input-text: #1F2328;
}

/* Botón de cambio de tema */
.theme-toggle {
    background: none;
    border: 2px solid var(--border);
    border-radius: 50%;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    height: 44px;
    margin-left: 15px;
    padding: 0;
    position: relative;
    transition: var(--transition-theme);
    width: 44px;
}

.theme-toggle:hover,
.theme-toggle:focus {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--card);
    outline: none;
}

.theme-toggle:focus {
    box-shadow: 0 0 0 3px var(--primary-hover);
}

/* Iconos del botón de tema */
.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    display: none;
    width: 20px;
    height: 20px;
}

:root[data-theme="dark"] .theme-toggle .icon-sun,
:root:not([data-theme]) .theme-toggle .icon-sun {
    display: block;
}

:root[data-theme="light"] .theme-toggle .icon-moon {
    display: block;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme]) .theme-toggle .icon-sun {
        display: none;
    }
    
    :root:not([data-theme]) .theme-toggle .icon-moon {
        display: block;
    }
}

/* Ajustes para el header con el botón de tema */
.social {
    display: flex;
    align-items: flex-start;
}

.social .social-links {
    display: flex;
    flex-direction: column;
}

.social .social-links ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Sistema de iconos de redes sociales según tema */
.social-links a {
    position: relative;
    display: inline-block;
}

.social-links a img {
    transition: opacity 0.15s ease;
}

/* En modo oscuro (default): mostrar iconos claros, ocultar verdes */
:root .social-links a img[src*="-h.png"],
:root[data-theme="dark"] .social-links a img[src*="-h.png"] {
    opacity: 0;
    position: absolute;
    top: 0;
    left: 0;
}

:root .social-links a img:not([src*="-h.png"]),
:root[data-theme="dark"] .social-links a img:not([src*="-h.png"]) {
    opacity: 1;
    position: relative;
}

/* En modo claro: mostrar iconos verdes, ocultar claros */
:root[data-theme="light"] .social-links a img[src*="-h.png"] {
    opacity: 1;
    position: relative;
}

:root[data-theme="light"] .social-links a img:not([src*="-h.png"]) {
    opacity: 0;
    position: absolute;
    top: 0;
    left: 0;
}

/* Respeto a prefers-color-scheme cuando no hay tema manual */
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) .social-links a img[src*="-h.png"] {
        opacity: 1;
        position: relative;
    }
    
    :root:not([data-theme]) .social-links a img:not([src*="-h.png"]) {
        opacity: 0;
        position: absolute;
        top: 0;
        left: 0;
    }
}

/* Hover effects - mantener los efectos existentes */
.social-links a:hover img {
    transform: scale(1.1);
}

/* También aplicar el mismo sistema a los iconos de la página de contacto */
.social-contact a {
    position: relative;
    display: inline-block;
}

.social-contact a img {
    transition: opacity 0.15s ease;
}

/* En modo oscuro: mostrar iconos claros en contacto */
:root .social-contact a img[src*="-h.png"],
:root[data-theme="dark"] .social-contact a img[src*="-h.png"] {
    opacity: 0;
    position: absolute;
    top: 0;
    left: 0;
}

:root .social-contact a img:not([src*="-h.png"]),
:root[data-theme="dark"] .social-contact a img:not([src*="-h.png"]) {
    opacity: 1;
    position: relative;
}

/* En modo claro: mostrar iconos verdes en contacto */
:root[data-theme="light"] .social-contact a img[src*="-h.png"] {
    opacity: 1;
    position: relative;
}

:root[data-theme="light"] .social-contact a img:not([src*="-h.png"]) {
    opacity: 0;
    position: absolute;
    top: 0;
    left: 0;
}

/* Respeto a prefers-color-scheme para contacto */
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) .social-contact a img[src*="-h.png"] {
        opacity: 1;
        position: relative;
    }
    
    :root:not([data-theme]) .social-contact a img:not([src*="-h.png"]) {
        opacity: 0;
        position: absolute;
        top: 0;
        left: 0;
    }
}

/* Gradientes específicos para .second-nav según tema */

/* Modo oscuro: gradiente hacia abajo (default) */
:root .second-nav,
:root[data-theme="dark"] .second-nav {
    background: -moz-linear-gradient(top, rgba(0, 0, 0, 0.5) 0%, rgba(255, 255, 255, 0) 100%);
    background: -webkit-linear-gradient(top, rgba(0, 0, 0, 0.5) 0%, rgba(255, 255, 255, 0) 100%);
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5) 0%, rgba(255, 255, 255, 0) 100%);
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#80000000', endColorstr='#00ffffff', GradientType=0);
}

/* Modo claro: gradiente hacia arriba */
:root[data-theme="light"] .second-nav {
    background: -moz-linear-gradient(bottom, rgba(0, 0, 0, 0.5) 0%, rgba(255, 255, 255, 0) 20%);
    background: -webkit-linear-gradient(bottom, rgba(0, 0, 0, 0.5) 0%, rgba(255, 255, 255, 0) 20%);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.5) 0%, rgba(255, 255, 255, 0) 20%);
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#33000000', endColorstr='#00ffffff', GradientType=0);
}

/* Respeto a prefers-color-scheme para gradientes */
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) .second-nav {
        background: -moz-linear-gradient(bottom, rgba(0, 0, 0, 0.5) 0%, rgba(255, 255, 255, 0) 20%);
        background: -webkit-linear-gradient(bottom, rgba(0, 0, 0, 0.5) 0%, rgba(255, 255, 255, 0) 20%);
        background: linear-gradient(to top, rgba(0, 0, 0, 0.5) 0%, rgba(255, 255, 255, 0) 20%);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#33000000', endColorstr='#00ffffff', GradientType=0);
    }
}

/* Responsive para el botón de tema */
@media (max-width: 800px) {
    .theme-toggle {
        height: 36px;
        width: 36px;
        font-size: 16px;
        margin-left: 10px;
    }
    
    .theme-toggle .icon-sun,
    .theme-toggle .icon-moon {
        width: 16px;
        height: 16px;
    }
}