/* --- FONTES E CONFIGURAÇÕES GLOBAIS --- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap' );

.smart-offers-container {
    font-family: 'Poppins', sans-serif;
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== SEÇÃO DE FILTROS (LAYOUT CORRIGIDO PARA DESKTOP) ===== */

.filter-header {
    text-align: center;
    margin-bottom: 24px;
}

.filter-title {
    font-size: 1.8em;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
}

.filter-subtitle {
    font-size: 1em;
    color: #64748b;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.5;
}

.smart-offers-filter-panel {
    background-color: #ffffff;
    border-radius: 12px;
    margin-bottom: 32px;
    padding: 24px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
}

/* LAYOUT PRINCIPAL DOS FILTROS - DESKTOP FIRST - AJUSTADO PARA CENTRALIZAÇÃO */
.smart-offers-filters {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    justify-content: center;
}

.location-filters {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    justify-content: center;
    flex-wrap: wrap;
}

.action-filters {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.filter-item {
    display: flex;
    flex-direction: column;
    min-width: 200px;
    max-width: 250px;
}

.filter-item label {
    font-size: 0.8em;
    font-weight: 500;
    color: #475569;
    margin-bottom: 6px;
    text-align: center;
}

.filter-item select {
    width: 100%;
    height: 42px;
    padding: 0 36px 0 14px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background-color: #f8fafc;
    font-family: 'Poppins', sans-serif;
    font-size: 0.9em;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e" );
    background-position: right 0.8rem center;
    background-repeat: no-repeat;
    background-size: 1.1em;
}

.filter-item select:hover { border-color: #94a3b8; }
.filter-item select:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); }

.filter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.9em;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    border-radius: 8px;
    white-space: nowrap;
    height: 42px;
    min-width: 140px;
}

.proximity-btn { background-color: #16a34a; color: #ffffff; }
.proximity-btn:hover { background-color: #15803d; }
.proximity-btn.loading { cursor: wait; background-color: #166534; }

.how-it-works-btn {
    background-color: #f1f5f9;
    color: #475569;
    animation: pulse-grey 2.5s infinite;
}
.how-it-works-btn:hover { background-color: #e2e8f0; animation-play-state: paused; }

@keyframes pulse-grey {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* --- GRADE DE OFERTAS --- */
.smart-offers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; transition: opacity 0.3s ease; }
.no-offers-found { grid-column: 1 / -1; text-align: center; padding: 40px; background-color: #f8fafc; border-radius: 12px; color: #64748b; }

/* ===== SEÇÃO DE ESTATÍSTICAS ===== */
.stats-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 32px;
}
.stat-card { background-color: #ffffff; border: 1px solid #eef2f7; border-radius: 12px; padding: 20px; text-align: center; transition: transform 0.2s ease, box-shadow 0.2s ease; }
.stat-card:hover { transform: translateY(-4px); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06); }
.stat-value { font-size: 2.2em; font-weight: 700; color: #3b82f6; line-height: 1.1; margin-bottom: 4px; }
.stat-label { font-size: 0.9em; font-weight: 500; color: #64748b; }
.stat-card:nth-child(3) .stat-value { color: #16a34a; }

/* --- CARD DA OFERTA (SEM ALTERAÇÕES) --- */
.offer-card { background: #ffffff; border-radius: 12px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.07); border: 1px solid #eef2f7; overflow: hidden; transition: transform 0.3s ease, box-shadow 0.3s ease; display: flex; flex-direction: column; position: relative; }
.tags-container { position: absolute; top: 10px; left: 10px; z-index: 2; display: flex; gap: 5px; }
.discount-tag { background-color: #ef4444; color: #ffffff; padding: 3px 8px; border-radius: 7px; font-size: 0.8em; font-weight: 700; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); white-space: nowrap; }
.discount-tag.low { background-color: #ef4444; }
.discount-tag.medium { background-color: #f59e0b; }
.discount-tag.high { background-color: #22c55e; }
.offer-image-wrapper { position: relative; overflow: hidden; aspect-ratio: 4 / 3; }
.offer-image { width: 100%; height: 100%; object-fit: cover; display: block; }
.distance-tag { position: absolute; bottom: 8px; right: 8px; background-color: rgba(15, 23, 42, 0.75); color: #ffffff; padding: 4px 10px; border-radius: 7px; font-size: 0.8em; font-weight: 600; z-index: 3; backdrop-filter: blur(3px); border: 1px solid rgba(255, 255, 255, 0.2); }
.offer-card-content { padding: 10px 12px; display: flex; flex-direction: column; flex-grow: 1; }
.offer-title { font-size: 1em; font-weight: 600; color: #1e293b; line-height: 1.3; margin: 0 0 8px 0; min-height: 34px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.price-section { background: #f8fafc; padding: 6px 10px; border-radius: 8px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: baseline; }
.price-original, .price-discounted { display: flex; flex-direction: row; align-items: baseline; gap: 4px; white-space: nowrap; }
.price-original { font-size: 0.8em; color: #64748b; text-decoration: line-through; }
.price-discounted { font-size: 1.1em; font-weight: 700; color: #e53e3e; text-decoration: none; }
.price-discounted .final-price { animation: pulse-price-constant 2s infinite ease-in-out; }
@keyframes pulse-price-constant { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.price-discounted.low { color: #ef4444; }
.price-discounted.medium { color: #f59e0b; }
.price-discounted.high { color: #22c55e; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; font-size: 0.8em; color: #475569; }
.info-item { background-color: #f8fafc; padding: 6px 8px; border-radius: 6px; display: flex; align-items: center; justify-content: space-between; white-space: nowrap; }
.info-item span { font-weight: normal; }
.info-item strong { font-weight: 700; color: #1e293b; margin-left: 4px; }
.location-section { background: #f1f5f9; padding: 5px 8px; border-radius: 6px; margin-bottom: 8px; font-size: 0.75em; color: #475569; min-height: 30px; display: flex; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress-wrapper { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.timer { text-align: center; font-size: 1em; font-weight: 700; letter-spacing: 0.5px; margin-bottom: 8px; padding: 4px; border-radius: 6px; color: #dc2626; transition: all 0.3s ease; }
.progress-bar { flex-grow: 1; background: #e2e8f0; border-radius: 99px; height: 5px; overflow: hidden; }
.progress-fill { height: 100%; transition: width 0.5s ease, background-color 0.5s ease; border-radius: 99px; }
.progress-fill.high { background-color: #22c55e; }
.progress-fill.medium { background-color: #f59e0b; }
.progress-fill.low { background-color: #ef4444; }
.stock-alert-icon { font-size: 1em; opacity: 0; transition: opacity 0.3s ease; }
.stock-alert-icon.low { opacity: 1; }
.timer.blinking-warning { animation: blink-warning 1.5s infinite; }
@keyframes blink-warning { 0%, 100% { background-color: #fef2f2; color: #dc2626; transform: scale(1); } 50% { background-color: transparent; color: #b91c1c; transform: scale(1.03); } }
.intention-btn { width: 100%; background: linear-gradient(135deg, #3b82f6, #2563eb); color: #ffffff; border: none; padding: 10px; border-radius: 8px; cursor: pointer; font-size: 0.9em; font-weight: 600; transition: all 0.3s ease; box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25); margin-top: auto; display: flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.intention-btn.registered { background: linear-gradient(135deg, #10b981, #059669); cursor: not-allowed; }

/* --- POP-UP (SEM ALTERAÇÕES) --- */
.smart-offer-popup { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(5px); display: flex; align-items: center; justify-content: center; z-index: 10000; padding: 15px; font-family: 'Poppins', sans-serif; }
.popup-content { background: #ffffff; border-radius: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); padding: 32px; max-width: 480px; width: 100%; max-height: 90vh; overflow-y: auto; text-align: center; position: relative; animation: popup-slide-in 0.4s cubic-bezier(0.25, 1, 0.5, 1); }
@keyframes popup-slide-in { from { opacity: 0; transform: scale(0.9) translateY(20px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.popup-close { position: absolute; top: 16px; right: 16px; background: #f1f5f9; border: none; border-radius: 50%; width: 36px; height: 36px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 18px; color: #64748b; transition: all 0.2s ease; }
.popup-close:hover { background: #e2e8f0; transform: rotate(90deg); }
.smart-offer-popup h3 { margin: 0 0 20px; color: #1e293b; font-size: 1.5em; font-weight: 700; }
.smart-offer-popup p { margin: 12px 0; color: #475569; line-height: 1.6; }
.popup-buttons { margin-top: 24px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.popup-buttons button { padding: 12px 24px; border: none; border-radius: 12px; cursor: pointer; font-weight: 600; transition: all 0.2s ease; min-width: 140px; }
.generate-coupon-btn { background: linear-gradient(135deg, #10b981, #059669); color: #ffffff; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3); }
.generate-coupon-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4); }
.close-btn { background: #f1f5f9; color: #475569; }
.close-btn:hover { background: #e2e8f0; color: #1e293b; }

/* ===== RESPONSIVIDADE (CORRIGIDA PARA DESKTOP) ===== */

/* DESKTOP - GARANTIR QUE FILTROS FIQUEM CENTRALIZADOS */
@media (min-width: 1025px) {
    /* Hover apenas em desktop */
    .offer-card:hover { 
        transform: translateY(-5px); 
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1); 
    }
    
    /* Layout horizontal centralizado dos filtros no desktop */
    .smart-offers-filters {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 24px;
        flex-wrap: wrap;
    }
    
    .filter-group {
        display: flex;
        flex-direction: row;
        align-items: flex-end;
        gap: 16px;
        justify-content: center;
    }
    
    .location-filters {
        display: flex;
        gap: 16px;
        align-items: flex-end;
        justify-content: center;
    }
    
    .action-filters {
        display: flex;
        gap: 12px;
        align-items: center;
        justify-content: center;
    }
}

/* TABLETS E TELAS MÉDIAS (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 768px) {
    .smart-offers-filters {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    
    .filter-group {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .location-filters {
        display: flex;
        gap: 16px;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .action-filters {
        display: flex;
        gap: 12px;
        justify-content: center;
        flex-wrap: wrap;
    }
}

/* CELULARES (até 767px) */
@media (max-width: 767px) {
    .smart-offers-container { padding: 0; }
    .filter-header { padding: 0 16px; }
    .smart-offers-filter-panel { margin: 0 16px 24px 16px; }

    /* Layout de filtros para mobile: tudo centralizado em coluna */
    .smart-offers-filters {
        flex-direction: column;
        align-items: center;
        gap: 16px;
    }
    
    .filter-group {
        flex-direction: column;
        align-items: center;
        width: 100%;
        gap: 12px;
    }
    
    .location-filters {
        display: flex;
        flex-direction: column;
        gap: 12px;
        width: 100%;
        align-items: center;
    }
    
    .action-filters {
        display: flex;
        flex-direction: column;
        gap: 12px;
        width: 100%;
        align-items: center;
    }
    
    .filter-item {
        width: 100%;
        max-width: 300px;
    }
    
    .filter-btn {
        width: 100%;
        max-width: 300px;
    }

    /* Estatísticas lado a lado no mobile */
    .stats-container {
        grid-template-columns: repeat(3, 1fr);
        margin: 24px 16px 0 16px;
    }
    .stat-value { font-size: 1.5em; }
    .stat-label { font-size: 0.75em; }
    .stat-card { padding: 12px; }

    /* Grade de ofertas com scroll horizontal */
    .smart-offers-grid {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        gap: 16px;
        padding: 20px;
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
    }
    .smart-offers-grid::-webkit-scrollbar { display: none; }
    .offer-card { flex: 0 0 90%; max-width: 340px; scroll-snap-align: center; }
    .smart-offers-container::after {
        content: "↔ Deslize para ver mais ofertas";
        display: block;
        text-align: center;
        font-size: 0.8em;
        color: #64748b;
        padding: 16px;
        font-style: italic;
    }
}

.discount-tag.pulsating {
    animation: pulse-discount 1.5s infinite ease-in-out;
}

@keyframes pulse-discount {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}