* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    background: #fff;
    color: #eee;
    font-family: Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: url('img/bg-campo.webp') no-repeat center center fixed;
    background-size: cover;
    opacity: 1;
    z-index: -1;
}
a { color: inherit; text-decoration: none; }

.main-wrapper {
    max-width: 1100px;
    margin: 0 auto;
    background: #1a1a1a;
    min-height: 100vh;
    border-left: 1px solid #333;
    border-right: 1px solid #333;
    box-shadow: 0 0 20px rgba(0,0,0,.5);
}

header {
    background: #111;
    padding: 20px;
    border-bottom: 3px solid #4caf50;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 30px;
    font-weight: 900;
    text-transform: uppercase;
}

@keyframes shine { to { background-position: 200% center; } }
.shiny-text {
    background: linear-gradient(to right, #ffffff 20%, #aaaaaa 40%, #ffffff 60%, #43d45b 80%);
    background-size: 200% auto;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shine 2.8s linear infinite;
}

.user-actions a {
    margin-left: 15px;
    font-size: 17px;
    font-weight: 700;
    color: #fff;
}

.btn-anunciar {
    padding: 10px 20px;
    color: #fff;
    font-size: 16px;
    font-weight: 800;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    background: linear-gradient(90deg, #4caf50, #32e05c, #2e8b36, #4caf50);
    background-size: 300% 300%;
    animation: gradientFlash 2.2s ease-in-out infinite;
    box-shadow: 0 0 12px rgba(76,175,80,0.6);
}

@keyframes gradientFlash {
    0%   { background-position: 0% 50%;   box-shadow: 0 0 10px rgba(76,175,80,0.5); }
    25%  { background-position: 50% 50%;  box-shadow: 0 0 16px rgba(76,255,120,0.8); }
    50%  { background-position: 100% 50%; box-shadow: 0 0 10px rgba(76,175,80,0.5); }
    75%  { background-position: 50% 50%;  box-shadow: 0 0 16px rgba(76,255,120,0.8); }
    100% { background-position: 0% 50%;   box-shadow: 0 0 10px rgba(76,175,80,0.5); }
}


.slider-container {
    position: relative;
    width: 100%;
    height: 500px;
    overflow: hidden;
}
.slide {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 1s;
}
.slide.active { opacity: 1; }

.slide-text {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 25px;
    width: 90%;
    text-align: center;
    color: #fff;
    text-shadow: 2px 2px 6px rgba(0,0,0,.8);
}
.slide-text h2 {
    font-size: 38px;
    font-weight: 700;
    margin-bottom: 10px;
}
.slide-text p {
    font-size: 20px;
    padding: 8px 20px;
    background: rgba(0,0,0,.6);
    display: inline-block;
    border-radius: 4px;
}

.filters {
    padding: 20px;
    background: #222;
    border-bottom: 1px solid #333;
}
.filter-group { margin-bottom: 18px; }

.filter-label {
    color: #4caf50;
    font-weight: 700;
    margin-bottom: 8px;
    display: block;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tags-container { display: flex; gap: 10px; flex-wrap: wrap; }

.tag {
    background: #333;
    color: #ccc;
    padding: 8px 14px;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid #444;
    transition: all .15s;
}
.tag:hover, .tag.active {
    background: #4caf50;
    color: #fff;
    border-color: #4caf50;
    font-weight: 700;
}

.state-tag {
    position: relative;
    background: #333;
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    border: 1px solid #444;
    font-weight: 700;
    z-index: 1;
    overflow: hidden;
}
.state-tag::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: var(--flag-url);
    background-size: cover;
    background-position: center;
    opacity: .25;
    z-index: -1;
    transition: opacity .2s;
}
.state-tag:hover::before { opacity: .4; }
.state-tag:hover, .state-tag.active {
    background: #4caf50 !important;
    border-color: #4caf50 !important;
    color: #fff !important;
}

.brand-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px,1fr));
    gap: 10px;
}
.brand-item {
    background: #fff;
    border-radius: 6px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #333;
    padding: 5px;
    transition: all .2s;
}
.brand-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.brand-item:hover { border-color: #4caf50; }
.brand-item.active {
    border-color: #4caf50;
    box-shadow: 0 0 10px rgba(76,175,80,.35);
}

.content { padding: 20px; }

#catalogo-container {
    transition: opacity .15s;
}
#catalogo-container.is-loading {
    opacity: .4;
    pointer-events: none;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px,1fr));
    gap: 20px;
}

.card {
    background: #262626;
    border: 1px solid #333;
    border-radius: 8px;
    overflow: hidden;
    transition: transform .15s, border-color .15s;
}
.card:hover {
    transform: translateY(-5px);
    border-color: #4caf50;
}
.card-img {
    height: 160px;
    width: 100%;
    object-fit: cover;
    background: #000;
}

.card-body { padding: 15px; }
.card-title {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 6px;
}
.card-info {
    font-size: 12px;
    color: #999;
    margin-bottom: 10px;
}
.card-price {
    font-size: 20px;
    font-weight: 700;
    color: #4caf50;
    margin-bottom: 10px;
}
.card-loc {
    font-size: 12px;
    color: #777;
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge-destaque {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    background: #4caf50;
    color: #fff;
}
.badge-info-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.badge-tag {
    background: rgba(0,0,0,.65);
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid #555;
}

.pagination {
    text-align: center;
    margin-top: 40px;
}
.page-link {
    display: inline-block;
    padding: 8px 12px;
    background: #333;
    color: #fff;
    border-radius: 4px;
    margin: 0 4px;
}
.page-link.active { background: #4caf50; }

footer {
    text-align: center;
    padding: 30px;
    border-top: 1px solid #333;
    color: #666;
    font-size: 14px;
    margin-top: 20px;
}

.localizacao-bar {
    width: 100%;
    background: #111;
    border-bottom: 3px solid #4CAF50;
    padding: 15px;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}
.localizacao-bar select {
    background: #222;
    color: #fff;
    border: 1px solid #333;
    padding: 10px;
    border-radius: 6px;
    font-size: 15px;
    min-width: 140px;
}
.localizacao-bar button {
    background: #4CAF50;
    border: none;
    padding: 10px 18px;
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    font-weight: bold;
}
.localizacao-bar button:hover {
    background: #3e8e41;
}
.localizacao-bar .btn-clear-loc {
    background: #ff4444 !important;
    color: #fff !important;
    padding: 10px 14px !important;
    border-radius: 6px !important;
    font-size: 16px !important;
    font-weight: 700;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.localizacao-bar .btn-clear-loc:hover {
    background: #cc0000 !important;
}

@media(max-width:900px) {
    .slide-text h2 { font-size: 28px; }
    .slide-text p { font-size: 16px; }
}

@media(max-width:800px) and (min-width:601px) {
    .localizacao-bar select { min-width: 130px; }
}

@media(max-width:600px) {
    .slider-container { height: 300px; }
    .slide-text { bottom: 10px; }
    .slide-text h2 { font-size: 26px; }
    .slide-text p { font-size: 16px; padding: 6px 14px; }

    .localizacao-bar {
        padding: 8px 6px;
        gap: 8px;
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        white-space: nowrap;
        scrollbar-width: none;
    }
    .localizacao-bar::-webkit-scrollbar { display: none; }

    .localizacao-bar select {
        min-width: 115px;
        max-width: 150px;
        font-size: 13px;
        padding: 7px 10px;
    }

    .localizacao-bar button {
        font-size: 13px;
        padding: 7px 12px;
    }

    .localizacao-bar .btn-clear-loc {
        padding: 7px 10px !important;
        font-size: 14px !important;
    }

    .badge-destaque,
    .badge-info-overlay {
        display: none !important;
    }

    .grid {
        grid-template-columns: repeat(3,1fr) !important;
        gap: 10px;
    }

    .card-img { height: 80px; }
    .card-body { padding: 10px; }
    .card-title { font-size: 12px; margin-bottom: 4px; }
    .card-info { font-size: 10px; margin-bottom: 6px; }
    .card-price { font-size: 14px; margin-bottom: 6px; }
    .card-loc { font-size: 10px; }
}

.text-center { text-align: center; }
.hidden { display: none !important; }

footer {
    position: relative;
}

.footer-contador {
    margin-bottom: 10px;
    font-size: 16px;
    color: #4CAF50;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.footer-contador .contador-numero {
    font-size: 22px;
    color: #3cd85a;
}

.footer-contador .contador-label {
    font-size: 14px;
    color: #a3ffba;
}

footer a {
    color: #4CAF50;
    font-size: 12px;
    margin: 0 10px;
    display: inline-block;
}

/* Melhorias de fluidez nos filtros */
.tag,
.state-tag,
.brand-item {
    transition: background-color .15s ease, color .15s ease, border-color .15s ease, opacity .15s ease;
    cursor: pointer;
}

.tag:hover,
.state-tag:hover,
.brand-item:hover {
    opacity: .8;
}

/* Loading verdadeiro (JS usa .loading e não .is-loading) */
#catalogo-container.loading {
    opacity: .45;
    pointer-events: none;
    transition: opacity .25s ease;
}

/* Otimização de transição do catálogo */
#catalogo-container {
    transition: opacity .25s ease;
    position: relative;
}

/* Spinner opcional */
#catalogo-container.loading::after {
    content: "";
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255,255,255,.25);
    border-top-color: #4CAF50;
    border-radius: 50%;
    animation: spin .8s linear infinite;
    position: absolute;
    left: 50%;
    top: 120px;
    margin-left: -14px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}


/* Retira qualquer transição normal */
#catalogo-container {
    transition: none !important;
    position: relative;
}

/* Transição SOMENTE na entrada do loading */
#catalogo-container.loading {
    opacity: .45;
    pointer-events: none;
    transition: opacity .25s ease !important;
}

/* Spinner opcional (não causa piscada) */
#catalogo-container.loading::after {
    content: "";
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255,255,255,.25);
    border-top-color: #4CAF50;
    border-radius: 50%;
    animation: spin .8s linear infinite;
    position: absolute;
    left: 50%;
    top: 120px;
    margin-left: -14px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}






/* Remove qualquer transição que possa causar piscada */
#catalogo-container {
    transition: none !important;
    position: relative;
}

/* Estilo do carregamento sem opacidade e sem flicker */
#catalogo-container.loading {
    pointer-events: none;
}

/* Spinner pequeno, discreto e sem causar repaint na tela */
#catalogo-container.loading::after {
    content: "";
    width: 26px;
    height: 26px;
    border: 3px solid rgba(255,255,255,.25);
    border-top-color: #4CAF50;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    position: absolute;
    left: 50%;
    top: 80px; /* não cobre o topo do container */
    margin-left: -13px;
    z-index: 9999;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
