:root {
    --primary-color: #007bff;
    --secondary-color: #2c3e50;
    --accent-color: #28a745;
    --bg-light: #f8f9fa;
    --bg-main: #ffffff;
    --text-color: #495057;
    --heading-color: #212529;
    --border-color: #e0e0e0;
    --border-radius: 12px;
    --shadow-light: 0 4px 15px rgba(0, 0, 0, 0.1);
    --shadow-dark: 0 8px 25px rgba(0, 0, 0, 0.2);
    --nav-bg: #343a40;
}

body[data-theme="dark"] {
    --primary-color: #007bff; 
    --secondary-color: #e9ecef; 
    --accent-color: #28a745;
    --bg-light: #1c1c27; 
    --bg-main: #12121d; 
    --text-color: #adb5bd; 
    --heading-color: #ffffff;
    --border-color: #495057;
    --shadow-light: 0 4px 15px rgba(0, 0, 0, 0.2);
    --shadow-dark: 0 8px 25px rgba(0, 0, 0, 0.4);
    --nav-bg: #12121d;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Poppins', sans-serif;
    color: var(--text-color);
    line-height: 1.6;
    background-color: var(--bg-main);
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4, h5, h6, .company, .institution {
    font-family: 'Montserrat', sans-serif;
    color: var(--heading-color);
    line-height: 1.2;
    transition: color 0.3s ease;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--accent-color);
}

ul {
    list-style: none;
}

.navbar {
    background-color: var(--nav-bg);
    padding: 15px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-dark);
    animation: fadeInDown 1s ease-out;
    transition: background-color 0.3s ease;
}

.nav-brand {
    color: #fff;
    font-size: 1.8em;
    font-weight: 700;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-logo {
    height: 38px;
    width: 38px;
    object-fit: contain;
    border-radius: 50%;
    filter: drop-shadow(0 0 6px rgba(0, 123, 255, 0.6));
    transition: filter 0.3s ease, transform 0.3s ease;
}

.nav-logo:hover {
    filter: drop-shadow(0 0 10px rgba(0, 123, 255, 0.9));
    transform: rotate(5deg) scale(1.1);
}

.nav-links {
    flex-grow: 1;
    text-align: center;
}

.nav-links a {
    color: #fff;
    margin: 0 20px;
    font-weight: 400;
    font-size: 0.95em;
    position: relative;
}

.nav-links a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    display: block;
    margin-top: 5px;
    right: 0;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

.nav-links a:hover::after {
    width: 100%;
    left: 0;
    background: var(--accent-color);
}

/* --- BOTONES DE ACCIÓN EN NAVBAR --- */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.theme-btn {
    background: none;
    border: 2px solid #fff;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2em;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

.theme-btn:hover {
    background-color: #fff;
    color: var(--nav-bg);
}

.lang-switcher {
    position: relative;
}

.lang-btn {
    background: none;
    border: 2px solid #fff;
    color: #fff;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.3s ease;
}

.lang-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.lang-dropdown {
    display: none;
    position: absolute;
    top: 120%;
    right: 0;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-dark);
    overflow: hidden;
    z-index: 1001;
}

.lang-dropdown.show {
    display: block;
}

.lang-dropdown a {
    display: block;
    padding: 12px 20px;
    color: var(--heading-color);
    white-space: nowrap;
}

.lang-dropdown a:hover {
    background-color: var(--bg-light);
    color: var(--primary-color);
}

/* --- SECCIÓN HERO --- */
.hero-section {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: #fff;
    position: relative;
    overflow: hidden;
    transition: background 0.3s ease;
}

body[data-theme="dark"] .hero-section {
    background: linear-gradient(135deg, #12121d 0%, #1c1c27 100%);
}

.hero-content {
    max-width: 800px;
    padding: 40px;
    z-index: 1;
    animation: fadeInUp 1.2s ease-out;
}

.hero-pic {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: 6px solid #fff;
    object-fit: cover;
    margin-bottom: 20px;
    box-shadow: var(--shadow-dark);
    animation: zoomIn 1s ease-out;
}

.hero-section h1 {
    font-size: 4em;
    margin-bottom: 10px;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.hero-section .tagline {
    font-size: 1.5em;
    font-weight: 300;
    opacity: 0.9;
    margin-bottom: 40px;
}

.hero-actions .btn {
    margin: 0 15px;
}

/* --- BOTONES --- */
.btn {
    display: inline-block;
    padding: 12px 30px;
    border-radius: 50px;
    font-weight: 600;
    text-transform: uppercase;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.primary-btn {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.primary-btn:hover {
    background-color: transparent;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.secondary-btn {
    background-color: transparent;
    color: #fff;
    border-color: #fff;
}

.secondary-btn:hover {
    background-color: #fff;
    color: var(--primary-color);
}

/* --- SECCIONES GENERALES --- */
.section-container {
    padding: 80px 40px;
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: background-color 0.3s ease;
}

.bg-light {
    background-color: var(--bg-light);
}

.section-title {
    font-size: 3em;
    margin-bottom: 60px;
    color: var(--heading-color);
    position: relative;
    display: inline-block;
    padding-bottom: 15px;
}

.section-title::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background-color: var(--primary-color);
    border-radius: 2px;
}

/* --- SOBRE MÍ --- */
.about-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    max-width: 800px;
    margin: 0 auto;
    text-align: left;
}

.about-content p {
    font-size: 1.1em;
    line-height: 1.8;
}

.personal-details {
    margin-top: 30px;
    width: 100%;
}

.personal-details h3 {
    font-size: 1.6em;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.personal-details ul {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.personal-details li {
    font-size: 1.1em;
    display: flex;
    align-items: center;
}

.personal-details li i {
    color: var(--primary-color);
    margin-right: 15px;
    font-size: 1.3em;
}

/* --- HABILIDADES --- */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 40px;
    text-align: left;
    max-width: 1100px;
    margin: 0 auto;
}

.skill-category {
    background-color: var(--bg-main);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
}

.skill-category:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow-dark);
}

.skill-category h3 {
    font-size: 1.8em;
    color: var(--primary-color);
    margin-bottom: 25px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.skill-category ul {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.skill-category li {
    font-size: 1em;
    display: flex;
    align-items: center;
    transition: color 0.3s ease;
}

.skill-category li:hover {
    color: var(--primary-color);
}

.skill-category li i {
    margin-right: 12px;
    font-size: 1.2em;
    transition: color 0.3s ease;
}

.skill-category li:hover i {
    color: var(--primary-color);
}

/* Barras de Progreso de Idiomas */
.language-item {
    margin-bottom: 20px;
}

.language-item p {
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.progress-bar-container {
    background-color: var(--border-color);
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    background: linear-gradient(to right, var(--primary-color), var(--accent-color));
    height: 100%;
    border-radius: 5px;
    width: 0%; /* Inicialmente 0% para animación */
    transition: width 1s ease-out;
    position: relative;
}

.progress-bar-fill::after {
    content: attr(data-level);
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 0.8em;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.progress-bar-fill.animated::after {
    opacity: 1;
}

/* --- EXPERIENCIA (TIMELINE) --- */
.timeline {
    position: relative;
    max-width: 1000px;
    margin: 0 auto;
    padding-bottom: 50px;
}

.timeline::after {
    content: '';
    position: absolute;
    width: 4px;
    background-color: var(--primary-color);
    top: 0;
    bottom: 0;
    left: 50%;
    margin-left: -2px;
}

.timeline-item {
    padding: 10px 0;
    position: relative;
    background-color: inherit;
    width: 50%;
}

.timeline-item::after {
    content: '';
    position: absolute;
    width: 25px;
    height: 25px;
    right: -17px;
    background-color: var(--bg-main);
    border: 4px solid var(--accent-color);
    top: 15px;
    border-radius: 50%;
    z-index: 1;
    transition: background-color 0.3s ease;
}

.timeline-item.left {
    left: 0;
    padding-right: 90px;
}

.timeline-item.right {
    left: 50%;
    padding-left: 90px;
}

.timeline-item.right::after {
    left: -17px;
}

.timeline-content {
    padding: 20px 30px;
    background-color: var(--bg-main);
    position: relative;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    transition: all 0.3s ease;
}

.timeline-content:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-dark);
}

.timeline-content h3 {
    font-size: 1.4em;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.timeline-content .description {
    font-size: 0.95em;
}

/* --- FORMACIÓN & CURSOS --- */
.education-grid, .courses-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    max-width: 1000px;
    margin: 0 auto;
    text-align: left;
}

.education-item, .course-item {
    background-color: var(--bg-main);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    transition: all 0.3s ease;
}

.education-item:hover, .course-item:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-dark);
}

.education-item h3, .course-item h3 {
    font-size: 1.3em;
    color: var(--primary-color);
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.course-item h3 i {
    font-size: 0.9em;
    min-width: 25px;
    text-align: center;
}

.education-item .date, .course-item .details {
    font-size: 0.9em;
}

.badge-new {
    background: linear-gradient(135deg, #ff416c, #ff4b2b);
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.65em;
    font-weight: 700;
    vertical-align: middle;
    margin-left: 8px;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(255, 65, 108, 0.4);
    display: inline-block;
    position: relative;
    top: -2px;
}

/* --- CONTACTO --- */
.contact-info-grid {
    display: flex;
    justify-content: center;
    gap: 50px;
    flex-wrap: wrap;
    margin-bottom: 40px;
}

.contact-item {
    text-align: center;
    transition: transform 0.3s ease, color 0.3s ease;
}

.contact-item:hover {
    transform: translateY(-5px);
    color: var(--primary-color);
}

.contact-item i {
    color: var(--primary-color);
    margin-bottom: 15px;
    transition: color 0.3s ease;
}

.contact-item:hover i {
    color: var(--accent-color);
}

.contact-item p {
    font-size: 1.1em;
    font-weight: 600;
}

.footer-note {
    font-size: 1.1em;
    font-style: italic;
}

/* --- FOOTER --- */
footer {
    background-color: var(--nav-bg);
    color: #fff;
    text-align: center;
    padding: 25px 0;
    font-size: 0.9em;
    transition: background-color 0.3s ease;
}

/* --- ANIMACIONES Y RESPONSIVE --- */
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }
@keyframes zoomIn { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes pulse-glow { 0%, 100% { box-shadow: 0 0 8px rgba(0,123,255,0.4); } 50% { box-shadow: 0 0 20px rgba(0,123,255,0.9); } }

.animate-on-scroll { opacity: 0; transform: translateY(50px); transition: opacity 0.8s ease-out, transform 0.8s ease-out; }
.animate-on-scroll.is-visible { opacity: 1; transform: translateY(0); }

/* --- BARRA DE PROGRESO DE LECTURA --- */
#read-progress {
    position: fixed;
    top: 0; left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(to right, var(--primary-color), var(--accent-color));
    z-index: 9999;
    transition: width 0.1s linear;
}

/* --- PARTÍCULAS (Canvas hero) --- */
#particles-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* --- TYPING CURSOR --- */
.typing-cursor {
    display: inline-block;
    animation: blink 0.8s infinite;
    color: rgba(255,255,255,0.8);
    font-weight: 300;
    margin-left: 2px;
}

/* --- BOTÓN DESCARGAR CV --- */
.cv-btn {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: #fff !important;
    border-color: transparent;
}
.cv-btn:hover {
    background: linear-gradient(135deg, #20c997, #28a745);
    color: #fff !important;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(40,167,69,0.5);
}

/* --- PROYECTOS GITHUB --- */
.projects-subtitle {
    font-size: 1.1em;
    color: var(--text-color);
    margin-bottom: 40px;
    margin-top: -40px;
}

.subsection-title {
    font-size: 1.8em;
    color: var(--primary-color);
    margin-top: 50px;
    margin-bottom: 25px;
    text-align: center;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    max-width: 1100px;
    margin: 0 auto 40px;
    text-align: left;
}

.project-card {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    position: relative;
    overflow: hidden;
}

.project-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 3px;
    background: linear-gradient(to right, var(--primary-color), var(--accent-color));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.project-card:hover::before { transform: scaleX(1); }

.project-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-dark);
    border-color: var(--primary-color);
}

.project-card-header { display: flex; align-items: center; gap: 10px; }
.project-card-header i { color: var(--text-color); font-size: 1.3em; }

.project-card h3 {
    font-size: 1.05em;
    color: var(--primary-color);
    margin: 0;
    word-break: break-all;
}

.project-card p { font-size: 0.9em; color: var(--text-color); flex-grow: 1; line-height: 1.6; }

.project-card-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.project-lang {
    background-color: var(--bg-light);
    color: var(--primary-color);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78em;
    font-weight: 600;
    border: 1px solid var(--border-color);
}

.project-stars { font-size: 0.85em; color: var(--text-color); }

.project-card-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.9em;
    margin-top: 5px;
    transition: gap 0.2s ease, color 0.2s ease;
}
.project-card-link:hover { gap: 12px; color: var(--accent-color); }

.projects-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.projects-footer { text-align: center; margin-top: 10px; }

.github-all-btn { display: inline-flex; align-items: center; gap: 10px; }

@media (max-width: 992px) {
    .nav-links { display: none; }
    .nav-brand { flex-grow: 1; text-align: left; }
    .hero-section h1 { font-size: 3em; }
    .section-title { font-size: 2.5em; }
    .timeline::after { left: 20px; }
    .timeline-item { width: 100%; padding-left: 60px; padding-right: 15px; }
    .timeline-item::after { left: 13px; }
    .timeline-item.right { left: 0%; padding-left: 60px; }
    .timeline-content { text-align: left; }
    .skills-grid, .education-grid, .courses-list { grid-template-columns: 1fr; }
}

@media (max-width: 576px) {
    .hero-section h1 { font-size: 2.2em; }
    .hero-actions { flex-direction: column; }
    .btn { width: 80%; margin: 10px auto; }
    .section-container { padding: 60px 20px; }
    .section-title { font-size: 2em; }
    .personal-details ul { grid-template-columns: 1fr; }
    .projects-grid { grid-template-columns: 1fr; }
}