/* ==========================================================================
   1. VARIABLES DE DISEÑO (Soporte Nativo de Temas)
   ========================================================================= */
:root {
    /* Modo Oscuro (Por defecto) */
    --bg-color: #0e0e11;
    --card-bg: #16161a;
    --border-color: #24242b;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --accent: #f59e0b;
    --accent-hover: #d97706;
    --max-width: 1200px;
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

body.light-mode {
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
}

/* ==========================================================================
   2. RESET Y REGLAS GLOBALES Y ANIMACIONES
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.4s cubic-bezier(0.16, 1, 0.3, 1), color 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

body {
    overflow-x: hidden;
    background-color: var(--bg-color);
    color: var(--text-main);
    transition: background-color 0.4s cubic-bezier(0.16, 1, 0.3, 1), color 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

a {
    text-decoration: none;
    color: inherit;
}

::selection {
    background-color: rgba(245, 158, 11, 0.25);
    color: var(--text-main);
}

/* Animaciones globales de entrada (Aceleración Premium) */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.anim-fade-in {
    animation: fadeInUp 1s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.anim-delay-1 { animation-delay: 0.12s; }
.anim-delay-2 { animation-delay: 0.24s; }
.anim-delay-3 { animation-delay: 0.36s; }

/* ==========================================================================
   3. COMPONENTES REUTILIZABLES (Navbar, Botones, Switch de Modo)
   ========================================================================== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: rgba(14, 14, 17, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    transition: background-color 0.4s, border-color 0.4s;

    body.light-mode & {
        background-color: rgba(248, 250, 252, 0.75);
    }

    .nav-container {
        max-width: var(--max-width);
        margin: 0 auto;
        padding: 1.2rem 2rem;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        position: relative;
    }

    .logo {
        font-weight: 900;
        letter-spacing: 2px;
        font-size: 1.5rem;
        color: var(--text-main);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);

        &:hover {
            transform: scale(1.03);
        }

        span {
            color: var(--accent);
        }
    }

    .nav-actions {
        display: flex;
        align-items: center;
        gap: 1rem;
    }

    /* SWITCH DE MODO CON GIRO ELÁSTICO */
    .theme-toggle {
        background: none;
        border: 1px solid var(--border-color);
        padding: 0.5rem;
        border-radius: 8px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);

        &:hover {
            border-color: var(--accent);
            transform: scale(1.1) rotate(15deg);
            background-color: rgba(245, 158, 11, 0.05);
        }
        
        &:active {
            transform: scale(0.95);
        }

        img {
            width: 18px;
            height: 18px;
            object-fit: contain;
        }

        .sun-icon { display: block; }
        .moon-icon { display: none; }

        body.light-mode & {
            .sun-icon { display: none; }
            .moon-icon { display: block; }
        }
    }

    .nav-links {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 2.5rem;

        a {
            font-size: 0.9rem;
            font-weight: 500;
            color: var(--text-muted);
            transition: color 0.3s ease;
            position: relative;
            padding: 0.4rem 0;

            /* EFECTO DE LA BARRITA EXPANSIVA DESDE EL CENTRO */
            &::after {
                content: '';
                position: absolute;
                bottom: 0;
                left: 50%;
                width: 0;
                height: 2px;
                background-color: var(--accent);
                transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
            }

            &:hover {
                color: var(--text-main);
                
                &::after {
                    width: 100%;
                    left: 0;
                }
            }

            /* Mantener la barra fija al 100% solo si está activo */
            &.active {
                color: var(--text-main);

                &::after {
                    width: 100%;
                    left: 0;
                }
            }

            /* Botón de contacto con micro-elevación */
            &.nav-btn {
                color: var(--text-main);
                background-color: rgba(255, 255, 255, 0.02);
                padding: 0.5rem 1.2rem;
                border-radius: 8px;
                border: 1px solid var(--border-color);
                transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);

                &:hover {
                    background-color: var(--accent);
                    color: #0e0e11;
                    border-color: var(--accent);
                    transform: translateY(-2px);
                    box-shadow: 0 8px 20px rgba(245, 158, 11, 0.15);
                }

                &.active {
                    background-color: var(--accent);
                    color: #0e0e11;
                    border-color: var(--accent);
                }

                &::after {
                    display: none;
                }
            }
        }
    }
}

/* BOTÓN HAMBURGUESA PARA MÓVILES */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 24px;
    height: 18px;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 1100;
    transition: transform 0.3s ease;

    &:active {
        transform: scale(0.9);
    }

    .bar {
        width: 100%;
        height: 2px;
        background-color: var(--text-main);
        transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
}

/* BOTONES GLOBALES CON ANIMACIÓN ELÁSTICA */
.btn {
    padding: 1rem 2.4rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    display: inline-block;

    &.btn-primary {
        background-color: var(--accent);
        color: #0e0e11;

        &:hover {
            background-color: var(--accent-hover);
            transform: translateY(-4px);
            box-shadow: 0 12px 30px rgba(245, 158, 11, 0.3);
        }

        &:active {
            transform: translateY(-1px);
        }
    }

    &.btn-secondary {
        border: 1px solid var(--border-color);
        color: var(--text-main);
        background-color: transparent;

        &:hover {
            border-color: var(--text-main);
            background-color: rgba(255, 255, 255, 0.03);
            transform: translateY(-2px);
        }

        body.light-mode & {
            &:hover {
                background-color: rgba(0, 0, 0, 0.02);
            }
        }
    }

    &.btn-block {
        width: 100%;
        text-align: center;
        border: none;
        font-size: 1rem;
    }
}

/* SECCIONES ESTÁNDAR */
.section {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 14rem 2rem 10rem 2rem;

    .section-header {
        margin-bottom: 5rem;
        max-width: 600px;

        .section-tag {
            display: inline-block;
            font-size: 0.75rem;
            text-transform: uppercase;
            letter-spacing: 2px;
            color: var(--accent);
            margin-bottom: 0.75rem;
            font-weight: 600;
        }

        h2 {
            font-size: 2.5rem;
            font-weight: 800;
            letter-spacing: -0.5px;
            margin-bottom: 1rem;
        }

        p {
            color: var(--text-muted);
            font-size: 1.1rem;
            line-height: 1.6;
            font-weight: 300;
        }
    }
}

/* ==========================================================================
   4. ESTILOS ESPECÍFICOS DE LA HOME (HERO)
   ========================================================================== */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 140px 2rem 0 2rem;
    text-align: center;

    .hero-content {
        max-width: 850px;
    }

    .badge {
        display: inline-block;
        padding: 0.4rem 1.2rem;
        border-radius: 50px;
        background-color: rgba(245, 158, 11, 0.05);
        border: 1px solid rgba(245, 158, 11, 0.15);
        color: var(--accent);
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 1.5px;
        margin-bottom: 2.5rem;
    }

    .hero-title {
        font-size: 4rem;
        font-weight: 900;
        line-height: 1.15;
        letter-spacing: -1.5px;
        margin-bottom: 1.5rem;
        color: var(--text-main);
        background: linear-gradient(to bottom right, var(--text-main) 60%, var(--text-muted));
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
    }

    .hero-subtitle {
        font-size: 1.25rem;
        color: var(--text-muted);
        font-weight: 400;
        max-width: 680px;
        margin: 0 auto 3.5rem auto;
        line-height: 1.6;
    }

    .hero-buttons {
        display: flex;
        gap: 1.2rem;
        justify-content: center;
    }
}

/* ==========================================================================
   5. GALERÍA DE PROYECTOS CON ZOOM FLUIDO INTERNO
   ========================================================================== */
.projects-section {
    .projects-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
        gap: 3rem;
    }

    .project-card-link {
        color: inherit;
        display: block;
    }

    .project-card {
        background-color: var(--card-bg);
        border: 1px solid var(--border-color);
        border-radius: 20px;
        overflow: hidden;
        transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1) !important;

        &:hover {
            border-color: rgba(245, 158, 11, 0.35);
            transform: translateY(-8px);
            box-shadow: 0 24px 48px rgba(0, 0, 0, 0.06);

            body:not(.light-mode) & {
                box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
            }

            /* Hace que el texto simulado de previsualización crezca */
            .project-image span {
                transform: scale(1.08);
                color: var(--accent);
            }
        }

        .project-image {
            aspect-ratio: 16 / 10;
            background-color: rgba(0, 0, 0, 0.1);
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-muted);
            font-weight: 600;
            font-size: 1.1rem;
            border-bottom: 1px solid var(--border-color);
            overflow: hidden;

            body:not(.light-mode) & {
                background-color: #121216;
            }

            /* Transición elástica para la imagen o texto de previsualización */
            span {
                transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
                display: inline-block;
            }
        }

        .project-info {
            padding: 2.5rem;

            .project-category {
                font-size: 0.75rem;
                text-transform: uppercase;
                font-weight: 700;
                color: var(--accent);
                letter-spacing: 1.5px;
            }

            h3 {
                font-size: 1.6rem;
                margin: 0.6rem 0;
                font-weight: 800;
                letter-spacing: -0.3px;
            }

            p {
                color: var(--text-muted);
                font-size: 0.95rem;
                line-height: 1.6;
                font-weight: 300;
            }
        }
    }
}

/* ==========================================================================
   6. SECCIÓN SOBRE MÍ Y SETUP
   ========================================================================== */
.about-section {
    .about-grid {
        display: grid;
        grid-template-columns: 1.5fr 1fr;
        gap: 4rem;
        margin-bottom: 6rem;
    }

    .about-text {
        h3 {
            font-size: 1.5rem;
            font-weight: 700;
            margin-bottom: 1.5rem;
            border-left: 3px solid var(--accent);
            padding-left: 1rem;
        }

        p {
            color: var(--text-muted);
            font-size: 1.05rem;
            line-height: 1.7;
            font-weight: 300;
            margin-bottom: 1.5rem;
        }
    }

    .about-skills {
        h3 {
            font-size: 1.5rem;
            font-weight: 700;
            margin-bottom: 1.5rem;
        }

        .skills-list {
            display: flex;
            flex-wrap: wrap;
            gap: 0.75rem;

            .skill-item {
                background-color: var(--card-bg);
                border: 1px solid var(--border-color);
                padding: 0.6rem 1.2rem;
                border-radius: 8px;
                font-size: 0.9rem;
                font-weight: 500;
                color: var(--text-main);
                transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);

                &:hover {
                    border-color: var(--accent);
                    transform: scale(1.04);
                    background-color: rgba(245, 158, 11, 0.02);
                }
            }
        }
    }

    .setup-container {
        border-top: 1px solid var(--border-color);
        padding-top: 5rem;

        h3 {
            font-size: 1.8rem;
            font-weight: 800;
            margin-bottom: 0.5rem;
        }

        .setup-intro {
            color: var(--text-muted);
            font-size: 1.05rem;
            font-weight: 300;
            margin-bottom: 3rem;
        }

        .setup-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
            gap: 1.5rem;
        }

        .setup-card {
            background-color: var(--card-bg);
            border: 1px solid var(--border-color);
            padding: 2rem;
            border-radius: 16px;
            transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;

            &:hover {
                transform: translateY(-5px);
                border-color: rgba(245, 158, 11, 0.2);
                box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
            }

            h4 {
                font-size: 0.8rem;
                text-transform: uppercase;
                letter-spacing: 1px;
                color: var(--accent);
                margin-bottom: 0.5rem;
            }

            p {
                font-size: 1.1rem;
                font-weight: 600;
                line-height: 1.4;
                color: var(--text-main);
            }
        }
    }
}

/* ==========================================================================
   7. FORMULARIO DE CONTACTO INDEPENDIENTE
   ========================================================================== */
.contacto-section {
    .contacto-form {
        max-width: 750px;
        margin: 0 auto;
        background-color: var(--card-bg);
        border: 1px solid var(--border-color);
        padding: 4rem;
        border-radius: 24px;
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.03);

        body:not(.light-mode) & {
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
        }

        .form-group-row {
            display: flex;
            gap: 1.5rem;
            margin-bottom: 1.5rem;

            .form-group {
                margin-bottom: 0;
                flex: 1;
            }
        }

        .form-group {
            margin-bottom: 1.75rem;
            display: flex;
            flex-direction: column;
            gap: 0.6rem;

            label {
                font-size: 0.85rem;
                font-weight: 600;
                color: var(--text-main);
                letter-spacing: 0.5px;
            }

            input,
            textarea {
                background-color: var(--bg-color);
                border: 1px solid var(--border-color);
                padding: 1.1rem;
                border-radius: 10px;
                color: var(--text-main);
                font-family: inherit;
                font-size: 0.95rem;
                transition: all 0.3s ease;

                &:focus {
                    outline: none;
                    border-color: var(--accent);
                    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.12);
                }

                &::placeholder {
                    color: var(--text-muted);
                }
            }

            textarea {
                resize: vertical;
            }
        }
    }
}

/* ==========================================================================
   8. NOTIFICACIÓN COMPONENTE TOASTIFY NATIVO
   ========================================================================== */
.toast-notificacion {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 2rem;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    z-index: 2000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid transparent;

    &.visible {
        transform: translateY(0);
        opacity: 1;
    }

    &.success {
        background-color: #10b981;
        color: #06110d;
    }

    &.error {
        background-color: #ef4444;
        color: #ffffff;
    }
}

/* ==========================================================================
   9. PÁGINAS CASOS DE ESTUDIO / DETALLES DE PROYECTO
   ========================================================================== */
.project-detail-section {
    .project-detail-layout {
        display: grid;
        grid-template-columns: 2fr 1fr;
        gap: 5rem;
        margin-top: 2rem;
    }

    .project-main-content {
        display: flex;
        flex-direction: column;
        gap: 4rem;

        .content-block {
            h3 {
                font-size: 1.6rem;
                font-weight: 700;
                margin-bottom: 1.2rem;
                border-left: 3px solid var(--accent);
                padding-left: 1rem;
            }

            p {
                color: var(--text-muted);
                font-size: 1.05rem;
                line-height: 1.7;
                font-weight: 300;
                margin-bottom: 1rem;
            }
        }
    }

    .project-sidebar {
        display: flex;
        flex-direction: column;
        gap: 2rem;

        .sidebar-box {
            background-color: var(--card-bg);
            border: 1px solid var(--border-color);
            padding: 2.5rem;
            border-radius: 16px;

            h4 {
                font-size: 0.85rem;
                text-transform: uppercase;
                letter-spacing: 1px;
                color: var(--accent);
                margin-bottom: 1.25rem;
                font-weight: 700;
            }

            p {
                color: var(--text-muted);
                font-size: 0.95rem;
                line-height: 1.6;
                margin-bottom: 0.75rem;

                strong {
                    color: var(--text-main);
                }
            }

            .tech-list {
                list-style: none;
                display: flex;
                flex-direction: column;
                gap: 0.6rem;
                color: var(--text-muted);
                font-size: 0.95rem;
                font-weight: 400;

                li::before {
                    content: "• ";
                    color: var(--accent);
                    font-weight: bold;
                }
            }
        }
    }
}

/* ==========================================================================
   10. FOOTER GLOBAL
   ========================================================================== */
.footer {
    background-color: #09090b;
    border-top: 1px solid var(--border-color);
    padding: 5rem 2rem 2rem 2rem;
    transition: background-color 0.3s ease, border-color 0.3s ease;

    body.light-mode & {
        background-color: #f1f5f9;
    }

    .footer-container {
        max-width: var(--max-width);
        margin: 0 auto;
        display: grid;
        grid-template-columns: 2fr 1fr 1fr;
        gap: 4rem;
        margin-bottom: 4rem;
    }

    .footer-brand {
        max-width: 360px;

        .logo {
            font-weight: 900;
            font-size: 1.3rem;
            letter-spacing: 1px;
            display: inline-block;
            margin-bottom: 1rem;

            span {
                color: var(--accent);
            }
        }

        p {
            color: var(--text-muted);
            font-size: 0.95rem;
            line-height: 1.6;
            font-weight: 300;
        }
    }

    .footer-nav,
    .footer-social {
        h3 {
            font-size: 0.9rem;
            text-transform: uppercase;
            letter-spacing: 1px;
            margin-bottom: 1.25rem;
            color: var(--text-main);
            font-weight: 700;
        }

        ul {
            list-style: none;
            display: flex;
            flex-direction: column;
            gap: 0.75rem;

            a {
                color: var(--text-muted);
                font-size: 0.95rem;
                transition: color 0.2s ease;

                &:hover {
                    color: var(--accent);
                }
            }
        }
    }

    .footer-bottom {
        border-top: 1px solid var(--border-color);
        padding-top: 2rem;

        .footer-bottom-container {
            max-width: var(--max-width);
            margin: 0 auto;
            display: flex;
            justify-content: space-between;
            align-items: center;
            color: var(--text-muted);
            font-size: 0.85rem;

            .footer-credit {
                font-weight: 300;
            }
        }
    }
}

/* ==========================================================================
   11. RESPONSIVE Y MEDIA QUERIES (Nesting)
   ========================================================================== */
@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }

    .navbar {
        .nav-container {
            flex-direction: row;
            justify-content: space-between;
            padding: 1.2rem 1.5rem;
        }

        .nav-actions {
            margin-left: auto;
        }

        .theme-toggle {
            position: relative;
            left: auto;
            margin-right: 0;
        }

        .nav-links {
            display: none;

            &.mobile-open {
                display: flex;
                flex-direction: column;
                position: fixed;
                top: 75px;
                left: 0;
                width: 100%;
                height: calc(100vh - 75px);
                background-color: var(--bg-color);
                padding: 3rem 2rem;
                gap: 2rem;
                align-items: flex-start;
                border-top: 1px solid var(--border-color);
                z-index: 999;
                justify-content: flex-start;

                a {
                    font-size: 1.5rem;
                    width: 100%;
                    text-align: left;

                    &.nav-btn {
                        text-align: center;
                        margin-top: 1rem;
                    }

                    &::after {
                        display: none;
                    }
                }
            }
        }
    }

    .hero {
        padding-top: 16px;

        .hero-title {
            font-size: 2.6rem;
        }

        .hero-subtitle {
            font-size: 1.1rem;
        }

        .hero-buttons {
            flex-direction: column;
            width: 100%;

            .btn {
                width: 100%;
                text-align: center;
            }
        }
    }

    .projects-section {
        .projects-grid {
            grid-template-columns: 1fr;
            gap: 2rem;
        }
    }

    .about-section {
        .about-grid {
            grid-template-columns: 1fr;
            gap: 3rem;
        }
    }

    .contacto-section {
        .contacto-form {
            padding: 2.5rem 1.5rem;

            .form-group-row {
                flex-direction: column;
                gap: 1.5rem;
            }
        }
    }

    .project-detail-section {
        .project-detail-layout {
            grid-template-columns: 1fr;
            gap: 3rem;
        }
    }

    .toast-notificacion {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        text-align: center;
    }

    .footer {
        padding: 4rem 1.5rem 2rem 1.5rem;

        .footer-container {
            grid-template-columns: 1fr;
            gap: 2.5rem;
            margin-bottom: 3rem;
        }

        .footer-bottom {
            .footer-bottom-container {
                flex-direction: column;
                gap: 0.75rem;
                text-align: center;
            }
        }
    }

    .menu-toggle.is-active {
        .bar:nth-child(1) {
            transform: translateY(8px) rotate(45deg);
        }

        .bar:nth-child(2) {
            opacity: 0;
        }

        .bar:nth-child(3) {
            transform: translateY(-8px) rotate(-45deg);
        }
    }
}