/* =========================================
   PRODUCTS & E-COMMERCE STYLES
   No-scroll layout — 3×3 compact grid
   ========================================= */

/* =========================================
   SLIDE WRAPPER — fills viewport, no scroll
   Combined selector ensures !important overrides
   inherited .slide-content spacing correctly.
   ========================================= */
.slide-content.products-slide-wrapper,
.products-slide-wrapper {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: stretch !important;
    text-align: left !important;
    padding: 0.75rem 1.25rem 0.5rem !important;
    height: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

/* =========================================
   HEADER — compact row with title + cart
   ========================================= */
.products-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1300px;
    margin: 0 auto;
    padding-bottom: 0.5rem;
}

.products-header .title {
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    margin: 0;
}

/* =========================================
   CART TOGGLE BUTTON
   ========================================= */
.cart-toggle {
    cursor: pointer;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    padding: 0.6rem;
    border-radius: var(--radius-full);
    position: relative;
    transition: var(--transition-bounce);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.cart-toggle:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.cart-icon-container {
    position: relative;
}

.cart-icon-container i {
    font-size: 1.1rem;
}

.cart-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--accent-gradient);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    border: 2px solid var(--surface-1);
}

@keyframes pulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.25); }
    100% { transform: scale(1); }
}
.pulse-anim { animation: pulse 0.3s ease-in-out; }

/* =========================================
   PRODUCT GRID — 3 columns × 3 rows
   fills remaining height with no overflow
   ========================================= */
.products-container {
    flex: 1;
    min-height: 0;                          /* critical for flex child shrink */
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);     /* exactly 3 rows, auto-size */
    gap: 0.65rem;
    width: 100%;
    max-width: 1300px;
    margin: 0 auto;
}

/* =========================================
   PRODUCT CARD — compact, no description
   ========================================= */
.product-card {
    background: var(--surface-2);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: var(--transition-bounce);
    display: flex;
    flex-direction: column;
    min-height: 0;              /* allow grid to shrink this */
    cursor: pointer;
}

.product-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

/* Image section fills most of the card */
.product-image {
    position: relative;
    flex: 1;
    min-height: 0;
    aspect-ratio: 4 / 3;        /* always reserves space even if img fails */
    overflow: hidden;
    /* gradient shows as placeholder when image is missing/slow */
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--border-color) 100%);
}

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

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

/* Category tag badge — top-left overlay on image */
.product-category.tag {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(var(--surface-1-rgb), 0.88);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    margin: 0;
    font-size: 0.62rem;
    padding: 0.15rem 0.55rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
}

/* Eye icon hint — bottom-centre of image */
.product-view-hint {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 1.5rem 0 0.5rem;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: linear-gradient(to top, rgba(0,0,0,0.45) 0%, transparent 100%);
    opacity: 0;
    transition: var(--transition-fast);
    pointer-events: none;
}

.product-view-hint i {
    color: white;
    font-size: 1.1rem;
    padding-bottom: 0.35rem;
}

.product-card:hover .product-view-hint {
    opacity: 1;
}

/* Info strip at card bottom */
.product-info {
    flex-shrink: 0;
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.product-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'Hind Madurai', sans-serif;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    cursor: pointer;
}

.product-title:hover {
    color: var(--primary-color);
}

.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.4rem;
}

.product-price {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--primary-color);
    white-space: nowrap;
}

.btn-add-cart {
    background: var(--surface-1);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-add-cart:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-1px);
}

/* =========================================
   PAGINATION — compact bottom bar
   ========================================= */
.pagination-controls {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.4rem 0 0.2rem;
    flex-wrap: wrap;
}

.page-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: var(--surface-2);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-btn:hover:not(.disabled):not(.active) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(8, 145, 178, 0.25);
}

.page-btn.active {
    background: var(--accent-gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(8, 145, 178, 0.3);
    transform: scale(1.05);
    pointer-events: none;
}

.page-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.page-nav {
    width: 30px;
    height: 30px;
    font-size: 0.7rem;
}

.page-info {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
    margin-left: 0.5rem;
}

/* =========================================
   PRODUCT DETAIL MODAL
   ========================================= */
.product-detail-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s ease;
}

.product-detail-modal.active {
    opacity: 1;
    visibility: visible;
}

.pdm-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    cursor: pointer;
}

.pdm-content {
    position: relative;
    background: var(--surface-1);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    display: flex;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    transform: translateY(20px) scale(0.97);
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.product-detail-modal.active .pdm-content {
    transform: translateY(0) scale(1);
}

/* Left — image panel */
.pdm-image-section {
    width: 45%;
    flex-shrink: 0;
    position: relative;
    background: var(--surface-2);
    overflow: hidden;
}

.pdm-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

.pdm-image-section:hover .pdm-image {
    transform: scale(1.04);
}

.pdm-category {
    position: absolute;
    top: 1rem;
    left: 1rem;
    margin: 0;
    font-size: 0.65rem;
    padding: 0.2rem 0.65rem;
    background: rgba(var(--surface-1-rgb), 0.9);
    backdrop-filter: blur(4px);
}

/* Right — info panel */
.pdm-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem 1.75rem;
    gap: 1rem;
    overflow-y: auto;
}

.pdm-name {
    font-family: 'Hind Madurai', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.3;
}

.pdm-desc {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.65;
    flex: 1;
    margin: 0;
}

.pdm-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.pdm-price {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-color);
}

.pdm-add-btn {
    padding: 0.7rem 1.4rem;
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: 0.3px;
}

/* Close button */
.pdm-close {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
    transition: var(--transition-fast);
    z-index: 10;
}

.pdm-close:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    transform: rotate(90deg);
}

/* =========================================
   CART SIDEBAR (offcanvas)
   ========================================= */
.cart-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-normal);
}

.cart-overlay.active {
    opacity: 1;
    visibility: visible;
}

.cart-sidebar {
    position: fixed;
    top: 0; right: -400px;
    width: 400px; max-width: 100vw;
    height: 100%;         /* Fill the container (Swiper slide) */
    background: var(--surface-1);
    z-index: 1001;
    box-shadow: -5px 0 25px rgba(0,0,0,0.12);
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.cart-sidebar.active { right: 0; }

.cart-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface-2);
}

.cart-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-family: 'Merriweather', serif;
    color: var(--primary-color);
}

.close-cart-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.4rem;
    cursor: pointer;
    transition: var(--transition-fast);
    padding: 0;
    display: flex;
}

.close-cart-btn:hover {
    color: var(--accent-color);
    transform: rotate(90deg);
}

.cart-items-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.empty-cart {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    text-align: center;
}

.empty-icon {
    font-size: 2.75rem;
    opacity: 0.3;
    margin-bottom: 1rem;
}

.cart-item {
    display: flex;
    gap: 0.85rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.cart-item-img {
    width: 65px; height: 65px;
    object-fit: cover;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    flex-shrink: 0;
}

.cart-item-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.cart-item-title {
    font-size: 0.88rem;
    margin: 0 0 0.2rem;
    line-height: 1.2;
    color: var(--text-primary);
}

.cart-item-price {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.85rem;
    margin-bottom: auto;
}

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.45rem;
}

.qty-btn {
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    width: 22px; height: 22px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
    color: var(--text-primary);
    transition: var(--transition-fast);
    font-size: 0.85rem;
}

.qty-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.qty-value {
    font-size: 0.85rem;
    font-weight: 500;
    min-width: 14px;
    text-align: center;
}

.remove-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    margin-left: auto;
    transition: var(--transition-fast);
    padding: 0.15rem;
    font-size: 0.85rem;
}

.remove-btn:hover { color: var(--accent-color); }

.cart-footer {
    flex-shrink: 0;                         /* never compress the checkout area */
    padding: 1.25rem 1.5rem;
    background: var(--surface-2);
    border-top: 1px solid var(--border-color);
}

.cart-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.cart-summary strong {
    font-size: 1.3rem;
    color: var(--text-primary);
}

.checkout-btn {
    padding: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.4px;
}

.cart-disclaimer {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin: 0.65rem 0 0;
}

/* =========================================
   TOAST NOTIFICATION
   ========================================= */
.procare-toast {
    position: fixed;
    bottom: 2rem; left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--surface-top);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.65rem 1.4rem;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
    z-index: 3000;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    font-size: 0.9rem;
}

.procare-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

.procare-toast.success i { color: var(--primary-color); }
.procare-toast.error   i { color: var(--accent-color); }

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 900px) {
    .products-container {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(3, 1fr); /* keep 3 rows, 2 cols = 6 items */
    }

    .pdm-content {
        flex-direction: column;
        max-height: 92vh;
    }

    .pdm-image-section {
        width: 100%;
        height: 220px;
    }

    .pdm-info {
        padding: 1.25rem;
    }
}

@media (max-width: 600px) {
    .products-slide-wrapper {
        padding: 0.5rem 0.75rem 0.35rem;
    }

    .products-container {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(3, 1fr);
        gap: 0.5rem;
    }

    .cart-sidebar {
        width: 100vw;
        right: -100vw;
    }

    .pdm-image-section {
        height: 180px;
    }
}
