/* WPG Product Grid – Frontend Styles */

/* ---- Wrapper ---- */
.wpg-product-grid-wrapper {
    position: relative;
    width: 100%;
}

/* ---- Controls Bar ---- */
.wpg-pg-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
    align-items: center;
}

.wpg-pg-search-wrap {
    position: relative;
    flex: 1 1 220px;
}

.wpg-pg-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
}

.wpg-pg-search-input {
    width: 100%;
    height: 44px;
    padding: 0 12px 0 38px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    background: #fafafa;
    color: #1a1a1a;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
}
.wpg-pg-search-input:focus {
    border-color: #1a1a1a;
    box-shadow: 0 0 0 3px rgba(0,0,0,.07);
    background: #fff;
}

.wpg-pg-filter-wrap {
    flex: 0 0 auto;
}

.wpg-pg-category-select {
    height: 44px;
    padding: 0 36px 0 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    background: #fafafa url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23555' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
    -webkit-appearance: none;
    appearance: none;
    color: #1a1a1a;
    cursor: pointer;
    outline: none;
    transition: border-color .2s;
}
.wpg-pg-category-select:focus {
    border-color: #1a1a1a;
}

/* ---- Grid ---- */
.wpg-product-grid {
    position: relative;
    transition: opacity .25s;
}
.wpg-product-grid.is-loading {
    opacity: .5;
    pointer-events: none;
}

/* ---- Loading spinner overlay ---- */
.wpg-pg-spinner {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.6);
    z-index: 10;
    align-items: center;
    justify-content: center;
}
.wpg-pg-spinner.is-active {
    display: flex;
}
.wpg-pg-spinner::after {
    content: '';
    width: 36px;
    height: 36px;
    border: 3px solid #e0e0e0;
    border-top-color: #1a1a1a;
    border-radius: 50%;
    animation: wpg-spin .7s linear infinite;
}
@keyframes wpg-spin { to { transform: rotate(360deg); } }

/* ---- Product Card ---- */
.wpg-pg-card {
    display: flex;
    flex-direction: column;
    transition: transform .2s, box-shadow .2s;
}
.wpg-pg-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,.12) !important;
}

.wpg-pg-card-image-wrap {
    display: block;
    text-decoration: none;
    position: relative;
}

.wpg-pg-image-ratio {
    background: #f5f5f5;
}
.wpg-pg-image-ratio img {
    display: block;
    transition: transform .3s;
}
.wpg-pg-card:hover .wpg-pg-image-ratio img {
    transform: scale(1.04);
}

/* ---- Badge ---- */
.wpg-pg-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    border-radius: 3px;
}
.wpg-pg-badge--sale {
    background: #e63946;
    color: #fff;
}
.wpg-pg-badge--featured {
    background: #f4a261;
    color: #fff;
}

/* ---- Card Body ---- */
.wpg-pg-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wpg-pg-product-title {
    text-decoration: none;
    transition: opacity .15s;
    word-break: break-word;
}
.wpg-pg-product-title:hover {
    opacity: .75;
}

/* ---- Price ---- */
.wpg-pg-price {}
.wpg-pg-price .price {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
}
.wpg-pg-price del {
    text-decoration: line-through;
    font-size: .9em;
}
.wpg-pg-price ins {
    text-decoration: none;
}
.wpg-pg-price .woocommerce-Price-currencySymbol {
    font-size: .85em;
}

/* ---- Buttons ---- */
.wpg-pg-btn-wrap {
    margin-top: auto;
    padding-top: 4px;
}

.wpg-pg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: background .2s, color .2s, opacity .2s;
    line-height: 1.3;
}
.wpg-pg-btn--full {
    width: 100%;
}
.wpg-pg-btn--wa {}
.wpg-pg-btn--cart {}
.wpg-pg-btn:hover { text-decoration: none; }

/* ---- External plugin button wrapper ---- */
.wpg-pg-btn-wrap--external {
    margin-top: auto;
    padding-top: 4px;
}
/* Ensure external WA plugin buttons fill the card width cleanly */
.wpg-pg-btn-wrap--external a,
.wpg-pg-btn-wrap--external button {
    display: block;
    width: 100%;
    text-align: center;
    box-sizing: border-box;
    text-decoration: none;
}

/* ---- No products ---- */
.wpg-pg-no-products {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 15px;
}

/* ---- Pagination ---- */
.wpg-pg-pagination-wrap {
    margin-top: 36px;
    display: flex;
    justify-content: center;
}

.wpg-pg-pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.wpg-pg-page-btn {
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    border: 1px solid #e0e0e0;
    background: #fff;
    color: #333;
    font-size: 14px;
    border-radius: 4px;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.wpg-pg-page-btn:hover:not(.wpg-pg-page-btn--active) {
    border-color: #999;
    background: #f5f5f5;
}
.wpg-pg-page-btn--active {
    cursor: default;
}
.wpg-pg-page-prev,
.wpg-pg-page-next {
    font-size: 18px;
    font-weight: 300;
}

.wpg-pg-page-ellipsis {
    padding: 0 4px;
    color: #999;
    line-height: 38px;
}

.wpg-pg-pagination--loadmore {
    display: flex;
    justify-content: center;
}
.wpg-pg-loadmore-btn {
    padding: 12px 36px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: opacity .2s;
    letter-spacing: .3px;
}
.wpg-pg-loadmore-btn:hover { opacity: .85; }
.wpg-pg-loadmore-btn:disabled {
    opacity: .5;
    cursor: default;
}

/* ---- Responsive fallbacks (overridden by inline CSS per block) ---- */
@media (max-width: 767px) {
    .wpg-pg-controls {
        flex-direction: column;
        gap: 8px;
    }
    .wpg-pg-search-wrap,
    .wpg-pg-filter-wrap { width: 100%; }
    .wpg-pg-category-select { width: 100%; }
}
