.products-grid {
    display: flex;
    flex-direction: row; /* Explicitly set to row for horizontal layout */
    flex-wrap: wrap; /* Allow wrapping to next line when space runs out */
    justify-content: center; /* Center items horizontally within the container */
    gap: 20px; /* Uniform spacing between elements */
    padding: 20px;
    margin: 0 auto;
}

.product-card {
    text-align: center;
    position: relative;
    max-width: 350px;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 20px; /* Add consistent spacing between product cards */
    background-color: #f9f9f9; /* Fundo suave */
    border-radius: 8px; /* Bordas arredondadas */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Sombra suave para criar profundidade */
}

.product-card img,
.product-card video {
    width: 100%;
    height: auto;
    display: block;
    max-height: 300px; /* Set a maximum height for images/videos */
    object-fit: contain; /* Ensure images maintain aspect ratio */
}

/* Ensure consistent styling for product price across all products */
.product-card .product-price {
    font-size: 18px;
    color: var(--primary-color);
    margin: 10px 0;
    display: block;
}

.product-card h3 {
    font-size: 16px;
    margin: 10px 0;
}

/* Ensure consistent styling for product description across all products */
.product-card .description {
    height: 48px; /* Fixed height to ensure consistent layout */
    overflow: hidden; /* Hide text that exceeds the fixed height */
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Limit to 2 lines of text */
    -webkit-box-orient: vertical;
    margin-bottom: 10px;
}

.product-card img {
    max-width: 100%;
    height: auto;
}

.cart-button {
    display: inline-block;
    margin-top: 10px;
}

.product-info .product-price {
    font-size: 24px; /* Aumenta o tamanho da fonte do preço */
    color: var(--primary-color); /* Usa a cor primária para destaque */
    margin-bottom: 15px; /* Espaço abaixo do preço */
    display: block; /* Garante que ocupe uma linha inteira */
}

.info-book {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(var(--primary-color-rgb), 0.85);
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 2;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
    backdrop-filter: blur(2px);
    padding: 6px;
}

.info-book img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: brightness(0) invert(1);
    opacity: 0.95;
}

.info-book:hover {
    background: rgba(var(--primary-color-rgb), 1);
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(0,0,0,0.2);
}

.product-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    overflow-y: auto;
    cursor: pointer;
    display: none;
}

.modal-content {
    cursor: default;
    position: relative;
    background: white;
    width: 90%;
    max-width: 1200px;
    margin: 40px auto;
    padding: 20px;
    border-radius: 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: start;
}

.modal-image-container {
    position: sticky;
    top: 20px;
}

.modal-image {
    width: 100%;
    height: auto;
    border-radius: 8px;
    object-fit: contain;
    max-height: 80vh;
}

.modal-details {
    padding: 20px;
    overflow-y: auto;
    max-height: 80vh;
}

.modal-title {
    font-size: 24px;
    margin-bottom: 15px;
    color: var(--admin-text);
}

.modal-description {
    color: var(--admin-text);
    line-height: 1.6;
    margin-bottom: 20px;
}

.modal-specs {
    background: var(--admin-card-bg);
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
    border: 1px solid var(--admin-border);
}

.modal-specs h3 {
    color: var(--admin-text);
    margin-bottom: 10px;
}

.specs-list {
    color: var(--admin-text);
    line-height: 1.8;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

@media (max-width: 768px) {
    .modal-content {
        grid-template-columns: 1fr;
        margin: 20px;
        width: calc(100% - 40px);
        gap: 20px;
    }

    .modal-image {
        max-height: 50vh;
    }

    .modal-details {
        padding: 15px 0;
    }
}

.cart-animation {
    position: fixed;
    z-index: 1000;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    transition: all 0.8s cubic-bezier(0.19, 1, 0.22, 1);
    opacity: 0;
    transform: scale(1);
}

.cart-animation img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.add-to-cart-success {
    position: fixed;
    top: 20px;
    right: 100px;
    background: #28a745;
    color: white;
    padding: 15px 25px;
    border-radius: 5px;
    z-index: 1000;
    display: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    animation: slideInRight 0.5s ease-out forwards;
}

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

.quantity-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 15px 0;
}

.quantity-btn {
    width: 32px;
    height: 32px;
    border: 2px solid var(--primary-color);
    background: transparent;
    color: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.quantity-btn:hover {
    background: var(--primary-color);
    color: white;
}

.quantity-input {
    width: 60px;
    height: 32px;
    text-align: center;
    border: 2px solid var(--primary-color);
    border-radius: 16px;
    font-size: 16px;
    color: var(--primary-color);
    background: transparent;
}

.quantity-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb), 0.2);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 25px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 14px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(var(--primary-color-rgb), 0.3);
}

.quantity-input::-webkit-outer-spin-button,
.quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.quantity-input[type=number] {
    -moz-appearance: textfield;
}

.product-card .product-image {
    width: 100%;
    height: auto;
    display: block;
}

.btn-secondary {
    background-color: #6c757d; /* Cinza escuro */
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 25px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 14px;
    display: inline-block; /* Garante que o botão seja um bloco em linha */
    margin-top: 20px; /* Espaço acima do botão */
}

.btn-secondary:hover {
    background-color: #565e64; /* Cinza mais escuro ao passar o mouse */
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.product-info-icon {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 28px !important;
    height: 28px !important;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 2;
    opacity: 0.7;
    padding: 2px;
    border-radius: 3px;
    background-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Centralizar o container principal do produto */
.product-details-container {
    display: flex;
    flex-direction: column;
    align-items: center; /* Centraliza os itens filhos horizontalmente */
    text-align: center; /* Centraliza o texto dentro do container */
    max-width: 1200px;
    margin: 0 auto; /* Centraliza horizontalmente */
    padding: 20px;
}

/* Corrigir cores dos botões */
.btn-secondary {
    background-color: #6c757d !important; /* Cinza escuro */
    color: white !important;
}

.btn-primary {
    background-color: var(--primary-color) !important;
    color: white !important;
}

@media (max-width: 768px) {
    .carousel-container {
        max-width: 100%; /* Permite que ocupe toda a tela em dispositivos móveis */
    }
}

.product-details-container {
    display: flex;
    flex-direction: column;
    align-items: center; /* Centraliza os itens filhos horizontalmente */
    text-align: center; /* Centraliza o texto dentro do container */
}

.product-details-section {
    width: 80%;
    max-width: 1200px;
    margin: 20px auto;
    padding: 20px;
    background-color: #f9f9f9; /* Fundo suave */
    border-radius: 8px; /* Bordas arredondadas */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Sombra suave para criar profundidade */
}

.product-details-section h2 {
    font-size: 22px;
    margin-bottom: 15px;
    color: var(--primary-color);
    text-align: left; /* Alinhar títulos à esquerda */
}

.product-details-section p,
.product-details-section ul {
    line-height: 1.6;
    color: #333;
    text-align: left; /* Alinhar texto à esquerda */
}

.specifications-list {
    list-style-type: none;
    padding: 0;
}

.specifications-list li {
    margin-bottom: 8px;
}

.product-info-icon:hover {
    transform: scale(1.2);
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.95);
}

.product-card > div {
    position: relative;
    width: 100%;
}

.product-card img:not(.product-info-icon) {
    width: 100%;
    height: auto;
    display: block;
}

.info-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
}

.info-modal-content {
    position: relative;
    background: white;
    width: 90%;
    max-width: 600px;
    margin: 50px auto;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.info-close {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.info-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.info-section:last-child {
    border-bottom: none;
}

.info-section h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.info-section p {
    line-height: 1.6;
    color: #666;
}

.specifications-list {
    list-style: none;
    padding: 0;
}

.specifications-list li {
    padding: 8px 0;
    border-bottom: 1px dashed #eee;
}

.specifications-list li:last-child {
    border-bottom: none;
}

/* Availability styles */
.disponivel {
    color: #28a745 !important;
    font-size: 0.9em;
    display: block;
    margin: 5px 0;
}

.poucas-unidades {
    color: #ffc107 !important;
    font-size: 0.9em;
    display: block;
    margin: 5px 0;
}

.ultimas-unidades {
    color: #dc3545 !important;
    font-weight: bold;
    font-size: 0.9em;
    display: block;
    margin: 5px 0;
}

.esgotado {
    color: #6c757d !important;
    font-weight: bold;
    font-size: 0.9em;
    display: block;
    margin: 5px 0;
}

/* Disabled button styles */
.btn-primary.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #6c757d;
}

input:disabled {
    opacity: 0.5;
    background-color: #e9ecef;
    cursor: not-allowed;
}

/* Out of stock product styles */
.produto-esgotado {
    opacity: 0.5;
}



.search-sort-controls button {
    padding: 8px 16px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.search-sort-controls button:hover {
    background-color: #0056b3;
}

/* Loading text style */
.loading-text {
    display: none;
    margin-top: 5px;
    font-size: 12px;
    color: #6c757d;
}

/* Ensure the parent container is full width and centered */
.products-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Add styles to center each new line within the container */
.products-grid > .product-card {
    flex: 1 1 calc(33.333% - 40px); /* 3 items per row with gap, adjust as needed */
    max-width: calc(33.333% - 40px);
    box-sizing: border-box;
}

/* Media query for larger screens (desktop) */
@media (min-width: 769px) {
    .products-grid {
        justify-content: space-around; /* Distribute items symmetrically from center */
    }
}


/* Add responsive design for product cards */
@media (max-width: 768px) {
    .products-grid > .product-card {
        flex: 1 1 calc(50% - 20px); /* 2 items per row on tablets */
        max-width: calc(50% - 20px);
    }

    .product-card img,
    .product-card video {
        height: auto;
        max-height: 200px; /* Limit image height for mobile */
    }

    .product-card h3 {
        font-size: 14px;
    }

    .product-price {
        font-size: 16px;
    }

    .description {
        font-size: 12px;
        height: auto; /* Remove fixed height */
        -webkit-line-clamp: unset; /* Allow text to wrap */
    }
}

/* Add extra responsive design for very narrow screens */
@media (max-width: 480px) {
    .products-grid > .product-card {
        flex: 1 1 calc(100% - 20px); /* 1 item per row on small screens */
        max-width: calc(100% - 20px);
    }
}
