/* Variables & Reset */
:root {
    --primary: #e63946;
    --primary-hover: #c1121f;
    --secondary: #1d3557;
    --accent: #2a9d8f;
    --bg-main: #f8f9fa;
    --bg-card: #ffffff;
    --text-dark: #212529;
    --text-muted: #6c757d;
    --border-color: #e9ecef;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.08);
    --radius: 12px;
    --transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-dark);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header & Instant Search */
.main-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 76px;
    gap: 20px;
}

.brand-logo img {
    height: 44px;
    width: auto;
    object-fit: contain;
}

.search-wrapper {
    position: relative;
    flex: 1;
    max-width: 580px;
}

.search-form {
    display: flex;
    align-items: center;
    background: var(--bg-main);
    border: 2px solid var(--border-color);
    border-radius: 30px;
    padding: 4px 6px 4px 18px;
    transition: var(--transition);
}

.search-form:focus-within {
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(230, 57, 70, 0.12);
}

.search-form input {
    border: none;
    background: transparent;
    width: 100%;
    outline: none;
    font-size: 0.95rem;
    color: var(--text-dark);
}

.search-form button {
    background: var(--primary);
    border: none;
    color: #fff;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.search-form button:hover {
    background: var(--primary-hover);
}

/* Autocomplete Dropdown */
.search-results-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #ffffff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    display: none;
    overflow: hidden;
    z-index: 110;
}

.search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-dark);
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.search-item:last-child {
    border-bottom: none;
}

.search-item:hover {
    background: var(--bg-main);
}

.search-item img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 6px;
}

.search-item-info .title {
    font-size: 0.88rem;
    font-weight: 500;
    line-height: 1.2;
}

.search-item-info .prices {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    font-size: 0.85rem;
}

.search-item-info .current {
    font-weight: 700;
    color: var(--primary);
}

.search-item-info .old {
    text-decoration: line-through;
    color: var(--text-muted);
}

.search-item-info .badge {
    background: #ffe3e5;
    color: var(--primary);
    font-weight: 700;
    font-size: 0.72rem;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Top Deals Section */
.top-deals-section {
    padding: 32px 0;
    background: linear-gradient(180deg, #ffffff 0%, var(--bg-main) 100%);
}

.section-title h2 {
    font-size: 1.4rem;
    color: var(--secondary);
}

.section-title p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

/* Correção do alinhamento do bloco do topo */
.top-deals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.top-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    position: relative;
    height: 100%;
}

.top-card-img {
    width: 100%;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: #fff;
    box-sizing: border-box;
}

.top-card-img a {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}

.top-card-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.top-card-body {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    justify-content: space-between;
    position: relative; /* Remove qualquer posicionamento absoluto antigo */
    top: auto;
    bottom: auto;
    left: auto;
    right: auto;
    background: #ffffff;
}

.top-card-body h3 {
    font-size: 0.9rem;
    line-height: 1.35;
    margin: 0 0 10px 0;
    height: 2.7em; /* Limita a altura a 2 linhas de texto */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.top-card-body h3 a {
    color: #1e293b;
    text-decoration: none;
}

.top-card-body h3 a:hover {
    color: #2563eb;
}

/* Products Grid */
.main-content {
    padding: 32px 20px 60px;
}

.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.filter-tabs {
    display: flex;
    gap: 8px;
    background: #ffffff;
    padding: 4px;
    border-radius: 30px;
    border: 1px solid var(--border-color);
}

.tab-item {
    text-decoration: none;
    color: var(--text-muted);
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 0.88rem;
    font-weight: 600;
    transition: var(--transition);
}

.tab-item.active, .tab-item:hover {
    background: var(--secondary);
    color: #ffffff;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 20px;
}

.product-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: 16px;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: var(--transition);
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: transparent;
}

.badge-discount {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--primary);
    color: #ffffff;
    font-weight: 800;
    font-size: 0.78rem;
    padding: 4px 8px;
    border-radius: 6px;
    z-index: 2;
}

.badge-bestseller {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--accent);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.72rem;
    padding: 4px 8px;
    border-radius: 6px;
    z-index: 2;
}

.card-image-wrap {
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.card-image-wrap img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
}

.card-brand {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    font-weight: 600;
}

.card-title {
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.35;
    height: 2.7em;
    overflow: hidden;
    margin: 4px 0 12px;
}

.card-pricing {
    margin-top: auto;
    margin-bottom: 12px;
}

.price-before {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: line-through;
}

.price-now {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary);
}

.price-now small {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-dark);
}

.btn-buy, .btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--secondary);
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    padding: 10px 16px;
    border-radius: 8px;
    transition: var(--transition);
}

.btn-buy:hover, .btn-primary:hover {
    background: var(--primary);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    list-style: none;
    gap: 8px;
    margin-top: 40px;
}

.pagination a {
    text-decoration: none;
    color: var(--text-dark);
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: #ffffff;
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
}

.pagination a.active, .pagination a:hover {
    background: var(--secondary);
    color: #ffffff;
    border-color: var(--secondary);
}

/* Footer */
.main-footer {
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    padding: 30px 0;
    text-align: center;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.footer-disclaimer {
    font-size: 0.78rem;
    margin-top: 6px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state h3 {
    margin: 16px 0 8px;
    color: var(--text-dark);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        height: auto;
        padding: 12px 20px;
    }
    
    .search-wrapper {
        width: 100%;
    }

    .filter-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }

    .card-image-wrap {
        height: 130px;
    }

    .price-now {
        font-size: 1.1rem;
    }
}