/**
 * Recent Products Grid - Sidebar & Filters Styles
 */

/* Container Principal */
.recent-products-filterable {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    background: #ffffff;
}

.recent-products-filterable.with-sidebar {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 40px;
    align-items: start;
}

/* ===== SIDEBAR ===== */
.rpg-sidebar {
    position: sticky;
    top: 20px;
    height: fit-content;
}

.rpg-sidebar-inner {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e5e7eb;
}

/* Seções de Filtro */
.rpg-filter-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid #f3f4f6;
}

.rpg-filter-section:last-of-type {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.rpg-filter-title {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rpg-filter-title svg {
    stroke: #9ca3af;
}

/* ===== BUSCA ===== */
.rpg-search-box {
    position: relative;
}

.rpg-search-box input {
    width: 100%;
    padding: 12px 40px 12px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    background: #f9fafb;
    transition: all 0.2s;
}

.rpg-search-box input:focus {
    outline: none;
    border-color: #05307A;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(5, 48, 122, 0.1);
}

.rpg-search-box input::placeholder {
    color: #9ca3af;
}

.rpg-search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    stroke: #9ca3af;
    pointer-events: none;
}

.rpg-search-spinner {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top-color: #05307A;
    border-radius: 50%;
    animation: rpg-spin 0.6s linear infinite;
}

@keyframes rpg-spin {
    to { transform: translateY(-50%) rotate(360deg); }
}

/* ===== LISTA DE CATEGORIAS ===== */
.rpg-category-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.rpg-category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: transparent;
}

.rpg-category-item:hover {
    background: #f3f4f6;
}

.rpg-category-item.active {
    background: #eef2ff;
}

.rpg-category-item.active .rpg-cat-name {
    color: #05307A;
    font-weight: 600;
}

.rpg-category-item.active .rpg-cat-count {
    background: #05307A;
    color: #fff;
}

.rpg-cat-name {
    font-size: 14px;
    color: #374151;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rpg-cat-count {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
    transition: all 0.15s;
}

/* ===== BOTÃO LIMPAR ===== */
.rpg-clear-filters {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    margin-top: 16px;
    background: #fee2e2;
    color: #dc2626;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.rpg-clear-filters:hover {
    background: #fecaca;
}

.rpg-clear-filters svg {
    stroke: currentColor;
}

/* ===== ÁREA PRINCIPAL ===== */
.rpg-main {
    min-height: 400px;
}

.rpg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.rpg-result-count {
    font-size: 14px;
    color: #6b7280;
}

.rpg-count-number {
    font-weight: 600;
    color: #111827;
}

.rpg-loading-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #6b7280;
}

.rpg-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top-color: #05307A;
    border-radius: 50%;
    animation: rpg-spin 0.6s linear infinite;
}

/* ===== GRID DE PRODUTOS ===== */
.rpg-products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    transition: opacity 0.2s;
}

/* ===== SEM PRODUTOS ===== */
.rpg-no-products {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.rpg-no-products svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.rpg-no-products p {
    font-size: 15px;
    color: #6b7280;
    margin: 0;
}

/* ===== LOADING STATE ===== */
.rpg-products-grid.rpg-loading {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* ===== BOTÃO CARREGAR MAIS ===== */
.rpg-load-more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    max-width: 300px;
    margin: 30px auto 0;
    padding: 14px 24px;
    background: #05307A;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.rpg-load-more:hover {
    background: #042559;
    transform: translateY(-1px);
}

.rpg-load-more:active {
    transform: translateY(0);
}

.rpg-remaining-wrapper {
    font-weight: 400;
    opacity: 0.8;
}

.rpg-load-more-spinner {
    display: none;
    animation: rpg-spin 1s linear infinite;
}

.rpg-load-more.loading .rpg-load-more-text,
.rpg-load-more.loading .rpg-remaining-wrapper {
    display: none;
}

.rpg-load-more.loading .rpg-load-more-spinner {
    display: block;
}

@keyframes rpg-spin {
    to { transform: rotate(360deg); }
}

/* ===== RESPONSIVO ===== */
@media (max-width: 1200px) {
    .rpg-products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .recent-products-filterable.with-sidebar {
        grid-template-columns: 240px 1fr;
        gap: 24px;
    }
    
    .rpg-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

@media (max-width: 768px) {
    .recent-products-filterable {
        background: #ffffff !important;
        padding: 16px !important;
    }
    
    .recent-products-filterable.with-sidebar {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px;
    }
    
    .rpg-sidebar {
        position: relative;
        top: 0;
        width: 100% !important;
        order: -1;
    }
    
    .rpg-sidebar-inner {
        padding: 0;
        background: transparent;
        border: none;
    }
    
    /* Botão toggle de filtros mobile */
    .rpg-mobile-filter-toggle {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 14px 16px;
        background: #f9fafb;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        font-size: 14px;
        font-weight: 600;
        color: #374151;
        cursor: pointer;
        transition: all 0.2s;
    }
    
    .rpg-mobile-filter-toggle:hover {
        background: #f3f4f6;
    }
    
    .rpg-mobile-filter-toggle.active {
        background: #05307A;
        color: white;
        border-color: #05307A;
    }
    
    .rpg-mobile-filter-toggle svg {
        transition: transform 0.2s;
    }
    
    .rpg-mobile-filter-toggle.active svg {
        transform: rotate(180deg);
        stroke: white;
    }
    
    .rpg-filter-toggle-left {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    
    .rpg-active-filter-count {
        background: #05307A;
        color: white;
        font-size: 11px;
        padding: 2px 8px;
        border-radius: 10px;
        margin-left: 8px;
    }
    
    .rpg-mobile-filter-toggle.active .rpg-active-filter-count {
        background: white;
        color: #05307A;
    }
    
    /* Container colapsável */
    .rpg-filters-collapsible {
        display: none;
        flex-direction: column;
        gap: 12px;
        padding: 16px;
        background: #f9fafb;
        border: 1px solid #e5e7eb;
        border-top: none;
        border-radius: 0 0 12px 12px;
        margin-top: -12px;
    }
    
    .rpg-filters-collapsible.open {
        display: flex;
    }
    
    /* Busca no mobile */
    .rpg-filter-section:first-child {
        margin-bottom: 0;
        padding-bottom: 0;
        border-bottom: none;
    }
    
    .rpg-filter-section {
        margin-bottom: 0;
        padding-bottom: 0;
        border-bottom: none;
    }
    
    .rpg-filter-title {
        display: none;
    }
    
    /* Categorias em grid vertical */
    .rpg-category-list {
        display: flex !important;
        flex-direction: column !important;
        gap: 6px;
        max-height: 200px;
        overflow-y: auto;
    }
    
    .rpg-category-item {
        flex-shrink: 0;
        padding: 12px 14px;
        margin-bottom: 0;
        border: 1px solid #e5e7eb;
        background: #fff;
        border-radius: 10px;
    }
    
    .rpg-category-item.active {
        border-color: #05307A;
        background: #eef2ff;
    }
    
    .rpg-cat-count {
        display: inline-block;
    }
    
    /* Ver mais/menos */
    .rpg-show-more-cats {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 10px;
        background: transparent;
        border: 1px dashed #d1d5db;
        border-radius: 10px;
        color: #6b7280;
        font-size: 13px;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s;
    }
    
    .rpg-show-more-cats:hover {
        background: #f3f4f6;
        border-color: #9ca3af;
        color: #374151;
    }
    
    .rpg-show-more-cats svg {
        transition: transform 0.2s;
    }
    
    .rpg-show-more-cats.expanded svg {
        transform: rotate(180deg);
    }
    
    /* Limitar categorias visíveis */
    .rpg-category-list:not(.expanded) .rpg-category-item:nth-child(n+5) {
        display: none;
    }
    
    /* Área Principal */
    .rpg-main {
        width: 100% !important;
        background: #ffffff;
    }
    
    /* Header compacto */
    .rpg-header {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .rpg-result-count {
        font-size: 13px;
    }
    
    /* Grid 2 colunas no mobile */
    .rpg-products-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
    
    /* Cards no mobile */
    .rpg-products-grid .product-card {
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden;
    }
    
    .rpg-products-grid .product-image {
        aspect-ratio: 1 !important;
        max-height: 180px;
    }
    
    .rpg-products-grid .product-image img {
        width: 100% !important;
        height: 100% !important;
        object-fit: contain !important;
        padding: 8px;
    }
    
    .rpg-products-grid .product-info {
        padding: 12px;
        gap: 6px;
    }
    
    .rpg-products-grid .product-title {
        font-size: 13px;
    }
    
    .rpg-products-grid .product-price {
        font-size: 14px;
    }
    
    .rpg-products-grid .product-image img {
        padding: 8px;
    }
    
    .rpg-products-grid .badge {
        font-size: 9px;
        padding: 3px 6px;
    }
    
    /* Botão limpar compacto */
    .rpg-clear-filters {
        padding: 10px;
        font-size: 12px;
        margin-top: 8px;
    }
}

/* Desktop: esconder botão toggle e manter sidebar visível */
@media (min-width: 769px) {
    .rpg-mobile-filter-toggle {
        display: none !important;
    }
    
    .rpg-show-more-cats {
        display: none !important;
    }
    
    .rpg-filters-collapsible {
        display: block !important;
    }
}

@media (max-width: 480px) {
    .recent-products-filterable {
        padding: 12px !important;
        background: #ffffff !important;
    }
    
    .rpg-sidebar-inner {
        padding: 12px;
    }
    
    .rpg-search-box input {
        padding: 10px 36px 10px 12px;
        font-size: 13px;
    }
    
    .rpg-filter-title {
        font-size: 10px;
        margin-bottom: 12px;
    }
    
    .rpg-category-item {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .rpg-products-grid {
        gap: 8px !important;
    }
    
    .rpg-products-grid .product-card {
        border-radius: 12px;
    }
    
    .rpg-products-grid .product-info {
        padding: 10px;
    }
    
    .rpg-products-grid .product-title {
        font-size: 12px;
    }
    
    .rpg-products-grid .product-price {
        font-size: 13px;
    }
    
    .rpg-products-grid .product-badges {
        top: 8px;
        left: 8px;
    }
    
    .rpg-products-grid .badge {
        font-size: 8px;
        padding: 2px 5px;
    }
    
    .rpg-no-products {
        padding: 40px 16px;
    }
    
    .rpg-no-products svg {
        width: 36px;
        height: 36px;
    }
    
    .rpg-no-products p {
        font-size: 13px;
    }
}

/* ===== CARDS DE PRODUTO ===== */
.rpg-products-grid .product-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.rpg-products-grid .product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
    border-color: #05307A;
}

.rpg-products-grid .product-card-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.rpg-products-grid .product-image {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    background: #ffffff;
    display: block;
    text-decoration: none;
}

.rpg-products-grid .product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.4s ease;
    padding: 12px;
}

.rpg-products-grid .product-card:hover .product-image img {
    transform: scale(1.05);
}

.rpg-products-grid .product-badges {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 2;
}

.rpg-products-grid .badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.rpg-products-grid .badge-sale {
    background: #dc2626;
    color: white;
}

.rpg-products-grid .product-info {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    border-top: 1px solid #f3f4f6;
}

.rpg-products-grid .product-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    line-height: 1.4;
}

.rpg-products-grid .product-title a {
    color: #111827;
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.rpg-products-grid .product-title a:hover {
    color: #05307A;
}

.rpg-products-grid .product-price {
    font-size: 16px;
    font-weight: 700;
    color: #05307A;
    margin-top: auto;
    text-align: center;
}

.rpg-products-grid .product-price del {
    color: #9ca3af;
    font-size: 13px;
    font-weight: 400;
    margin-right: 8px;
}

.rpg-products-grid .product-price ins {
    text-decoration: none;
}
