.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 */
}

/* Legacy loja: garante altura para o carrossel com slides absolutos */
.products-grid .product-card .carousel-media {
    position: relative;
    min-height: 340px;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
}

/* Override do carrossel legacy para enquadrar melhor as fotos no card */
.products-grid .product-card .carousel-media .carousel-slide {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.products-grid .product-card .carousel-slide img,
.products-grid .product-card .carousel-slide video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: contain;
    object-position: center center;
    transform: none;
}

.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-flags {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 10px 0 4px;
}

.product-flag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1;
}

.product-flag-promo {
    background: #fde8e8;
    color: #991b1b;
}

.product-flag-frete {
    background: #e8f7ee;
    color: #166534;
}

.product-price-wrap {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
    margin: 10px 0;
}

.product-price-promotional {
    color: #dc2626;
    margin: 0;
}

.product-price-original {
    color: #6b7280;
    text-decoration: line-through;
    font-size: 14px;
}

.product-shipping-note {
    display: block;
    margin-top: 6px;
    color: #166534;
    font-size: 13px;
    font-weight: 600;
}

.product-card h3 {
    font-size: 16px;
    margin: 10px 0;
    font-family: var(--font-secondary, var(--font-main, inherit));
}

/* 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;
    font-family: var(--font-secondary, var(--font-main, inherit));
}

.btn-primary:hover {
    background: var(--secondary-color, var(--primary-color));
    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: var(--secondary-color, #6c757d);
    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 */
    font-family: var(--font-secondary, var(--font-main, inherit));
}

.btn-secondary:hover {
    background-color: var(--primary-color);
    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: var(--secondary-color, #6c757d) !important;
    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: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-secondary, var(--font-main, inherit));
}

.search-sort-controls button:hover {
    background-color: var(--secondary-color, var(--primary-color));
}

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

.search-sort-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.search-sort-controls > div {
    position: relative;
}

.search-sort-controls input[type="text"],
.search-sort-controls select {
    min-width: 220px;
    height: 38px;
    padding: 0 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    color: #111827;
}

.search-sort-controls button[type="submit"] {
    height: 38px;
    padding: 0 18px;
    border-radius: 8px;
}

.category-menu {
    max-width: 1200px;
    margin: 10px auto 0;
    padding: 0 20px;
}

.category-menu-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 0;
    padding: 0;
}

.category-menu .menu-item {
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border: 1px solid var(--admin-border, #d9d9d9);
    border-radius: 999px;
    color: var(--admin-text, #1f2937);
    text-decoration: none;
    font-size: 0.9rem;
    background: var(--admin-card-bg, #fff);
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.category-menu .menu-item:hover,
.category-menu .menu-item.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* 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 */
    }
}


/* ============================================
   RESPONSIVIDADE - PRODUTOS E INDEX
   ============================================ */

/* Tablets */
@media (max-width: 1024px) {
    .products-grid > .product-card {
        flex: 1 1 calc(33.333% - 16px);
        max-width: calc(33.333% - 16px);
    }

    .modal-content {
        max-width: 900px;
    }
}

/* Mobile landscape e portrait */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        width: 100%;
    }

    .search-container {
        padding: 0 12px;
        max-width: 100%;
    }

    .search-sort-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .search-sort-controls input[type="text"],
    .search-sort-controls select,
    .search-sort-controls button[type="submit"] {
        width: 100%;
        min-width: 0;
        height: 44px;
        padding: 0 14px;
        font-size: 16px; /* Previne zoom no iOS */
    }

    .category-menu {
        padding: 0 12px;
        max-width: 100%;
    }

    .category-menu-list {
        justify-content: flex-start;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
    }

    .category-menu .menu-item {
        flex-shrink: 0;
    }

    .products-container {
        padding: 0 12px;
        max-width: 100%;
    }

    .products-grid {
        padding: 12px 0;
        gap: 12px;
    }

    .products-grid .product-card .carousel-media {
        min-height: 200px;
    }

    .products-grid > .product-card {
        flex: 1 1 calc(50% - 12px);
        max-width: calc(50% - 12px);
        margin-bottom: 12px;
    }

    .product-card {
        padding: 10px;
    }

    .product-card img,
    .product-card video {
        height: auto;
        max-height: 180px;
    }

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

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

    .description {
        font-size: 13px;
        height: auto;
        -webkit-line-clamp: 2;
        margin-bottom: 8px;
    }

    .quantity-controls {
        margin: 10px 0;
    }

    .quantity-btn {
        width: 32px;
        height: 32px;
        min-width: 44px;
        min-height: 44px;
        font-size: 16px;
    }

    .quantity-input {
        height: 32px;
        width: 50px;
        font-size: 16px;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
        padding: 12px 16px;
        min-height: 44px;
        font-size: 14px;
        margin-top: 8px;
    }

    .modal-content {
        grid-template-columns: 1fr;
        margin: 12px;
        width: calc(100% - 24px);
        gap: 16px;
        padding: 14px;
    }

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

    .modal-details {
        padding: 0;
        max-height: none;
        overflow-y: visible;
    }

    .modal-title {
        font-size: 1.25rem;
    }

    .cart-animation {
        width: 44px;
        height: 44px;
    }

    .add-to-cart-success {
        top: 12px;
        right: 12px;
        left: 12px;
        max-width: none;
        padding: 12px;
    }
}

/* Mobile portrait pequeno */
@media (max-width: 480px) {
    .search-container,
    .category-menu,
    .products-container {
        padding: 0 8px;
    }

    .products-grid {
        padding: 8px 0;
        gap: 10px;
    }

    .products-grid > .product-card {
        flex: 1 1 calc(100% - 10px);
        max-width: calc(100% - 10px);
    }

    .product-card {
        padding: 8px;
    }

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

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

    .description {
        font-size: 12px;
    }

    .btn-primary,
    .btn-secondary {
        padding: 10px 14px;
        font-size: 13px;
    }
}

/* Touch devices */
@media (hover: none) and (pointer: coarse) {
    .quantity-btn,
    .btn-primary,
    .btn-secondary,
    .search-sort-controls button {
        min-height: 44px;
    }
}

.product-variation {
    margin: 8px 0 12px;
}

.product-variation label {
    display: block;
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 4px;
}

.product-variation select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
}

.product-variation select:focus {
    outline: none;
    border-color: #aaa;
}
