/* =====================================================
   CPG Frontend Styles — Poppins Font, বাংলা UI
   ===================================================== */

*, *::before, *::after { box-sizing: border-box; }

.cpg-grid-wrapper,
.cpg-grid-wrapper *,
.cpg-cart-popup,
.cpg-cart-popup *,
.cpg-wishlist-popup,
.cpg-wishlist-popup * {
    font-family: 'Poppins', 'Hind Siliguri', sans-serif;
}

/* ─── Category Header ───────────────────────────────── */
.cpg-category-header-wrap {
    margin-bottom: 20px;
}

.cpg-category-header {
    margin: 0 0 6px;
    font-family: 'Poppins', 'Hind Siliguri', sans-serif;
    font-weight: 700;
    line-height: 1.3;
    word-break: break-word;
}

.cpg-category-header-desc {
    margin: 0 0 16px;
    font-size: 14px;
    color: #6b7280;
    font-family: 'Poppins', 'Hind Siliguri', sans-serif;
    line-height: 1.6;
}

/* ─── Grid ─────────────────────────────────────────── */
.cpg-grid-wrapper { width: 100%; margin: 0 auto; }

.cpg-grid {
    display: grid;
    gap: 20px;
    margin-bottom: 30px;
}

/* ─── Product Card ──────────────────────────────────── */
.cpg-product-card {
    background: #fff;
    overflow: hidden;
    transition: transform 0.28s ease, box-shadow 0.28s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* ─── Product Image ─────────────────────────────────── */
.cpg-product-image {
    position: relative;
    overflow: hidden;
    background: #f3f4f6;
    flex-shrink: 0;
    aspect-ratio: 1 / 1;
    width: 100%;
}

.cpg-product-image a {
    display: block;
    width: 100%;
    height: 100%;
}

.cpg-product-image .cpg-img,
.cpg-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
    display: block;
}

.cpg-product-card:hover .cpg-product-image img {
    transform: scale(1.06);
}

/* ─── Wishlist Button ───────────────────────────────── */
.cpg-wishlist-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 3;
    background: rgba(255,255,255,0.92);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    backdrop-filter: blur(4px);
    padding: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.cpg-wishlist-btn:hover {
    background: #fff;
    transform: scale(1.12);
}

.cpg-heart-icon {
    width: 18px;
    height: 18px;
    color: #9ca3af;
    transition: color 0.2s ease, fill 0.2s ease;
    display: block;
}

.cpg-wishlist-btn.cpg-in-wishlist .cpg-heart-icon {
    color: #ef4444;
    fill: #ef4444;
}

.cpg-wishlist-btn:hover .cpg-heart-icon {
    color: #ef4444;
}

/* ─── Badges ────────────────────────────────────────── */
.cpg-badge {
    position: absolute;
    top: 10px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    z-index: 2;
}

.cpg-in-stock    { background: #16a34a; color: #fff; left: 10px; }
.cpg-out-of-stock{ background: #ef4444; color: #fff; left: 10px; }
.cpg-sale-badge  { background: #f97316; color: #fff; right: 54px; }

/* ─── Product Info ──────────────────────────────────── */
.cpg-product-info {
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* ─── Product Title — 3-line clamp ──────────────────── */
.cpg-product-title {
    margin: 0 0 2px;
    line-height: 1.45;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cpg-product-title a {
    text-decoration: none;
    color: #111827;
    transition: color 0.2s;
    display: block;
}

.cpg-product-title a:hover { color: #2563eb; }

/* ─── Rating ────────────────────────────────────────── */
.cpg-product-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.cpg-product-rating .star-rating {
    float: none;
    margin: 0;
    font-size: 13px;
}

.cpg-rating-count { font-size: 11px; color: #9ca3af; }

/* ─── Price ─────────────────────────────────────────── */
.cpg-product-price {
    margin: 2px 0 8px;
    color: #111827;
    flex-shrink: 0;
}

.cpg-product-price del {
    color: #9ca3af;
    margin-right: 6px;
    font-weight: 400;
    font-size: 0.9em;
}

.cpg-product-price ins {
    text-decoration: none;
    color: #dc2626;
}

/* ─── Card Actions ──────────────────────────────────── */
.cpg-card-actions {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: auto;
}

.cpg-add-to-cart-btn,
.cpg-order-now-btn {
    border: none;
    cursor: pointer;
    transition: background 0.22s ease, color 0.22s ease, transform 0.15s ease;
    text-align: center;
    font-weight: 600;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    letter-spacing: 0.2px;
    line-height: 1.2;
    outline: none;
    font-family: 'Poppins', 'Hind Siliguri', sans-serif;
    white-space: normal;
    word-break: break-word;
    min-height: 40px;
    padding: 8px 12px;
}

.cpg-add-to-cart-btn:active,
.cpg-order-now-btn:active { transform: scale(0.97); }

.cpg-add-to-cart-btn.cpg-disabled,
.cpg-add-to-cart-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
}

/* ─── Success Message ───────────────────────────────── */
.cpg-success-message {
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 12px;
    text-align: center;
    margin-top: 6px;
    animation: cpgFadeInUp 0.3s ease;
    font-weight: 500;
}

@keyframes cpgFadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── No Products ───────────────────────────────────── */
.cpg-no-products {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    background: #f9fafb;
    border-radius: 12px;
    color: #6b7280;
}

.cpg-no-products span { font-size: 40px; display: block; margin-bottom: 12px; }
.cpg-no-products p    { font-size: 16px; margin: 0; }

/* ─── Pagination ────────────────────────────────────── */
.cpg-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 32px;
    flex-wrap: wrap;
}

.cpg-page-btn,
.cpg-prev-btn,
.cpg-next-btn {
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    font-size: 13px;
    font-weight: 500;
    font-family: 'Poppins', 'Hind Siliguri', sans-serif;
    white-space: nowrap;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cpg-prev-btn:disabled,
.cpg-next-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── Loading ────────────────────────────────────────── */
.cpg-grid.cpg-loading {
    position: relative;
    min-height: 200px;
    opacity: 0.5;
    pointer-events: none;
}

.cpg-grid.cpg-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #2563eb;
    border-radius: 50%;
    animation: cpgSpin 0.8s linear infinite;
    z-index: 10;
}

@keyframes cpgSpin {
    0%   { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ─── Cart Icon ──────────────────────────────────────── */
.cpg-cart-icon-wrap {
    display: inline-flex;
    align-items: center;
    position: relative;
    text-decoration: none;
    cursor: pointer;
}

.cpg-cart-icon { display: flex; align-items: center; }

.cpg-cart-count,
.cpg-wishlist-count {
    position: absolute;
    top: -8px;
    right: -10px;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
    animation: cpgBounce 0.3s ease;
}

@keyframes cpgBounce {
    0%   { transform: scale(0.5); }
    60%  { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ─── Wishlist Icon Wrap ─────────────────────────────── */
.cpg-wishlist-icon-wrap {
    display: inline-flex;
    align-items: center;
    position: relative;
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}

/* ─── Overlay (shared base) ──────────────────────────── */
.cpg-cart-overlay,
.cpg-wishlist-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 99998;
    backdrop-filter: blur(2px);
    transition: opacity 0.28s ease;
    opacity: 0;
}

.cpg-cart-overlay.cpg-open,
.cpg-wishlist-overlay.cpg-open {
    display: block;
    opacity: 1;
}

/* ─── Cart Popup (Right Side) ────────────────────────── */
.cpg-cart-popup {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    max-width: 95vw;
    height: 100vh;
    background: #fff;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    /* transform দিয়ে hide করি — width যাই হোক সবসময় ঠিকভাবে লুকাবে */
    transform: translateX(110%);
    transition: transform 0.32s cubic-bezier(0.4,0,0.2,1);
    box-shadow: -4px 0 32px rgba(0,0,0,0.14);
    font-family: 'Poppins', 'Hind Siliguri', sans-serif;
}

.cpg-cart-popup.cpg-open { transform: translateX(0); }

/* ─── Wishlist Popup (Left Side) ─────────────────────── */
.cpg-wishlist-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 380px;
    max-width: 95vw;
    height: 100vh;
    background: #fff;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    /* transform দিয়ে hide করি — width যাই হোক সবসময় ঠিকভাবে লুকাবে */
    transform: translateX(-110%);
    transition: transform 0.32s cubic-bezier(0.4,0,0.2,1);
    box-shadow: 4px 0 32px rgba(0,0,0,0.14);
    font-family: 'Poppins', 'Hind Siliguri', sans-serif;
}

.cpg-wishlist-popup.cpg-open { transform: translateX(0); }

/* ─── Popup Header (shared) ──────────────────────────── */
.cpg-cart-popup-header,
.cpg-wishlist-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid #f3f4f6;
    background: #fff;
    flex-shrink: 0;
}

.cpg-cart-popup-title,
.cpg-wishlist-popup-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cpg-wishlist-popup-title svg { color: #ef4444; flex-shrink: 0; }

.cpg-popup-count-badge,
.cpg-wl-popup-count-badge {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

.cpg-cart-close,
.cpg-wishlist-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #6b7280;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
    padding: 0;
    font-family: inherit;
    line-height: 1;
}

.cpg-cart-close:hover,
.cpg-wishlist-close:hover {
    background: #f3f4f6;
    color: #111827;
}

/* ─── Popup Body (shared) ────────────────────────────── */
.cpg-cart-popup-body,
.cpg-wishlist-popup-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cpg-cart-popup-body::-webkit-scrollbar,
.cpg-wishlist-popup-body::-webkit-scrollbar { width: 4px; }
.cpg-cart-popup-body::-webkit-scrollbar-track,
.cpg-wishlist-popup-body::-webkit-scrollbar-track { background: #f9fafb; }
.cpg-cart-popup-body::-webkit-scrollbar-thumb,
.cpg-wishlist-popup-body::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* ─── Empty State (shared) ───────────────────────────── */
.cpg-popup-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    color: #9ca3af;
    text-align: center;
}

.cpg-empty-icon { font-size: 48px; display: block; margin-bottom: 12px; }
.cpg-popup-empty p { margin: 0; font-size: 15px; }

/* ─── Cart Popup Item ────────────────────────────────── */
.cpg-popup-item {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    background: #f9fafb;
    border-radius: 10px;
    border: 1px solid #f3f4f6;
}

.cpg-popup-item-img {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #e5e7eb;
}

.cpg-popup-item-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cpg-popup-item-info {
    flex: 1;
    min-width: 0;
}

.cpg-popup-item-name {
    margin: 0 0 4px;
    font-size: 13px;
    font-weight: 600;
    color: #111827;
    line-height: 1.35;
    word-break: break-word;
    white-space: normal;
}

.cpg-popup-item-meta {
    margin: 0;
    font-size: 13px;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.cpg-popup-qty   { font-weight: 600; color: #374151; }
.cpg-popup-price { color: #dc2626; font-weight: 700; }

/* ─── Wishlist Popup Item ────────────────────────────── */
.cpg-wl-popup-item {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    background: #f9fafb;
    border-radius: 10px;
    border: 1px solid #f3f4f6;
    position: relative;
}

.cpg-wl-popup-item-img {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #e5e7eb;
}

.cpg-wl-popup-item-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cpg-wl-popup-item-info { flex: 1; min-width: 0; }

.cpg-wl-popup-item-name {
    margin: 0 0 4px;
    font-size: 13px;
    font-weight: 600;
    color: #111827;
    line-height: 1.35;
    word-break: break-word;
    white-space: normal;
    text-decoration: none;
    display: block;
}

.cpg-wl-popup-item-name:hover { color: #2563eb; }

.cpg-wl-popup-item-price {
    font-size: 13px;
    font-weight: 700;
    color: #dc2626;
    margin: 0 0 6px;
}

.cpg-wl-atc-btn {
    font-size: 11px;
    font-weight: 600;
    padding: 5px 10px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background 0.2s, color 0.2s;
    font-family: 'Poppins', sans-serif;
    white-space: nowrap;
}

.cpg-wl-remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
    line-height: 1;
    font-family: inherit;
}

.cpg-wl-remove-btn:hover { color: #ef4444; background: #fee2e2; }

/* ─── Cart Popup Footer ──────────────────────────────── */
.cpg-cart-popup-footer {
    padding: 16px 20px;
    border-top: 1px solid #f3f4f6;
    flex-shrink: 0;
    background: #fff;
}

.cpg-cart-subtotal-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    font-size: 15px;
    font-weight: 600;
    color: #111827;
}

.cpg-cart-subtotal-amount {
    color: #dc2626;
    font-size: 17px;
    font-weight: 700;
}

.cpg-cart-popup-actions {
    display: flex;
    gap: 10px;
}

.cpg-popup-view-cart,
.cpg-popup-checkout {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 14px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease;
    cursor: pointer;
    border: none;
    outline: none;
    font-family: 'Poppins', sans-serif;
    text-align: center;
    line-height: 1;
}

/* ─── Wishlist Popup Footer ──────────────────────────── */
.cpg-wishlist-popup-footer {
    padding: 16px 20px;
    border-top: 1px solid #f3f4f6;
    flex-shrink: 0;
    background: #fff;
}

.cpg-wl-popup-shop {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.2s ease, color 0.2s ease;
    background: #ef4444;
    color: #fff;
    width: 100%;
    text-align: center;
    gap: 6px;
}

.cpg-wl-popup-shop:hover { background: #dc2626; color: #fff; }

/* ─── Quantity Selector ──────────────────────────────── */
.cpg-quantity-selector {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

.cpg-qty-minus, .cpg-qty-plus {
    width: 30px;
    height: 30px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background 0.2s;
    font-family: 'Poppins', sans-serif;
}

.cpg-qty-minus:hover, .cpg-qty-plus:hover { background: #e5e7eb; }

.cpg-qty-input {
    width: 52px;
    height: 30px;
    text-align: center;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    font-family: 'Poppins', sans-serif;
}

/* ─── Spinner ────────────────────────────────────────── */
.cpg-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: cpgSpin 0.7s linear infinite;
    vertical-align: middle;
}

/* ─── Responsive ─────────────────────────────────────── */

/* Large Desktop: 1400px+ */
@media (min-width: 1400px) {
    .cpg-grid-wrapper { max-width: 1400px; }
}

/* Desktop: 993px – 1199px */
@media (max-width: 1199px) {
    .cpg-cart-popup,
    .cpg-wishlist-popup { width: 360px; }
}

/* Tablet: 768px – 992px */
@media (max-width: 992px) {
    .cpg-product-info { padding: 10px 12px 12px; }
}

/* Phablet / Large Mobile: 577px – 767px */
@media (max-width: 767px) {
    .cpg-cart-popup,
    .cpg-wishlist-popup {
        width: 100%;
        max-width: 100%;
    }
    .cpg-product-info { padding: 10px 10px 12px; }
    .cpg-add-to-cart-btn,
    .cpg-order-now-btn {
        min-height: 38px;
    }
    .cpg-wishlist-btn { width: 32px; height: 32px; }
    .cpg-heart-icon   { width: 16px; height: 16px; }
    .cpg-badge        { font-size: 10px; padding: 2px 8px; }
    .cpg-category-header-wrap { margin-bottom: 16px; }
}

/* Small Mobile: < 480px */
@media (max-width: 480px) {
    .cpg-cart-popup-title,
    .cpg-wishlist-popup-title { font-size: 14px; }
    .cpg-pagination { gap: 4px; }
    .cpg-page-btn, .cpg-prev-btn, .cpg-next-btn {
        min-width: 32px; height: 34px; font-size: 12px; padding: 0 8px;
    }
    .cpg-category-header-wrap { margin-bottom: 12px; }
}

/* ─── Print ──────────────────────────────────────────── */
@media print {
    .cpg-add-to-cart-btn, .cpg-order-now-btn,
    .cpg-pagination, .cpg-cart-popup,
    .cpg-wishlist-popup, .cpg-cart-overlay,
    .cpg-wishlist-overlay, .cpg-wishlist-btn { display: none !important; }
}
