:root {
    --primary-color: #3b82f6;
    --secondary-color: #b9aaff;
    --bg-color: #0f1012;
    --text-color: #ffffff;
    --text-muted: #a0a0a0;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-bg: rgba(255, 255, 255, 0.05);
    --panel-bg: rgba(15, 16, 18, 0.95);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.light-theme {
    --bg-color: #ffffff;
    --text-color: #1a1b1e;
    --text-muted: #666666;
    --glass-bg: rgba(0, 0, 0, 0.05);
    --glass-border: rgba(0, 0, 0, 0.1);
    --card-bg: rgba(0, 0, 0, 0.03);
    --panel-bg: rgba(255, 255, 255, 0.98);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Navbar */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--panel-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--glass-border);
    padding: 15px 0;
}

.nav-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.site-logo {
    height: 40px;
    width: 40px;
    object-fit: cover;
    border-radius: 50%;
}

.site-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Search Bar */
.search-container {
    flex: 1;
    max-width: 500px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

#searchInput {
    width: 100%;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px 15px 12px 45px;
    color: var(--text-color);
    outline: none;
    transition: var(--transition);
}

#searchInput:focus {
    border-color: var(--primary-color);
    background: var(--card-bg);
}

.cart-button {
    position: relative;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.cart-button:hover {
    background: var(--primary-color);
    color: white;
}

.cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid var(--bg-color);
}

/* Main Content */
.main-container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

.category-section {
    margin-bottom: 50px;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    border-bottom: 2px solid var(--glass-border);
    padding-bottom: 10px;
}

.category-name {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Product Cards Common */
.product-item-wrapper {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    transition: var(--transition);
    cursor: pointer;
    overflow: hidden;
    color: var(--text-color);
}

.product-item-wrapper:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.product-image-container {
    background: rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* TEMPLATE 1: GRID MODERNO */
[data-template="1"] .products-display {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

[data-template="1"] .product-item-wrapper {
    border-radius: 20px;
    display: flex;
    flex-direction: column;
}

[data-template="1"] .product-image-container {
    height: 220px;
}

[data-template="1"] .product-info {
    padding: 20px;
}

/* TEMPLATE 2: LISTA MINIMALISTA */
[data-template="2"] .products-display {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

[data-template="2"] .product-item-wrapper {
    border-radius: 15px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 20px;
}

[data-template="2"] .product-image-container {
    width: 100px;
    height: 100px;
    border-radius: 12px;
    flex-shrink: 0;
}

[data-template="2"] .product-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

[data-template="2"] .product-main-info {
    flex: 1;
}

[data-template="2"] .product-footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 20px;
}

/* TEMPLATE 3: CARDS COMPACTOS */
[data-template="3"] .products-display {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
}

[data-template="3"] .product-item-wrapper {
    border-radius: 15px;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

[data-template="3"] .product-image-container {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 10px;
    margin-bottom: 12px;
}

[data-template="3"] .product-footer {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
}

[data-template="3"] .product-price {
    text-align: center;
}

/* Common Elements */
.product-name {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 5px;
    color: var(--text-color);
}

.product-description {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 15px;
}

.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.product-price {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary-color);
}

.add-to-cart-btn {
    background: var(--primary-color);
    border: none;
    color: white;
    padding: 10px 18px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.add-to-cart-btn:hover {
    filter: brightness(1.1);
    transform: scale(1.05);
}

/* Cart Panel */
.cart-panel {
    position: fixed;
    right: -450px;
    top: 0;
    width: 450px;
    height: 100vh;
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    border-left: 1px solid var(--glass-border);
    z-index: 2000;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 30px rgba(0,0,0,0.2);
}

.cart-panel.active { right: 0; }

.cart-header {
    padding: 30px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-header h2 {
    color: var(--text-color);
}

.close-btn {
    background: var(--glass-bg);
    border: none;
    color: var(--text-color);
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

.close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.cart-item {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 15px;
    display: flex;
    gap: 15px;
    color: var(--text-color);
}

.cart-item-image {
    width: 70px;
    height: 70px;
    border-radius: 10px;
    object-fit: cover;
}

.cart-item-info { flex: 1; }
.cart-item-name { font-weight: 600; margin-bottom: 5px; color: var(--text-color); }
.cart-item-price { color: var(--primary-color); font-weight: 700; margin-bottom: 10px; }

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.qty-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    width: 30px;
    height: 30px;
    color: var(--text-color);
    cursor: pointer;
    transition: var(--transition);
}

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

.remove-btn {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    padding: 8px 12px;
    color: #ef4444;
    cursor: pointer;
    margin-left: auto;
    transition: var(--transition);
}

.remove-btn:hover {
    background: #ef4444;
    color: white;
}
.empty-cart, .loading-state{
    display: flex;
    gap: 10px;
}

.cart-footer {
    padding: 20px 30px;
    border-top: 1px solid var(--glass-border);
    background: var(--panel-bg);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-color);
}

.cart-actions { display: flex; flex-direction: column; gap: 10px; }
.btn-cancel, .btn-continue { width: 100%; padding: 15px; border-radius: 12px; font-weight: 600; cursor: pointer; border: none; transition: var(--transition); }
.btn-cancel { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.btn-cancel:hover { background: #ef4444; color: white; }
.btn-continue { background: var(--primary-color); color: white; }
.btn-continue:hover { filter: brightness(1.1); transform: translateY(-2px); }

/* Checkout Screen */
.checkout-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    z-index: 3000;
    display: none;
    padding: 40px 20px;
    overflow-y: auto;
    color: var(--text-color);
}

.checkout-screen.active { display: block; }

.checkout-container { max-width: 600px; margin: 0 auto; }

.checkout-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
}

.back-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
}

.checkout-item {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.checkout-item-image {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    object-fit: cover;
}

.checkout-item-main { flex: 1; }
.checkout-item-name { font-size: 1.1rem; font-weight: 700; color: var(--text-color); }
.checkout-item-details { font-size: 0.9rem; color: var(--text-muted); }

.checkout-item-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.checkout-item-price { font-size: 1.1rem; font-weight: 800; color: var(--primary-color); }

.checkout-summary {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    padding: 25px;
    border-radius: 20px;
    margin: 30px 0;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    color: var(--text-muted);
}

.total-row {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--glass-border);
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-color);
}

.btn-finalize {
    width: 100%;
    padding: 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 15px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.btn-finalize:hover {
    filter: brightness(1.1);
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(var(--primary-rgb), 0.3);
}

/* Receipt Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 4000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal.active { display: flex; }

.modal-content {
    background: var(--panel-bg);
    padding: 30px;
    border-radius: 25px;
    width: 90%;
    max-width: 500px;
    border: 1px solid var(--glass-border);
    color: var(--text-color);
}

.modal-header {
    margin-bottom: 20px;
    text-align: center;
}

.receipt-content textarea {
    width: 100%;
    height: 250px;
    background: #000;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 15px;
    color: #ccc;
    font-family: 'Courier New', monospace;
    resize: none;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.btn-copy, .btn-new-sale {
    flex: 1;
    padding: 15px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-copy {
    background: var(--glass-bg);
    color: var(--text-color);
    border: 1px solid var(--glass-border);
}

.btn-new-sale {
    background: var(--primary-color);
    color: white;
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1500;
    display: none;
}

.overlay.active { display: block; }

/* TEMPLATE 4: LISTA ULTRA-FINA (SEM IMAGEM) */
[data-template="4"] .products-display {
    display: flex;
    flex-direction: column;
    gap: 10px !important; /* Força o espaçamento de 10px entre cada item */
    padding: 5px 0;
}

[data-template="4"] .product-item-wrapper {
    border-radius: 8px;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    min-height: 55px;
    background: var(--card-bg); /* Garante que o fundo apareça */
    border: 1px solid var(--glass-border);
    margin-bottom: 0; /* O gap do pai já resolve o espaçamento */
}

[data-template="4"] .product-image-container {
    display: none !important; /* Remove a imagem */
}

[data-template="4"] .product-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

[data-template="4"] .product-main-info {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 15px;
    flex: 1;
}

[data-template="4"] .product-name {
    font-size: 1rem;
    margin: 0;
    white-space: nowrap;
    font-weight: 700;
}

[data-template="4"] .product-description {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
}

[data-template="4"] .product-footer {
    display: flex;
    align-items: center;
    gap: 15px;
}

[data-template="4"] .product-price {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary-color);
}

/* TEMPLATE 5: CATEGORIAS EM COLUNAS DINÂMICAS */

/* Container que envolve todas as categorias */
[data-template="5"] #productsContainer {
    display: grid;
    /* Cria colunas de no mínimo 350px, ocupando até 1/3 do espaço (3 colunas max) */
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 30px;
    align-items: start;
}

/* Ajuste para garantir que cada categoria se comporte como uma lista (Estilo Template 2) */
[data-template="5"] .category-section {
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.02);
    padding: 20px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

[data-template="5"] .products-display {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

[data-template="5"] .product-item-wrapper {
    border-radius: 12px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
    background: var(--glass-bg);
}

[data-template="5"] .product-image-container {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    flex-shrink: 0;
}

[data-template="5"] .product-info {
    flex: 1;
    display: flex;
    flex-direction: column; /* Nome em cima, preço embaixo para caber em colunas estreitas */
    gap: 5px;
}

[data-template="5"] .product-name {
    font-size: 0.95rem;
    margin: 0;
}

[data-template="5"] .product-description {
    display: none; /* Escondido para manter o visual limpo nas colunas */
}

[data-template="5"] .product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

[data-template="5"] .product-price {
    font-size: 1rem;
    font-weight: 700;
}

[data-template="5"] .add-to-cart-btn {
    padding: 5px 10px;
    font-size: 0.75rem;
}

/* TEMPLATE 6: PAINEL PDV (FOCO NO VENDEDOR) */
[data-template="6"] .products-display {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

[data-template="6"] .product-item-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 15px;
    border-radius: 12px;
    height: 140px; /* Altura fixa para manter o grid alinhado */
    background: var(--card-bg);
    border: 2px solid var(--glass-border);
    text-align: center;
    position: relative;
}

[data-template="6"] .product-image-container {
    display: none !important; /* Remove imagem para focar no texto e velocidade */
}

[data-template="6"] .product-info {
    display: flex;
    flex-direction: column;
    height: 100%;
}

[data-template="6"] .product-name {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--text-color);
}

[data-template="6"] .product-description {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

[data-template="6"] .product-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

[data-template="6"] .product-price {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--primary-color);
}

/* Transforma o botão em uma camada que cobre o card para clique fácil */
[data-template="6"] .add-to-cart-btn {
    width: 100%;
    padding: 8px;
    font-size: 0.9rem;
    text-transform: uppercase;
    border-radius: 8px;
    background: var(--primary-color);
}

/* Feedback visual de "Item no Carrinho" */
[data-template="6"] .product-item-wrapper:active {
    background: var(--primary-color);
    border-color: #fff;
}
[data-template="6"] .product-item-wrapper:active .product-name,
[data-template="6"] .product-item-wrapper:active .product-price,
[data-template="6"] .product-item-wrapper:active .product-description {
    color: #fff !important;
}

/* TEMPLATE 7: GRID DE CATEGORIAS COM ITENS ESTILO T4 */

/* Container de colunas dinâmicas */
[data-template="7"] #productsContainer {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    align-items: start;
}

/* A seção da categoria ganha um leve destaque */
[data-template="7"] .category-section {
    background: rgba(255, 255, 255, 0.02);
    padding: 15px;
    border-radius: 15px;
    border: 1px solid var(--glass-border);
}

/* Estilo do item igual ao Template 4 (Com fundo e borda) */
[data-template="7"] .product-item-wrapper {
    background: var(--card-bg); /* O "fundinho" que gostaste */
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    min-height: 50px;
    margin-bottom: 6px; /* Espaço entre as linhas do T4 */
    transition: var(--transition);
}

[data-template="7"] .product-item-wrapper:hover {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.08);
}

[data-template="7"] .product-image-container {
    display: none !important; /* Mantém sem imagem para ser rápido */
}

[data-template="7"] .product-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    min-width: 0; 
}

[data-template="7"] .product-main-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

[data-template="7"] .product-name {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-color);
}

[data-template="7"] .product-description {
    font-size: 0.75rem;
    margin: 0;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

[data-template="7"] .product-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

[data-template="7"] .product-price {
    font-size: 1rem;
    font-weight: 800;
    color: var(--primary-color);
    white-space: nowrap;
}

[data-template="7"] .add-to-cart-btn {
    padding: 5px 10px;
    font-size: 0.7rem;
    border-radius: 6px;
    background: var(--primary-color);
    white-space: nowrap;
    flex-shrink: 0;
}



/* Responsividade: Se a tela for pequena (celular), volta para 1 coluna cheia */
@media (max-width: 768px) {
    [data-template="5"] #productsContainer {
        grid-template-columns: 1fr;
    }
}

/* Efeito de clique geral para itens do produto */
.product-item-wrapper.active-click {
    transform: scale(1.01) !important; /* Primeiro ele encolhe levemente */
    border-color: var(--primary-color) !important;
    transition: transform 0.1s ease;
}

/* Opcional: Efeito de brilho rápido */
.product-item-wrapper.active-click::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: inherit;
    pointer-events: none;
}

/* Ajuste da Navbar para Mobile (Tudo em uma linha) */
@media (max-width: 768px) {
    .nav-content {
        display: flex;
        flex-direction: row !important; /* Força ficar em linha */
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 0 15px;
        height: 70px;
    }

    /* Esconde o nome da loja no mobile */
    .site-name {
        display: none !important;
    }

    /* Garante que o container do logo não ocupe espaço se não tiver logo */
    .logo-container {
        flex-shrink: 0;
    }

    /* Faz a barra de pesquisa ocupar o espaço central */
    .search-container {
        flex: 1;
        max-width: none;
        margin: 0;
    }

    .search-container input {
        padding: 8px 12px 8px 35px; /* Diminui um pouco o padding interno */
        font-size: 14px;
    }

    /* Mantém o carrinho no final */
    .cart-button {
        flex-shrink: 0;
        width: 45px;
        height: 45px;
    }
}
