/* Forçar layout empilhado no mobile (garante override de regras abaixo) */
.portfolio-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
}

.portfolio-modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--eerie-black-1);
    padding: 24px;
    border-radius: 20px;
    width: 98%;
    max-width: none;
    height: 80vh;
    position: relative;
    display: flex;
    gap: 28px;
    box-sizing: border-box;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: var(--light-gray);
    font-size: 24px;
    cursor: pointer;
}

.modal-image-main {
    width: 100%;
    height: 400px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 20px;
}

.modal-thumbnails {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 0;
}

.modal-thumbnail {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 5px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s;
}

.modal-thumbnail.active {
    opacity: 1;
}

.modal-details {
    margin-top: 20px;
    color: var(--light-gray);
}

.modal-title {
    font-size: var(--fs-3);
    color: var(--light-gray);
    margin-bottom: 10px;
}

.tech-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 15px 0;
}

.tech-tag {
    background-color: var(--jet);
    color: var(--light-gray);
    padding: 5px 10px;
    border-radius: 15px;
    font-size: var(--fs-7);
}

.modal-description {
    margin: 15px 0;
    line-height: 1.6;
}

/* Controles do carrossel */
.carousel-controls {
    display: flex;
    justify-content: space-between;
    position: absolute;
    top: 50%;
    width: 100%;
    transform: translateY(-50%);
    pointer-events: none;
}

.carousel-control {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 15px;
    cursor: pointer;
    border-radius: 50%;
    pointer-events: auto;
}

.carousel-control:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Reset e ajustes específicos para mobile */
@media (max-width: 768px) {
    .modal-content {
        width: 98%;
        max-width: 98%;
        height: auto;
        min-height: 95vh;
        flex-direction: column;
        padding: 12px;
        gap: 0;
        border-radius: 12px;
        overflow-y: auto;
        background-color: var(--eerie-black-1);
    }

    .modal-left {
        width: 100%;
        max-width: 100%;
        flex: none;
        margin-bottom: 0;
        position: relative;
        order: 1;
    }

    .modal-right {
        width: 100%;
        max-width: 100%;
        flex: none;
        padding: 0;
        display: flex;
        flex-direction: column;
        order: 2;
    }

    .modal-image-main {
        height: 42vh;
        width: 100%;
        object-fit: cover;
        border-radius: 12px;
        margin: 0;
    }

    /* Ajustes dos controles do carrossel para mobile */
    .carousel-controls {
        position: absolute;
        top: 50%;
        width: 100%;
        transform: translateY(-50%);
        z-index: 100;
        pointer-events: none;
        padding: 0 10px;
        box-sizing: border-box;
    }

    .carousel-control {
        pointer-events: auto;
        background: rgba(255, 255, 255, 0.3);
        padding: 12px;
        font-size: 18px;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        margin: 0 5px;
    }

    /* Container dos detalhes do projeto */
    .modal-details {
        width: 100%;
        margin: 16px 0;
        padding: 20px 16px;
        display: flex;
        flex-direction: column;
        gap: 20px;
        background-color: rgba(0, 0, 0, 0.2);
        border-radius: 12px;
        order: 1;
    }

    /* Título do projeto */
    .modal-title {
        width: 100%;
        font-size: 28px;
        line-height: 1.3;
        color: var(--vegas-gold);
        margin: 0;
        text-align: left;
        font-weight: 600;
    }

    /* Container das tecnologias */
    .tech-stack {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 10px;
        margin: 12px 0;
    }

    /* Tags de tecnologia */
    .tech-tag {
        background-color: var(--jet);
        color: var(--light-gray);
        padding: 8px 16px;
        border-radius: 20px;
        font-size: 14px;
        font-weight: 500;
        letter-spacing: 0.5px;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    /* Descrição do projeto */
    .modal-description {
        width: 100%;
        font-size: 16px;
        line-height: 1.7;
        color: var(--light-gray);
        text-align: left;
        margin: 0;
        padding: 0;
    }

    /* Miniaturas */
    .modal-thumbnails-wrapper {
        width: 100%;
        margin: 0;
        padding: 16px;
        background: transparent;
        order: 2;
    }

    .modal-thumbnails {
        display: flex;
        justify-content: flex-start;
        gap: 12px;
        overflow-x: auto;
        padding: 8px 0;
        -webkit-overflow-scrolling: touch;
    }

    /* Botão de fechar */
    .modal-close {
        position: absolute;
        top: 8px;
        right: 8px;
        background: rgba(0, 0, 0, 0.3);
        color: var(--light-gray);
        border: none;
        border-radius: 50%;
        padding: 8px;
        font-size: 24px;
        cursor: pointer;
        z-index: 1001;
    }
}

/* Ajustes de responsividade para mobile */
@media (max-width: 768px) {
  .modal-content {
    width: 98%;
    max-width: 98%;
    min-height: 95vh;
    height: auto;
    flex-direction: column;
    padding: 12px;
    gap: 12px;
    border-radius: 12px;
    overflow-y: auto;
  }

  .modal-left,
  .modal-right {
    max-width: 100%;
    flex: none;
    width: 100%;
    height: auto;
  }

  .modal-image-main {
    height: 38vh;
    object-fit: cover;
    width: 100%;
  }

  /* Ajustes para melhor visualização do conteúdo */
  .modal-details {
    width: 100%;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }

  .modal-title {
    font-size: 20px;
    line-height: 1.3;
    margin: 0;
    color: var(--light-gray);
    width: 100%;
  }

  .tech-stack {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 8px 0;
    width: 100%;
  }

  .modal-description {
    font-size: 15px;
    line-height: 1.6;
    color: var(--light-gray);
    margin: 0;
    padding: 0 4px;
    width: 100%;
  }

  /* Miniaturas ficam abaixo do texto */
  .modal-thumbnails-wrapper {
    margin-top: 12px;
    background: transparent;
    padding: 6px 0;
    width: 100%;
  }

  /* Garantir que o botão de fechar fique bem visível */
  .modal-close {
    top: 8px;
    right: 8px;
    padding: 8px;
    font-size: 24px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
  }
}

/* Estilos atualizados para as miniaturas do carrossel */
.modal-thumbnails {
    height: 80px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 5px 0;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    justify-content: center;
}

.modal-thumbnails::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.modal-thumbnail {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    box-sizing: border-box;
}

.modal-thumbnail:hover {
    opacity: 0.8;
    transform: translateY(-2px);
}

.modal-thumbnail.active {
    opacity: 1;
    border: 2px solid var(--vegas-gold);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

/* Container para as miniaturas com fundo mais escuro */
.modal-thumbnails-wrapper {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 10px;
    margin-top: 10px;
}

/* Responsive: mobile layout (stacked) */
@media (max-width: 768px) {
    .modal-content {
        width: 98%;
        max-width: 98%;
        height: 95vh;
        flex-direction: column;
        padding: 12px;
        gap: 12px;
        border-radius: 12px;
        overflow: hidden; /* hide native scrollbar visually */
    }

    .modal-left,
    .modal-right {
        max-width: 100%;
        flex: none;
        width: 100%;
    }

    .modal-image-main {
        height: 38vh;
        object-fit: cover;
        width: 100%;
        border-radius: 8px;
    }

    /* Centralizar texto e elementos para melhor leitura no mobile */
    .modal-right {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        max-height: calc(55vh - 20px);
        overflow-y: auto;
        padding: 8px 6px;
        box-sizing: border-box;
    }

    .modal-details {
        padding: 6px 8px;
    }

    .modal-title {
        font-size: 20px;
        line-height: 1.2;
        margin-bottom: 8px;
    }

    .modal-description {
        font-size: 15px;
        line-height: 1.5;
        margin-bottom: 10px;
        padding: 0 6px;
    }

    .tech-stack {
        justify-content: center;
        gap: 8px;
    }

    /* Miniaturas ficam abaixo do texto no lado direito (agora empilhadas) */
    .modal-thumbnails-wrapper {
        margin-top: 8px;
        background: transparent;
        padding: 6px 0 0 0;
        width: 100%;
        display: flex;
        justify-content: center;
    }

    .modal-thumbnails {
        justify-content: center;
        overflow-x: auto;
        padding-bottom: 6px;
        gap: 10px;
    }

        /* Reordenar conteúdo no modal-right para mobile: tecnologias antes do texto */
        .modal-details {
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .tech-stack { order: 1; }
        .modal-title { order: 2; }
        .modal-description { order: 3; }

    /* aumentar área de toque das miniaturas */
    .modal-thumbnail {
        width: 72px;
        height: 72px;
    }

    /* controles maiores no mobile para toque confortável */
    .carousel-control {
        padding: 18px;
        font-size: 18px;
    }

    /* esconder barras de rolagem visualmente, mas manter a rolagem funcional */
    .modal-thumbnails::-webkit-scrollbar,
    .modal-content::-webkit-scrollbar {
        height: 0px;
        width: 0px;
        display: none;
    }
    
            @media (max-width: 768px) {
                .modal-left,
                .modal-right {
                    flex: 0 0 100% !important;
                    max-width: 100% !important;
                    width: 100% !important;
                    padding: 0 !important;
                }
    
                /* garantir que modal-right não use alinhamento lateral e que o conteúdo ocupe toda largura */
                .modal-right {
                    align-items: center !important;
                    text-align: center !important;
                    justify-content: flex-start !important;
                    overflow: visible !important;
                    max-height: none !important;
                }
    
                /* Miniaturas sempre abaixo do texto e centralizadas */
                .modal-thumbnails-wrapper {
                    width: 100% !important;
                    display: block !important;
                    margin-top: 12px !important;
                    background: transparent !important;
                    padding: 6px 0 0 0 !important;
                }
    
                .modal-thumbnails {
                    justify-content: center !important;
                    overflow-x: auto !important;
                }
    
                /* Certificar que a imagem ocupe toda a largura do bloco superior */
                .modal-image-main {
                    width: 100% !important;
                    height: 36vh !important;
                    object-fit: cover !important;
                }
            }

    .modal-thumbnails {
        -ms-overflow-style: none; /* IE/Edge */
        scrollbar-width: none; /* Firefox */
    }

    .modal-right::-webkit-scrollbar {
        height: 0; width: 0; display: none;
    }

    /* garantir que o botão de fechar fique visível no mobile e com área de toque maior */
    .modal-close {
        top: 8px;
        right: 8px;
        font-size: 22px;
        padding: 6px;
    }

    /* adaptar o modal para telas muito pequenas */
    @media (max-height: 600px) {
        .modal-image-main { height: 32vh; }
        .modal-right { max-height: 60vh; }
    }
}

.modal-left {
    flex: 0 0 60%;
    max-width: 60%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-right {
    flex: 0 0 40%;
    max-width: 40%;
    padding-right: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.carousel-container {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

.modal-image-main {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

/* Ajuste para quando não há carrossel */
.modal-thumbnails:empty {
    display: none;
}

.modal-thumbnails:empty + .carousel-container {
    height: 100%;
}

.modal-thumbnails {
    height: 100px;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.modal-thumbnails::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.modal-title {
    margin: 0 0 8px 0;
    color: var(--light-gray);
    font-size: 30px;
    line-height: 1.15;
}

.modal-details {
    color: var(--light-gray);
    margin: 0;
    max-width: 100%;
}

.modal-description {
    font-size: 16px;
    line-height: 1.7;
    color: var(--light-gray);
    margin: 0 0 8px 0;
}