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

:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --secondary: #764ba2;
    --accent: #00d4ff;
    --text: #2d3748;
    --text-light: #718096;
    --text-muted: #a0aec0;
    --bg: #ffffff;
    --bg-alt: #f7fafc;
    --bg-card: #ffffff;
    --shadow: 0 10px 30px rgba(0,0,0,0.1);
    --shadow-lg: 0 20px 60px rgba(0,0,0,0.15);
    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-3: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

body {
    font-family: 'Lato', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    /* flex-grow: 1; is no longer needed with the new sticky footer method. */
}


.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    position: fixed;
    top: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    z-index: 1000;
    padding: 1rem 0;
    box-shadow: 0 2px 20px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
}

nav {
    display: flex;
    align-items: center;
    gap: 1.5rem; /* Aggiunto per spaziatura */
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Fai in modo che il menu occupi lo spazio rimanente e centri il suo contenuto */
#menu {
    flex-grow: 1;
    display: flex;
    justify-content: center;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text);
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    padding: 0.5rem 0;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--gradient-1);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-links a:hover::after {
    width: 100%;
}

.nav-links a:hover {
    color: var(--primary);
}

.mobile-menu {
    display: none;
    flex-direction: column;
    cursor: pointer;
}

.mobile-menu span {
    width: 25px;
    height: 3px;
    background: var(--text);
    margin: 3px 0;
    transition: 0.3s;
}

/* Hero Section */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #e0eafc 0%, #cfdef3 100%);
    padding-top: 80px;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="%23f0f0f0" stroke-width="0.5"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    opacity: 0.5;
}

.hero-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: center;
    position: relative;
    z-index: 2;
}

.hero-text {
    animation: slideInLeft 1s ease-out;
}

.hero-text h1 {
    font-size: 3.8rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text);
    line-height: 1.1;
}

.hero-text .highlight {
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-text .subtitle {
    font-size: 1.3rem;
    color: var(--text-light);
    margin-bottom: 1rem;
    font-weight: 500;
}

.hero-text p {
    font-size: 1.1rem;
    color: var(--text-light);
    margin-bottom: 2rem;
    line-height: 1.7;
}

.hero-buttons {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-top: 2rem;
}

.hero-social-links {
    display: flex;
    gap: 1rem;
    margin-top: 2.5rem;
}

.hero-social-links a {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    background-color: rgba(255, 255, 255, 0.7);
    border: 1px solid #e2e8f0;
    border-radius: 50%;
    color: var(--text-light);
    font-size: 1rem;
    text-decoration: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.hero-social-links a:hover {
    background-color: var(--primary);
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

/* Language Selector */
.lang-switcher {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    border: 1px solid #e2e8f0;
    padding: 0.25rem 0.5rem;
    border-radius: 20px;
    background-color: var(--bg-alt);
}

.lang-option {
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 15px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
    transition: all 0.3s ease;
}

.lang-option.active,
.lang-option:hover {
    background-color: var(--primary);
    color: white;
}

.btn {
    padding: 14px 28px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: var(--gradient-1);
    color: white;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary);
    border: 2px solid var(--primary);
    backdrop-filter: blur(10px);
}

.btn-secondary:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
}

.social-links-hero {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    color: var(--text-light);
    font-size: 1.2rem;
    text-decoration: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.social-link:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.social-link.linkedin:hover {
    background: #0077b5;
    color: white;
}

.social-link.gmail:hover {
    background: #ea4335;
    color: white;
}

.hero-visual {
    display: flex;
    justify-content: center;
    align-items: center;
    animation: slideInRight 1s ease-out;
}

.hero-image-container {
    width: 300px;
    height: 300px;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 8px solid white;
}

.hero-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* About Section */
.about, .hobbies, .blog, .python-projects {
    padding: 120px 0;
    background: var(--bg-alt);
    position: relative;
}

.github-link {
    text-align: center;
    margin-bottom: 2rem;
}

.blog-posts {
    margin-top: 4rem;
}

.blog-post {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.blog-post h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.hobby-item-centered {
    text-align: center;
}

.hobbies-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 6rem;
}

.hobby-item {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.hobby-item h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.section-title {
    text-align: center;
    font-size: 2.8rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text);
}

.section-subtitle {
    text-align: center;
    font-size: 1.2rem;
    color: var(--text-light);
    margin-bottom: 4rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.about-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: center;
}

.about-text h3 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text);
}

.about-text p {
    margin-bottom: 1.5rem;
    color: var(--text-light);
    line-height: 1.7;
}

.skills-container {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.skill-card {
    background: var(--bg);
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    border: 1px solid #e2e8f0;
}

.skill-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.15);
}

.skill-icon {
    font-size: 2.2rem;
    margin-bottom: 0.8rem;
    display: block;
}

/* Tooltip styles for tech icons */
.tech-icon {
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.tech-icon:hover {
    transform: scale(1.1);
}

/* Custom tooltip styling */
.tech-icon[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
}

.tech-icon[title]:hover::before {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 6px solid rgba(0, 0, 0, 0.8);
    z-index: 1000;
    pointer-events: none;
}

.skill-card h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

/* Projects Section */
.projects {
    padding: 120px 0;
    background: var(--bg);
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 2.5rem;
    margin-top: 4rem;
}

.project-card {
    background: var(--bg-card);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    border: 1px solid #e2e8f0;
}

.project-card:hover {
    transform: translateY(-12px);
    box-shadow: var(--shadow-lg);
}

.project-image {
    height: 220px;
    background: var(--gradient-1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 3.5rem;
    position: relative;
    overflow: hidden;
}

.project-card:nth-child(2) .project-image {
    background: var(--gradient-2);
}

.project-card:nth-child(3) .project-image {
    background: var(--gradient-3);
}

.project-content {
    padding: 2rem;
}

.text-justify {
    text-align: justify;
}

.project-title {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
    color: var(--text);
}

.project-description {
    color: var(--text-light);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.project-tech {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.tech-tag {
    background: var(--bg-alt);
    color: var(--primary);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.tech-icon {
    width: 24px;      
    height: 24px;     
    object-fit: contain;
    margin-right: 5px;   
    vertical-align: middle;
}


.project-links {
    display: flex;
    gap: 1rem;
}

.project-links a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    transition: color 0.3s ease;
}

.project-links a:hover {
    color: var(--primary-dark);
}

/* Contact Section */
.contact {
    padding: 120px 0 0;
    background: var(--bg-alt);
}

.contact-container {
    max-width: 800px;
    margin: 0 auto;
}

.contact-form {
    background: var(--bg-card);
    padding: 3rem;
    border-radius: 20px;
    box-shadow: var(--shadow);
    border: 1px solid #e2e8f0;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.8rem;
    font-weight: 600;
    color: var(--text);
    font-size: 0.95rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: var(--bg);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    height: 140px;
    line-height: 1.6;
}

.submit-btn {
    width: 100%;
    background: var(--gradient-1);
    color: white;
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.4);
}

/* Footer */
footer {
    background: #1a202c; /* Darker background */
    color: #a0aec0; /* Lighter text */
    padding: 3rem 0;
    text-align: center;
    /* margin-top: auto; moved to the placeholder */
}

#footer-placeholder {
    margin-top: auto; /* This is the key for the sticky footer! */
}

.footer-social {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.footer-social a {
    color: #FFFFFF;
    font-size: 1.5rem;
    transition: all 0.3s ease;
}

.footer-social a:hover {
    color: var(--accent);
    transform: translateY(-2px);
}

.footer-text {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
}

/* Animations */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s ease;
}

.animate-on-scroll.animated {
    opacity: 1;
    transform: translateY(0);
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Su mobile, il logo occupa lo spazio per spingere i controlli a destra */
    .logo {
        flex-grow: 1;
    }

    #menu {
        flex-grow: 0; /* Resetta la crescita del menu */
    }

    .nav-links {
        /* Nascondi il menu di navigazione di default */
        display: none;
        /* Posizionamento assoluto per sovrapporsi al contenuto */
        position: absolute;
        top: 100%; /* Posizionalo subito sotto l'header */
        left: 0;
        width: 100%;
        /* Stile del menu a tendina */
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        flex-direction: column;
        align-items: center;
        padding: 1rem 0;
        box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    }

    .nav-links.active {
        /* Mostra il menu quando ha la classe 'active' */
        display: flex;
    }

    .nav-links li {
        margin: 0.5rem 0;
    }

    .mobile-menu {
        display: flex; /* Mostra l'icona hamburger */
        z-index: 1001; /* Assicura che sia sopra altri elementi */
    }

    /* Stile per l'animazione dell'icona hamburger in una 'X' */
    .mobile-menu.is-active span:nth-child(1) {
        transform: rotate(-45deg) translate(-5px, 6px);
    }
    .mobile-menu.is-active span:nth-child(2) {
        opacity: 0;
    }
    .mobile-menu.is-active span:nth-child(3) {
        transform: rotate(45deg) translate(-5px, -6px);
    }

    .hero-content {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 3rem;
    }

    .hero-text h1 {
        font-size: 2.8rem;
    }

    .hero-buttons {
        justify-content: center;
    }

    .about-content {
        grid-template-columns: 1fr;
        gap: 3rem;
    }

    .projects-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .contact-form {
        padding: 2rem;
    }

    .about, .hobbies, .blog, .python-projects {
        padding: 80px 0;
    }

    .code-showcase {
        max-width: 100%;
        font-size: 0.8rem;
    }

    .section-title {
        font-size: 2.2rem;
    }

    .container {
        padding: 0 15px;
    }
}

@media (max-width: 480px) {
    .hero-text h1 {
        font-size: 2.2rem;
    }

    .social-links-hero {
        justify-content: center;
    }

    .hero-buttons {
        flex-direction: column;
        align-items: center;
    }
}

/* Tabs for Projects Page */
.tabs-container {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: var(--shadow);
    margin-top: 4rem;
}

.tab-buttons {
    display: flex;
    gap: 1rem;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 1rem 1.5rem;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-light);
    position: relative;
    transition: all 0.3s ease;
}

.tab-btn.active {
    color: var(--primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: fadeInUp 0.5s ease-out;
}

.project-preview {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    align-items: center;
}

.project-preview-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 12px;
    background-color: var(--bg-alt);
}

.project-preview-text h3 {
    font-size: 1.6rem;
    margin-bottom: 1rem;
}

.project-preview-description {
    margin-bottom: 1.5rem;
    line-height: 1.7;
    color: var(--text-light);
}

/* Sub-tabs for Python Projects */
.sub-tabs-container {
    padding: 1.5rem;
    background-color: var(--bg-alt);
    border-radius: 12px;
}

.sub-tab-buttons {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 1.5rem;
}

.sub-tab-btn {
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-light);
    position: relative;
    transition: all 0.3s ease;
    border-bottom: 2px solid transparent;
}

.sub-tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.sub-tab-pane {
    display: none;
}

.sub-tab-pane.active {
    display: block;
    animation: fadeInUp 0.5s ease-out;
}

.sub-tab-pane h3 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
}

.sub-tab-pane p {
    color: var(--text-light);
}

.sub-tab-pane-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

.code-block {
    background: #2d3748; /* Dark background for code */
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 8px;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.85rem;
    overflow-x: auto;
    height: 100%;
}


/* CV Page Styles */
.cv-page-tabbed {
    padding-top: 80px; /* Header height */
    background: var(--bg);
}

.cv-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid #e2e8f0;
}

.cv-tab-btn {
    padding: 1rem 1.5rem;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-light);
    position: relative;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.cv-tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.cv-tab-pane {
    display: none;
}

.cv-tab-pane.active {
    display: block;
}

#graph-view {
    width: 100%;
    height: calc(100vh - 200px); /* Adjust height as needed */
    position: relative;
    background-color: var(--bg); /* White background */
    overflow-x: auto !important; /* Enable horizontal scrolling for the graph */
}

#cv-graph {
    width: 100%;
    height: 80vh;
    min-height: 600px; /* Ensure visibility on most screens */
}

.cv-title {
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.cv-subtitle {
    font-size: 1.2rem;
    color: var(--text-light);
}

/* New CV Modal Styles */
.cv-modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s ease;
}

.cv-modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding: 2rem;
    border: 1px solid #888;
    width: 80%;
    max-width: 600px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    position: relative;
    animation: slideUp 0.4s ease-out;
}

.cv-modal-close-btn {
    color: #aaa;
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.cv-modal-close-btn:hover,
.cv-modal-close-btn:focus {
    color: black;
    text-decoration: none;
}

#modal-details ul {
    list-style-position: inside;
    padding-left: 0;
}

#modal-details li {
    margin-bottom: 0.5rem;
}

.modal-badges {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
}

.modal-badge-img {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* New CV Legend Styles */
.cv-legend {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    background: rgba(255, 255, 255, 0.9);
    padding: 1rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color-box {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}


@media (max-width: 768px) {
    .item-main-info {
        flex-wrap: wrap;
    }

    .backlog-item-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .item-details {
        width: 100%;
        min-width: 0;
        justify-content: flex-end; /* Mantiene l'allineamento a destra anche su mobile */
        margin-left: 0; /* Reset del margin su mobile */
    }

    .progress-bar-container {
        flex-basis: 100px;
        flex-grow: 1;
        max-width: 150px;
    }

    .tab-buttons {
        justify-content: center;
        row-gap: 0.5rem;
    }
    .node text {
        font-size: 10px;
    }
    .project-preview {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .project-preview-image {
        margin-bottom: 1.5rem;
        height: 220px;
    }
}

/* D3 Tree styles */
.node .node-html-container {
    width: 30px;
    height: 30px;
    background-color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
    border: 2px solid white;
}

.node .node-html-container i {
    font-size: 16px;
    /* Color will be set dynamically via JS */
}

.node:hover .node-html-container {
    transform: scale(1.15);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

.node text {
  font-family: 'Lato', sans-serif;
  font-size: 12px;
  font-weight: 500;
  fill: var(--text);
}

.link {
  fill: none;
  stroke: var(--text-muted);
  stroke-opacity: 0.6;
  stroke-width: 1.5px;
}

/* Gallery Page Styles */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 4rem;
}
.gallery-item img {
    width: 100%;
    height: 620px;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.gallery-item img:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

/* Timeline for Textual CV */
.cv-section {
    margin-bottom: 3rem;
}

.cv-section-title {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.timeline {
    position: relative;
    padding-left: 2rem;
    border-left: 3px solid var(--primary);
}

.timeline-item {
    position: relative;
    margin-bottom: 2rem;
}

.timeline-dot {
    position: absolute;
    left: -2.7rem;
    top: 0.5rem;
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    border: 4px solid var(--bg);
}

.timeline-content {
    background: var(--bg-alt);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.timeline-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.timeline-date {
    color: var(--text-light);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.timeline-company {
    color: var(--secondary);
    font-weight: 600;
    margin-bottom: 1rem;
}

.timeline-details ul {
    list-style-position: inside;
    padding-left: 0;
}

.timeline-details li {
    margin-bottom: 0.5rem;
    color: var(--text-light);
}

/* Styles for the CV Download Section */
.cv-download-section {
    padding: 2rem 0;
    text-align: center;
    background-color: var(--bg-alt);
    margin-top: 80px; /* To clear the fixed header */
}

.cv-download-section .btn {
    display: inline-block;
    padding: 12px 28px;
    background-color: var(--primary);
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

.cv-download-section .btn:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.cv-download-section .btn i {
    margin-right: 8px;
}

/* Backlog Page Styles */
/* Wider container specifically for backlog page */
.backlog-page-container {
    max-width: 1600px; /* Più largo del container standard (1200px) */
    margin: 0 auto;
    padding: 0 20px;
}

.backlog-container {
    display: flex;
    flex-direction: column;
    gap: 2.5rem; /* Aumentato da 1.5rem a 2.5rem */
    margin-top: 4rem;
    margin-bottom: 4rem; /* Aggiunto per spaziatura dal footer */
    width: 100%; /* Assicura che usi tutta la larghezza disponibile */
}  

.backlog-item {
    background: var(--bg-card);
    padding: 1.5rem 2rem;
    border-radius: 16px;
    box-shadow: var(--shadow);
    border-left: 5px solid;
    transition: all 0.3s ease;
    width: 100%; /* Larghezza completa */
    max-width: 100%; /* Non superare il genitore */
    box-sizing: border-box; /* Include padding e border nel calcolo */
}

.backlog-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    width: 100%;
}

.backlog-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.item-main-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-grow: 1;
}

.item-main-info .fas {
    font-size: 1.5rem;
    color: var(--text-muted);
}

.item-title {
    font-size: 1.2rem;
    font-weight: 600;
}

.item-type, .item-status {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
}

.item-type.tech { background-color: #e0f2fe; color: #0ea5e9; }
.item-type.project { background-color: #dcfce7; color: #22c55e; }
.item-type.course { background-color: #fef3c7; color: #f59e0b; }

.item-status.learning { color: #3b82f6; }
.item-status.developing { color: #16a34a; }
.item-status.future { color: #a855f7; }

.item-details {
    display: flex;
    align-items: center;
    justify-content: flex-end; /* Allinea tutto a destra */
    gap: 1.5rem;
    /*min-width: 350px;*/
    margin-left: auto; /* Spinge l'intero blocco a destra */
}

.item-dates {
    font-size: 0.9rem;
    color: var(--text-light);
    font-weight: 500;
}

.progress-bar-container {
    width: 150px;
    height: 8px;
    background-color: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--gradient-1);
    border-radius: 4px;
}

/* Border colors based on status */
.backlog-item[data-status="learning"] { border-color: #3b82f6; }
.backlog-item[data-status="developing"] { border-color: #16a34a; }
.backlog-item[data-status="future"] {
    border-color: #a855f7;
    background-color: #faf5ff;
}

.backlog-item.future-goal {
    font-style: italic;
}

.backlog-item.future-goal .item-title {
    color: #581c87;
}

.expand-icon {
    margin-left: auto;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.expand-icon.expanded {
    transform: rotate(180deg);
}

.item-expandable-content {
    display: none;
    width: 100%; /* Larghezza completa del genitore */
    padding-top: 1rem;
    margin-top: 1rem;
    border-top: 1px solid #e2e8f0;
    box-sizing: border-box; /* Include padding nel calcolo della larghezza */
    overflow: hidden; /* Nasconde contenuto che potrebbe overflow */
}

.item-expandable-content.is-visible {
    display: block;
}

.item-description {
    color: var(--text-light);
    margin-bottom: 1rem;
    word-wrap: break-word; /* Spezza parole lunghe */
    overflow-wrap: break-word; /* Compatibilità */
    max-width: 100%; /* Non superare il contenitore */
}

/* Video Demo Styles */
.video-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 2rem 0;
    width: 100%;
}

.video-container iframe {
    width: 560px;
    height: 315px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    max-width: 100%;
}

/* YouTube iframe responsive wrapper */
.youtube-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    margin: 2rem 0;
    width: 100%;
}

.youtube-wrapper iframe {
    border-radius: 12px;
    box-shadow: var(--shadow);
    max-width: 100%;
}


.project-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    max-width: 100%;
}

@media (max-width: 768px) {
    .video-container iframe {
        width: 100%;
        height: auto;
        aspect-ratio: 16/9;
    }
    
    .youtube-wrapper iframe {
        width: 100%;
        height: auto;
        aspect-ratio: 16/9;
    }
}

.project-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    word-break: break-word; /* Spezza le URL lunghe */
    max-width: 100%; /* Non superare il contenitore */
}

.project-link:hover {
    text-decoration: underline;
}

.backlog-badges {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.backlog-badge-img {
    width: 80px;
    height: 80px;
    object-fit: contain; /* Ensures the entire image is visible */
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* Hobbies Page - Tile Styles */
.hobbies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 4rem;
}

.hobby-tile {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: all 0.3s ease;
    border-top: 4px solid var(--primary);
}

.hobby-tile:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
}

.hobby-tile-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--primary);
}

.hobby-tile-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.hobby-tile-description {
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.hobby-tile .btn {
    margin-top: auto;
}

/* Project Page - Tile Styles */
.project-grid {
    display: grid;
    grid-template-columns: 1fr; /* Only one tile per tab for now */
    gap: 2rem;
    padding: 1rem;
}

.project-tile {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: all 0.3s ease;
    border-top: 4px solid var(--secondary);
}

.project-tile:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
}

.project-tile-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--secondary);
}

.project-tile-title {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.project-tile-description {
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 1.5rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.project-tile-tech {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 2rem;
}

.project-tile .tech-tag {
    background: var(--bg-alt);
    border: 1px solid #e2e8f0;
}

/* Stili per Login Admin e Modale */
.admin-login {
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-light);
    transition: color 0.3s ease;
}

.admin-login:hover {
    color: var(--primary);
}

.modal {
    display: none; /* Nascosto di default */
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: var(--bg-card);
    margin: 15% auto;
    padding: 0; /* Rimosso padding per un controllo più fine */
    width: 90%;
    max-width: 450px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    position: relative;
    animation: slideUp 0.4s ease-out;
    text-align: center;
    overflow: hidden; /* Nasconde il contenuto che sborda */
    border-top: 5px solid var(--primary);
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e2e8f0;
}

.modal-header h2 {
    font-size: 1.8rem;
    color: var(--text);
    margin: 0;
}

.modal-body {
    padding: 2rem;
}

.modal-body p {
    font-size: 1.1rem;
    color: var(--text-light);
    margin-bottom: 2rem;
}

.close-btn {
    color: #aaa;
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-btn:hover,
.close-btn:focus {
    color: black;
    text-decoration: none;
}

#login-github-btn {
    background: var(--gradient-1);
    color: white;
    padding: 14px 28px;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%; /* Pulsante a larghezza piena */
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

#login-github-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.4);
}

#login-github-btn i {
    margin-right: 0.75rem;
    font-size: 1.2rem;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.modal-buttons .btn,
.modal-buttons .btn-danger,
.modal-buttons .btn-secondary {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-danger {
    background-color: #e53e3e;
    color: white;
}

.btn-danger:hover {
    background-color: #c53030;
    transform: translateY(-2px);
}

.modal-buttons .btn-secondary {
    background: #e2e8f0;
    color: var(--text-light);
    border: 2px solid transparent;
}

.modal-buttons .btn-secondary:hover {
    background: #cbd5e0;
    color: var(--text);
    transform: translateY(-2px);
}

.admin-link a {
    color: #e53e3e !important; /* Rosso per l'admin link */
    font-weight: 700 !important;
}

.admin-link a:hover {
    color: #c53030 !important; /* Rosso più scuro on hover */
}

.admin-link a i {
    margin-right: 0.5rem;
}

/* Stili per la pagina Admin */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 4rem;
}

.admin-tile {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: var(--shadow);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border-top: 4px solid var(--secondary);
}

.admin-tile:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
}

.admin-tile-icon {
    font-size: 3rem;
    margin-bottom: 1.5rem;
    color: var(--secondary);
}

.admin-tile-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

/* AI Banner */
.ai-banner {
    position: absolute;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    padding: 0.4rem 1.5rem;
    border-radius: 20px;
    box-shadow: var(--shadow);
    color: var(--text-light);
    text-align: center;
    font-size: 0.8rem;
    max-width: 100%;
}

.ai-banner i {
    color: var(--primary);
    margin: 0 0.25rem;
}

.d3-graph-container {
    margin-top: 3rem;
}

/* New Project Detail Page Layout */
.project-detail-layout {
    display: grid;
    grid-template-columns: 2fr 1fr; /* 2/3 for main content, 1/3 for sidebar */
    gap: 3rem;
    align-items: start;
}

.project-main-content h3 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    margin-top: 2rem;
}

.project-main-content p, .project-main-content li {
    color: var(--text-light);
    line-height: 1.8;
    margin-bottom: 1rem;
}

.project-sidebar {
    position: sticky;
    top: 120px; /* Adjust based on header height */
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.sidebar-section {
    background: var(--bg-alt);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.sidebar-section h3 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--primary);
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e2e8f0;
}

.sidebar-section ul {
    list-style: none;
    padding-left: 0;
}

.sidebar-section ul li {
    margin-bottom: 0.75rem;
    color: var(--text-light);
    line-height: 1.6;
    font-size: 0.95rem;
}

.sidebar-section ul {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.sidebar-section ul li {
    background: var(--bg-card);
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid #e2e8f0;
    margin-bottom: 0; /* Override default margin */
}

.sidebar-section ul li:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow);
}

.sidebar-section ul li strong {
    color: var(--text);
}

/* Responsive adjustments for the new layout */
@media (max-width: 992px) {
    .project-detail-layout {
        grid-template-columns: 1fr; /* Stack columns on smaller screens */
    }

    .project-sidebar {
        position: static; /* Remove sticky positioning on mobile */
        top: auto;
    }
}

/* Research Page Specific Styles */
.profile-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.profile-links .btn-social {
    padding: 12px 24px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    background-color: var(--bg-card);
    color: var(--text);
    border: 1px solid #e2e8f0;
    box-shadow: var(--shadow);
}

.profile-links .btn-social:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

.profile-links .btn-social i {
    font-size: 1.2rem;
}

.publications-list {
    margin-top: 4rem;
}

.publications-list h3 {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--primary);
    display: inline-block;
}

.publications-list ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 3rem;
}

.publications-list li {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    border-left: 4px solid var(--secondary);
    line-height: 1.7;
    color: var(--text-light);
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

/* Project Logos Section */
.project-logos {
    margin-top: 4rem;
    padding-top: 3rem;
    border-top: 1px solid #ffffff;
}

.project-logos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 2rem;
    align-items: center;
}

.logo-placeholder {
    height: 100px;
    background-color: var(--bg-alt);
    border: 2px dashed #ffffff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;   
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}
