@media screen and (max-width: 1200px) {
    section, .nav-container {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

@media screen and (max-width: 992px) {
    header {
        height: 60px;
    }
    
    /* Logo adjustments for mobile */
    .logo {
        font-size: 1.2rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 160px;
    }
    
    .nav-links {
        position: fixed;
        top: 0;
        right: -300px;
        width: 300px;
        height: 100vh;
        background-color: var(--header-bg);
        box-shadow: -5px 0 15px var(--shadow-color);
        flex-direction: column;
        padding: 80px 40px;
        transition: right 0.3s ease;
        z-index: 990;
    }
    
    .nav-links.active {
        right: 0;
    }
    
    .nav-links li {
        margin: 15px 0;
    }
    
    .mobile-menu-btn {
        display: block;
        z-index: 1000;
    }
    
    /* Hero Section */
    .hero {
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        padding-top: 60px;
    }
    
    .hero-content {
        padding: 0 1rem;
        gap: 0.6rem;
        max-height: calc(100% - 30px);
    }
    
    .hero-content h1 {
        font-size: 1.8rem;
    }
    
    .hero-content h2 {
        font-size: 1.2rem;
        line-height: 1.3;
        text-align: center;
        width: 100%;
    }
    
    .typewriter {
        text-align: center;
        width: 100%;
        display: block;
        margin: 0 auto;
    }
    
    .profile-img {
        width: 200px;
        height: 200px;
    }
    
    .timeline::after {
        left: 40px;
    }
    
    .timeline-item {
        width: 100%;
        padding-left: 80px;
        padding-right: 0;
    }
    
    .timeline-item:nth-child(even) {
        left: 0;
    }
    
    .timeline-item:nth-child(odd) .timeline-dot,
    .timeline-item:nth-child(even) .timeline-dot {
        left: 32px;
    }
    
    /* Modal */
    .modal-body {
        grid-template-columns: 1fr;
    }
    
    /* Contact Section */
    .contact-item {
        flex-wrap: wrap;
        justify-content: flex-start;
    }
    
    .contact-item p {
        width: 100%;
        word-break: break-word;
        overflow-wrap: break-word;
        padding-left: 40px;
        margin-top: 5px;
    }
    
    .contact-item i {
        min-width: 30px;
    }
}

@media screen and (max-width: 768px) {
    /* Logo adjustments for smaller screens */
    .logo {
        font-size: 1rem;
        max-width: 110px; /* Reduzido para mostrar apenas "Lucas Gabriel..." */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Hero Section */
    .hero {
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        padding-top: 60px;
    }
    
    .hero-content {
        gap: 0.5rem;
        max-height: calc(100% - 20px);
    }
    
    .hero-content h1 {
        font-size: 1.7rem;
    }
    
    .hero-content h2 {
        font-size: 1.1rem;
        line-height: 1.2;
    }
    
    .profile-img {
        width: 180px;
        height: 180px;
    }
    
    /* Projects Grid */
    .projects-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
    
    /* Contact Section */
    .contact-container {
        grid-template-columns: 1fr;
    }
    
    /* Contact Section */
    .contact-container-simple {
        padding: 1.5rem;
        width: 90%;
    }
    
    .contact-item {
        font-size: 1rem;
    }
    
    .contact-item i {
        font-size: 1.3rem;
    }
    
    /* Certificates Grid */
    .certificates-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
    
    /* Botão de download de CV */
    .download-btn {
        width: 100%;
        justify-content: center;
        padding: 0.8rem 1.5rem;
        font-size: 0.95rem;
    }
}

@media screen and (max-width: 576px) {
    /* Section Titles */
    .section-title {
        font-size: 2rem;
    }
    
    /* Logo adjustments for even smaller screens */
    .logo {
        font-size: 0.95rem;
        max-width: 105px; /* Reduzido para mostrar apenas "Lucas Gabriel..." */
    }
    
    /* Hero Section */
    .hero {
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        padding-top: 50px;
    }
    
    .hero-content {
        gap: 0.4rem;
        max-height: calc(100% - 15px);
    }
    
    /* Modal Global Settings */
    .modal {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-content {
        overflow: visible; /* Permite que o conteúdo flua naturalmente */
    }
    
    .profile-img {
        width: 160px;
        height: 160px;
    }
    
    .hero-content h1 {
        font-size: 1.5rem;
    }
    
    .hero-content h2 {
        font-size: 0.95rem;
        line-height: 1.2;
    }
    
    .hero-content p {
        font-size: 0.9rem;
        padding: 0 0.5rem;
        line-height: 1.3;
        max-width: 90%;
    }
    
    .cta-btn {
        padding: 0.7rem 1.5rem;
        font-size: 0.9rem;
    }
    
    /* Projects Filter */
    .projects-filter {
        flex-direction: column;
        align-items: center;
    }
    
    .filter-btn {
        width: 200px;
    }
    
    /* Modal */
    .modal-content {
        width: 95%;
        padding: 1.5rem;
        margin: 3% auto;
        max-height: 94vh;
        overflow-y: auto; /* Principal área de rolagem */
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-body {
        grid-template-columns: 1fr;
        max-height: none;
        gap: 1rem;
        overflow: visible; /* Desativa a rolagem neste nível */
    }
    
    .modal-gallery {
        grid-template-columns: repeat(2, 1fr); /* 2 imagens por linha */
        gap: 0.5rem; /* Espaço menor entre imagens */
        max-height: none; /* Removemos a altura máxima fixa */
        overflow-y: visible; /* Desabilita a rolagem separada */
        margin-bottom: 1.5rem; /* Espaço entre a galeria e o texto */
    }
    
    /* Controle do tamanho das imagens na galeria */
    .modal-gallery img {
        max-height: 180px; /* Altura máxima para cada imagem */
        width: 100%;
        object-fit: cover; /* Cobre o espaço mantendo proporção */
        border-radius: 4px;
    }
    
    .modal-info {
        max-height: none; /* Removemos a altura máxima fixa */
        overflow: visible; /* Desativa a rolagem separada */
        padding: 0; /* Remove o padding extra que era usado para a barra de rolagem */
    }
    
    .close-modal {
        top: 0.5rem;
        right: 1rem;
        font-size: 2.2rem;
        padding: 0.5rem;
        z-index: 10;
    }
    
    .modal-btn {
        display: block;
        width: 100%;
        margin: 0.8rem 0;
        padding: 0.9rem;
        text-align: center;
        font-size: 1rem;
    }
    
    /* Indicador de rolagem para mostrar que há mais conteúdo */
    .modal-content::after {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background-color: var(--primary-color);
        border-radius: 2px;
        margin: 1rem auto 0;
        opacity: 0.7;
    }
    
    .modal-gallery img {
        max-height: 200px; /* Altura máxima para cada imagem */
        width: auto;
        height: auto;
        object-fit: contain; /* Mantém a proporção da imagem */
        margin: 0 auto; /* Centraliza as imagens */
        display: block;
    }
    
    /* Melhorias para visualização em tela cheia */
    .full-size-modal .full-size-content {
        width: 100%;
        height: 100%;
        padding: 0;
    }
    
    .full-size-modal img {
        max-height: 80vh;
        width: auto;
        max-width: 100%;
        object-fit: contain;
    }
    
    .full-size-modal .nav-arrow {
        padding: 1rem;
        background-color: rgba(0, 0, 0, 0.5);
        border-radius: 50%;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Contact Section */
    .contact-container-simple {
        padding: 1.25rem;
    }
    
    .contact-item {
        align-items: flex-start;
    }
    
    .contact-item p, .contact-item a {
        font-size: 0.9rem;
        line-height: 1.4;
    }
}

@media screen and (max-width: 480px) {
    /* Logo for very small screens */
    .logo {
        font-size: 0.9rem;
        max-width: 100px; /* Reduzido para mostrar apenas "Lucas Gabriel..." */
    }
    
    /* Hero Section */
    .hero-content h1 {
        font-size: 1.5rem;
    }
}

@media screen and (max-width: 360px) {
    /* Logo for extra small screens */
    .logo {
        font-size: 0.85rem;
        max-width: 95px; /* Reduzido para mostrar apenas "Lucas Gabriel..." */
    }
    
    /* Hero Section */
    .hero-content h1 {
        font-size: 1.8rem;
    }
    
    .hero-content h2 {
        font-size: 1.1rem;
    }
    
    .social-links {
        gap: 1rem;
    }
    
    /* Contact Section */
    .contact-item {
        gap: 0.7rem;
    }
    
    .contact-item p {
        padding-left: 35px;
    }
    
    .download-btn {
        font-size: 0.9rem;
        padding: 0.7rem 1.2rem;
    }
}

/* Mobile Menu Animation */
.mobile-menu-toggle .bar1,
.mobile-menu-toggle .bar2,
.mobile-menu-toggle .bar3 {
    width: 25px;
    height: 3px;
    background-color: var(--text-color);
    margin: 5px 0;
    transition: 0.4s;
}

.mobile-menu-toggle.active .bar1 {
    transform: rotate(-45deg) translate(-5px, 6px);
}

.mobile-menu-toggle.active .bar2 {
    opacity: 0;
}

.mobile-menu-toggle.active .bar3 {
    transform: rotate(45deg) translate(-5px, -6px);
}

/* For projects modal iframe/video */
@media screen and (max-width: 768px) {
    .modal-video {
        height: 300px;
    }
}

@media screen and (max-width: 576px) {
    .modal-video {
        height: 200px;
    }
}

/* Melhorias específicas para dispositivos móveis muito pequenos */
@media screen and (max-width: 360px) {
    .modal-gallery {
        grid-template-columns: 1fr; /* Apenas 1 imagem por linha em telas muito pequenas */
    }
    
    .modal-content {
        padding: 1rem;
    }
    
    .close-modal {
        top: 0.3rem;
        right: 0.8rem;
    }
    
    /* Melhorias para touch */
    .modal img {
        min-height: 44px; /* Garantir altura mínima para alvos de toque */
    }
}

/* Melhorias para iOS e dispositivos móveis em geral */
@media screen and (max-width: 768px) {
    /* Impedir comportamento de rolagem elástico em iOS */
    .modal, .modal-content, .modal-body {
        overscroll-behavior: contain;
    }
    
    /* Melhorar precisão de toque */
    .close-modal, .modal-btn, .modal-gallery img {
        touch-action: manipulation;
    }
    
    /* Feedback visual ao tocar */
    .modal-gallery img:active {
        opacity: 0.8;
        transform: scale(0.98);
        transition: all 0.1s ease;
    }
    
    /* Indicador visual para mostrar que as imagens são tocáveis */
    .modal-gallery img::after {
        content: '';
        position: absolute;
        bottom: 5px;
        right: 5px;
        width: 20px;
        height: 20px;
        background-color: rgba(255, 255, 255, 0.7);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        pointer-events: none;
    }
}
@media screen and (max-width: 420px), (max-height: 600px) {
    .hero {
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        padding-top: 50px;
    }
    
    .hero-content {
        gap: 0.3rem;
        max-height: calc(100% - 10px);
    }
    
    .profile-img {
        width: 130px;
        height: 130px;
        border-width: 3px;
    }
    
    .hero-content h1 {
        font-size: 1.3rem;
    }
    
    .hero-content h2 {
        font-size: 0.85rem;
        line-height: 1.2;
    }
    
    .hero-content p {
        font-size: 0.8rem;
        max-width: 90%;
        line-height: 1.3;
    }
    
    .social-links {
        gap: 0.8rem;
    }
    
    .social-links a {
        font-size: 1.1rem;
    }
    
    .cta-btn {
        padding: 0.5rem 1rem;
        font-size: 0.75rem;
        margin-top: 0.2rem;
    }
}

@media screen and (max-height: 500px) and (orientation: landscape) {
    .hero {
        padding-top: 40px;
    }
    
    .hero-content {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem 1.5rem;
        padding: 0 2rem;
    }
    
    .profile-img {
        width: 110px;
        height: 110px;
        border-width: 2px;
        margin-right: 1rem;
    }
    
    .hero-content h1, 
    .hero-content h2 {
        text-align: left;
        width: calc(100% - 130px);
    }
    
    .hero-content p {
        width: 100%;
        font-size: 0.75rem;
        line-height: 1.2;
        margin-top: -0.3rem;
    }
    
    .social-links, .cta-btn {
        margin-top: -0.2rem;
    }
    
    .social-links {
        gap: 0.7rem;
    }
    
    .social-links a {
        font-size: 1rem;
    }
    
    .cta-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.7rem;
    }
    
    /* Estilos para fullscreen em dispositivos móveis */
    .fullscreen-nav {
        padding: 0 20px;
    }
    
    .fullscreen-prev,
    .fullscreen-next {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .fullscreen-close {
        top: 15px;
        right: 15px;
    }
    
    .fullscreen-counter {
        bottom: 15px;
    }
    
    .fullscreen-image {
        max-width: 100%;
        max-height: 80%;
    }
}