/* 
  MEDICO LIFE SCIENCE - Products Page Specific Styles
  ===================================================
*/

/* Reset for alignment issues */
body, html {
    width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

#products-container,
.products-category-section,
.products-hero,
.cta-section {
    width: 100%;
    display: block;
}

/* Force center alignment for all containers */
.container {
    grid-template-columns: repeat(3, 1fr);
    max-width: 1400px;
}

/* Ensure header container is also centered */
.header-container {
    max-width: 1280px;
    margin: 0 auto;
}


/* Products Hero Section */
.products-hero {
    min-height: 70vh;
    padding-top: 10rem;
    padding-bottom: 4rem;
    background: linear-gradient(180deg, rgba(92, 69, 191, 0.06) 0%, rgba(92, 69, 191, 0.02) 100%);
    position: relative;
    overflow: hidden;
    width: 100%;
}

.hero-content {
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

/* Category Navigation */
.category-navigation {
    margin-top: 3rem;
    padding: 1.5rem 0;
    width: 100%;
    text-align: center;
}

.filter-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 100%;
    padding: 1rem 0;
    margin: 0 auto;
}

.filter-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    font-size: 0.9rem;
    font-weight: 600;
    background-color: var(--secondary);
    color: var(--foreground);
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
    flex-shrink: 0;
}

.filter-btn:hover {
    background-color: var(--light-bg);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.filter-btn.active {
    background-color: var(--accent);
    color: var(--accent-foreground);
    border-color: var(--accent);
    box-shadow: 0 5px 15px rgba(113, 0, 0, 0.2);
}

/* Products Category Sections */
.products-category-section {
    padding: 5rem 0;
    position: relative;
    scroll-margin-top: 100px;
    width: 100%;
}

.products-category-section:nth-child(even) {
    background-color: var(--light-bg);
}

.category-header {
    text-align: center;
    margin-bottom: 3rem;
    width: 100%;
}

.category-title-wrapper {
    display: block;
    width: 100%;
    text-align: center;
    position: relative;
    padding-bottom: 1rem;
}

.category-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--foreground);
    margin-bottom: 0.5rem;
    position: relative;
    display: inline-block;
    text-align: center;
}

.category-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(to right, var(--accent), var(--primary));
    border-radius: 2px;
}

.category-subtitle {
    font-size: 1.125rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 1.5rem auto 0;
    line-height: 1.6;
    text-align: center;
    width: 100%;
}

/* Products Category Grid - Center the cards */
.products-category-grid {
    display: grid;
    gap: 30px;
    grid-template-columns: repeat(3, 1fr);
    padding: 0;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    justify-items: center; /* Center grid items */
}

/* Fix container for category sections */
.products-category-section .container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem;
}

@media (min-width: 640px) {
    .products-category-section .container {
        padding: 0 1.5rem;
    }
}

/* Product Card Enhancements for Products Page */
.product-card {
    perspective: 1500px;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px; /* Limit card width */
    height: 480px; /* Fixed height for consistent cards */
    margin: 0 auto; /* Center the card */
}

.atvImg {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-lg);
    transform-style: preserve-3d;
    transition: transform 0.1s ease-out;
    box-shadow: 0 25px 50px rgba(14, 21, 47, 0.1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.card-content {
    width: 100%;
    height: 100%;
    background: var(--secondary);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-lemon);
}

.card-image {
    width: 100%;
    position: relative;
    overflow: hidden;
    
    /* Base height for large screens (4 cards) */
    height: 55%;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.atvImg:hover .card-image img {
    transform: scale(1.05);
}

.card-info {
    padding: 25px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 2;
    background: var(--secondary);
}

.product-name {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0 0 12px 0;
    color: var(--dark-grey);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.6em;
    text-align: center; /* Center product name */
}

.product-description {
    color: var(--secondary-foreground);
    margin: 0 0 15px 0;
    flex-grow: 1;
    font-size: 0.95rem;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 4.8em;
    text-align: center; /* Center description */
}

.card-info:has(.product-tags) .product-description,
.card-info:has(.product-specs) .product-description {
    -webkit-line-clamp: 2;
    min-height: 3.2em;
}

/* Product Specifications */
.product-specs {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.spec-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--secondary-foreground);
}

.spec-item i {
    width: 16px;
    height: 16px;
    color: var(--accent);
    flex-shrink: 0;
}

/* Product Tags */
.product-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    justify-content: center; /* Center tags */
}

.tag {
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.tag-primary {
    background-color: var(--primary);
    color: var(--primary-foreground);
    border: 1px solid var(--border-lemon);
}

.tag-accent {
    background-color: var(--accent);
    color: var(--accent-foreground);
}

.tag-green {
    background-color: var(--green);
    color: var(--green-foreground);
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

.price {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--accent);
    text-align: center; /* Center price */
}

.add-to-cart {
    background-color: var(--primary);
    color: var(--primary-foreground);
    border: none;
    padding: 12px 28px;
    border-radius: var(--radius);
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.95rem;
    letter-spacing: 0.5px;
    margin: 0;
}

.add-to-cart:hover {
    background-color: var(--yellow);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(253, 244, 133, 0.3);
}

/* Category Empty State */
.category-empty {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--light-bg);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--border);
    max-width: 600px;
    margin: 0 auto;
}

/* Ensure all sections are properly centered */
section, .cta-section, .products-hero {
    width: 100%;
}

section .container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem;
}

@media (min-width: 640px) {
    section .container {
        padding: 0 1.5rem;
    }
}

/* Center the filter buttons container */
.filter-buttons-container {
    display: flex;
    justify-content: center;
    width: 100%;
}

/* Fix for product card alignment within grid */
.product-card {
    margin: 0 auto;
}

/* Center the CTA section */
.cta-section .container {
    display: flex;
    justify-content: center;
}

.cta-card {
    width: 100%;
    max-width: 1280px;
}

.cta-content {
    margin: 0 auto;
}

/* Scroll to top button */
.scroll-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background-color: var(--accent);
    color: var(--accent-foreground);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all var(--transition-normal);
    box-shadow: 0 5px 20px rgba(113, 0, 0, 0.3);
    z-index: 1000;
    border: none;
}

.scroll-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-top:hover {
    background-color: #4a0000;
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(113, 0, 0, 0.4);
}

.scroll-top i {
    width: 1.5rem;
    height: 1.5rem;
}

/* ========== RESPONSIVE DESIGN ========== */

/* Large Desktop: 1239px and up - 4 columns */
@media screen and (min-width: 1239px) {
    .products-category-grid {
        grid-template-columns: repeat(3, 1fr);
        max-width: 1400px;
    }
    
    .product-card {
        height: 500px;
    }
}

/* Desktop: 1024px - 1238px - 3 columns */
@media screen and (min-width: 1024px) and (max-width: 1238px) {
    .products-hero {
        min-height: 60vh;
        padding-top: 8rem;
        padding-bottom: 4rem;
    }
    
    .products-category-section {
        padding: 4rem 0;
    }
    
    .products-category-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 25px;
        max-width: 1200px;
    }
    
    .product-card {
        height: 460px;
    }
    
    .category-title {
        font-size: 2.25rem;
    }
    
    .filter-btn {
        padding: 0.65rem 1.25rem;
        font-size: 0.85rem;
    }
}

/* Tablet Landscape: 992px - 1023px - 3 columns */
@media screen and (min-width: 992px) and (max-width: 1023px) {
    .products-category-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
        max-width: 1000px;
    }
    
    .product-card {
        height: 440px;
    }
    
    .category-title {
        font-size: 2rem;
    }
}

/* Tablet Portrait: 768px - 991px - 2 columns */
@media screen and (min-width: 768px) and (max-width: 991px) {
    .products-hero {
        min-height: auto;
        padding-top: 7rem;
        padding-bottom: 3rem;
    }
    
    .products-category-section {
        padding: 3rem 0;
    }
    
    .products-category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
        max-width: 750px;
    }
    
    .product-card {
        height: 420px;
    }
    
    .category-title {
        font-size: 1.75rem;
    }
    
    .filter-buttons {
        justify-content: center;
        padding-bottom: 0.5rem;
    }
    
    .filter-btn {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }
    .tag {
    padding: 5px 12px;
    border-radius: 50px;
    font-size: 0.65rem;
    font-weight: 550;
    letter-spacing: 0.3px;
}
}

/* Mobile Landscape: 576px - 767px - 2 columns */
@media screen and (min-width: 576px) and (max-width: 767px) {
    .products-hero {
        padding-top: 7rem;
        padding-bottom: 2rem;
    }
    
    .products-category-section {
        padding: 2.5rem 0;
    }
    
    .products-category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        max-width: 550px;
    }
    
    .product-card {
        height: 400px;
        max-width: 100%;
    }
    
    .category-title {
        font-size: 1.75rem;
    }
    
    .category-subtitle {
        font-size: 1rem;
        margin: 1rem auto 0;
    }
    
    .filter-buttons {
        gap: 0.5rem;
    }
    
    .filter-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.75rem;
    }
    
}

/* Mobile Portrait: 480px - 575px - 1 column */
@media screen and (min-width: 480px) and (max-width: 575px) {
    .products-hero {
        padding-top: 6rem;
        padding-bottom: 2rem;
    }
    
    .products-category-grid {
        grid-template-columns: 1fr;
        gap: 15px;
        max-width: 480px;
    }
    
    .product-card {
        height: 380px;
        max-width: 100%;
    }
    
    .category-title {
        font-size: 1.5rem;
    }
    
    .filter-buttons {
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 1rem;
        -webkit-overflow-scrolling: touch;
    }
    
    .filter-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.75rem;
        flex-shrink: 0;
    }
}

/* Small Mobile: 0px - 479px - 1 column */
@media screen and (max-width: 479px) {
    .products-hero {
        padding-top: 6rem;
        padding-bottom: 1.5rem;
    }
    
    .category-navigation {
        margin-top: 2rem;
        padding: 1rem 0;
    }
    
    .products-category-section {
        padding: 2rem 0;
    }
    
    .products-category-grid {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 0 0.5rem;
    }
    
    .product-card {
        height: 360px;
        max-width: 100%;
    }
    
    .category-title {
        font-size: 1.4rem;
    }
    
    .category-subtitle {
        font-size: 0.9rem;
        padding: 0 0.5rem;
    }
    
    .card-info {
        padding: 20px;
    }
    
    .product-name {
        font-size: 1.2rem;
        margin-bottom: 8px;
    }
    
    .product-description {
        font-size: 0.9rem;
        margin-bottom: 12px;
    }
    
    .price {
        font-size: 1.6rem;
    }
    
    .add-to-cart {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    .scroll-top {
        bottom: 1rem;
        right: 1rem;
        width: 3rem;
        height: 3rem;
    }
    
    .scroll-top i {
        width: 1.25rem;
        height: 1.25rem;
    }
}

/* Hide scrollbar for filter buttons but keep functionality */
.filter-buttons::-webkit-scrollbar {
    display: none;
}

.filter-buttons {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

/* Fix for iOS Safari 100vh issue */
@supports (-webkit-touch-callout: none) {
    .products-hero {
        min-height: -webkit-fill-available;
    }
}

/* Print styles */
@media print {
    .filter-buttons,
    .scroll-top,
    .add-to-cart,
    .header,
    .footer,
    .cta-section {
        display: none !important;
    }
    
    .products-category-section {
        page-break-inside: avoid;
        break-inside: avoid;
    }
    
    .product-card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        height: auto !important;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .product-card,
    .filter-btn,
    .add-to-cart,
    .scroll-top,
    .atvImg {
        transition: none !important;
        animation: none !important;
    }
    
    .atvImg:hover .card-image img {
        transform: none !important;
    }
}

/* Animation for category sections */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.products-category-section.reveal.in-view {
    animation: fadeInUp 0.6s ease forwards;
}

/* Loading animation for product filtering */
.loading-products {
    text-align: center;
    padding: 3rem;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--light-bg);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Animation for product cards appearing */
@keyframes cardAppear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.product-card {
    animation: cardAppear 0.5s ease forwards;
    animation-delay: calc(var(--card-index, 0) * 0.1s);
}

/* Staggered animation for product cards */
.product-card:nth-child(1) { --card-index: 1; }
.product-card:nth-child(2) { --card-index: 2; }
.product-card:nth-child(3) { --card-index: 3; }
.product-card:nth-child(4) { --card-index: 4; }
.product-card:nth-child(5) { --card-index: 5; }
.product-card:nth-child(6) { --card-index: 6; }