/* ============================================
   WORLDWIDELABS FLAGSHIP UI v1.0
   Clean-slate design system - Nike/Apple quality
   ============================================ */

/* ---- Design Tokens ---- */
:root {
    /* Spacing */
    --wwl-sp-xs: 4px;
    --wwl-sp-sm: 8px;
    --wwl-sp-md: 16px;
    --wwl-sp-lg: 24px;
    --wwl-sp-xl: 32px;

    /* Colors */
    --wwl-primary: #0d9488;
    --wwl-primary-light: #f0fdfa;
    --wwl-text: #111827;
    --wwl-text-muted: #6b7280;
    --wwl-border: #e5e7eb;
    --wwl-bg-subtle: #f8fafc;

    /* Sizing */
    --wwl-thumb-size: 72px;
    --wwl-card-radius: 16px;
    --wwl-icon-tap: 48px;
}

/* ============================================
   PRODUCT GRID - All !important to override legacy
   ============================================ */
.products-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
    padding: 0 12px !important;
}

@media (min-width: 640px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 16px !important;
        padding: 0 !important;
    }
}

@media (min-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 24px !important;
    }
}

/* ============================================
   PRODUCT CARD - FLAGSHIP DESIGN
   ============================================ */
.products-grid>a,
.products-grid>div,
.wwl-card {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: var(--wwl-card-radius);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    text-decoration: none;
    color: inherit;
}

.products-grid>a:hover,
.products-grid>div:hover,
.wwl-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.15);
}

/* ============================================
   PRODUCT CARD - AUTHORITATIVE STYLES
   All !important to override legacy styles.css
   ============================================ */

/* Product Card Container */
.product-card {
    display: flex !important;
    flex-direction: column !important;
    background: white !important;
    border-radius: 16px !important;
    overflow: hidden !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
    border: none !important;
    transition: transform 0.3s ease, box-shadow 0.3s ease !important;
}

.product-card:hover {
    transform: translateY(-4px) !important;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12) !important;
}

/* Image Link Wrapper - CRITICAL: Override legacy min-height: 240px */
.product-card .product-image,
.product-card>a.product-image {
    display: block !important;
    width: 100% !important;
    height: 160px !important;
    min-height: unset !important;
    max-height: 160px !important;
    overflow: hidden !important;
    background: white !important;
    padding: 0 !important;
    aspect-ratio: unset !important;
}

/* Image Container */
.product-card .product-image-container {
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: white !important;
    overflow: hidden !important;
    padding: 0 !important;
}

/* The Actual Image - Mobile: Zoomed cover */
.product-card .product-image-container img,
.product-card .product-image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center 35% !important;
    transform: scale(1.5) !important;
    transform-origin: center 40% !important;
    transition: transform 0.4s ease !important;
    max-width: none !important;
    max-height: none !important;
}

.product-card:hover .product-image-container img,
.product-card:hover .product-image img {
    transform: scale(1.6) !important;
}

/* TABLET (640px+): Full vial visible, slight zoom for emphasis */
@media (min-width: 640px) {

    .product-card .product-image,
    .product-card>a.product-image {
        height: 200px !important;
        max-height: 200px !important;
    }

    .product-card .product-image-container img,
    .product-card .product-image img {
        object-fit: contain !important;
        object-position: center center !important;
        transform: scale(1.1) !important;
        transform-origin: center center !important;
        padding: 8px !important;
    }

    .product-card:hover .product-image-container img,
    .product-card:hover .product-image img {
        transform: scale(1.15) !important;
    }
}

/* DESKTOP (1024px+): Full vial with premium spacing */
@media (min-width: 1024px) {

    .product-card .product-image,
    .product-card>a.product-image {
        height: 220px !important;
        max-height: 220px !important;
    }

    .product-card .product-image-container img,
    .product-card .product-image img {
        object-fit: contain !important;
        object-position: center center !important;
        transform: scale(1.05) !important;
        transform-origin: center center !important;
        padding: 12px !important;
    }

    .product-card:hover .product-image-container img,
    .product-card:hover .product-image img {
        transform: scale(1.1) !important;
    }
}

/* Product Info */
.product-card .product-info {
    padding: 10px 12px 12px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
    flex: 1 !important;
}

/* Category Label */
.product-card .product-category {
    font-size: 0.6rem !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    color: #0d9488 !important;
    margin: 0 !important;
    line-height: 1.2 !important;
}

/* Product Name - Single line with ellipsis */
.product-card .product-name,
.product-card h3 {
    font-size: 0.8125rem !important;
    font-weight: 600 !important;
    color: #111827 !important;
    line-height: 1.3 !important;
    margin: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* Description - Hidden */
.product-card .product-desc,
.product-card p {
    display: none !important;
}

/* Footer - Price and Button */
.product-card .product-footer {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-top: auto !important;
    padding-top: 8px !important;
    border-top: 1px solid #e5e7eb !important;
}

/* Price */
.product-card .product-price {
    font-size: 0.875rem !important;
    font-weight: 700 !important;
    color: #0d9488 !important;
}

/* Cart Button */
.product-card .product-btn {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    border-radius: 8px !important;
    background: #0d9488 !important;
    color: white !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    padding: 0 !important;
    transition: background 0.2s ease !important;
}

.product-card .product-btn:hover {
    background: #0f766e !important;
}

.product-card .product-btn svg {
    width: 16px !important;
    height: 16px !important;
}

/* ============================================
   LEGACY SELECTORS - Keep for compatibility
   ============================================ */
.products-grid [class*="info"],
.products-grid [class*="content"],
.products-grid [class*="details"],
.wwl-card__body {
    padding: var(--wwl-sp-md);
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Category Label */
.products-grid [class*="category"],
.wwl-card__category {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.75px;
    color: var(--wwl-primary);
    margin-bottom: var(--wwl-sp-xs);
    line-height: 1.2;
}

/* Product Name */
.products-grid h3,
.products-grid [class*="name"],
.products-grid [class*="title"]:not([class*="detail"]),
.wwl-card__name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--wwl-text);
    line-height: 1.35;
    margin: 0 0 var(--wwl-sp-xs) 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Description */
.products-grid p,
.products-grid [class*="desc"],
.wwl-card__desc {
    font-size: 0.8125rem;
    color: var(--wwl-text-muted);
    line-height: 1.4;
    margin: 0 0 auto 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Card Footer - Price & Action */
.products-grid [class*="footer"],
.products-grid [class*="price-row"],
.wwl-card__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--wwl-sp-sm);
    padding-top: var(--wwl-sp-sm);
    border-top: 1px solid var(--wwl-border);
}

/* Price */
.products-grid [class*="price"],
.wwl-card__price {
    font-size: 1rem;
    font-weight: 700;
    color: var(--wwl-primary);
}

.products-grid [class*="price"] span,
.wwl-card__price span {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--wwl-text-muted);
    margin-left: 4px;
}

/* Cart Button */
.products-grid button,
.products-grid [class*="cart"],
.wwl-card__cart {
    width: var(--wwl-icon-tap);
    height: var(--wwl-icon-tap);
    min-width: var(--wwl-icon-tap);
    border-radius: 12px;
    background: var(--wwl-primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.products-grid button:hover,
.products-grid [class*="cart"]:hover,
.wwl-card__cart:hover {
    background: #0f766e;
    transform: scale(1.05);
}

.products-grid button svg,
.products-grid [class*="cart"] svg,
.wwl-card__cart svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   PRODUCT DETAIL PAGE - IMAGE-FIRST DESIGN
   ============================================ */

/* Hero Image - Let the image display at its natural size */
.gallery-main,
.wwl-detail__hero {
    width: 100%;
    background: white;
    overflow: hidden;
    border-radius: 0;
    border: none;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   DESKTOP PRODUCT DETAIL - Two-column Layout
   ============================================ */
@media (min-width: 768px) {
    .product-detail-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 40px !important;
        align-items: start !important;
    }

    .product-gallery {
        position: sticky !important;
        top: 100px !important;
    }

    /* Override inline style: width:100vw */
    .gallery-main,
    .product-gallery .gallery-main {
        width: 100% !important;
        margin-left: 0 !important;
        border-radius: 16px !important;
    }

    .gallery-main .product-image-container {
        max-height: 500px !important;
    }

    .gallery-main img,
    #mainImage {
        width: 100% !important;
        height: auto !important;
        max-height: 500px !important;
        object-fit: contain !important;
    }

    .product-detail-info {
        padding: 0 !important;
    }
}

.gallery-main .product-image-container,
.wwl-detail__hero-inner {
    width: 100%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.gallery-main img,
#mainImage,
.wwl-detail__hero img {
    width: 100%;
    height: auto;
    max-height: 60vh;
    object-fit: contain;
    object-position: center;
    display: block;
}

/* CoA Exception - Readable Display */
#mainImage[src*="-coa"],
.wwl-detail__hero img[src*="-coa"] {
    object-fit: contain;
    background: white;
    padding: 16px;
    max-height: 70vh;
}

/* Thumbnail Row */
.gallery-thumbs,
.wwl-detail__thumbs {
    display: flex;
    gap: 12px;
    padding: var(--wwl-sp-md) 20px;
    background: white;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.gallery-thumbs .thumb,
.wwl-detail__thumb {
    width: var(--wwl-thumb-size);
    height: var(--wwl-thumb-size);
    min-width: var(--wwl-thumb-size);
    flex-shrink: 0;
    border-radius: 12px;
    border: 2px solid var(--wwl-border);
    background: white;
    padding: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
    position: relative;
}

.gallery-thumbs .thumb:hover,
.wwl-detail__thumb:hover {
    border-color: var(--wwl-primary);
}

.gallery-thumbs .thumb.active,
.wwl-detail__thumb.active {
    border-color: var(--wwl-primary);
    background: var(--wwl-primary-light);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.gallery-thumbs .thumb img,
.wwl-detail__thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 6px;
}

/* COA Label Badge */
.gallery-thumbs .coa-label,
.wwl-detail__thumb-label {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--wwl-primary);
    color: white;
    font-size: 0.5625rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Product Info Section */
.product-detail-info,
.wwl-detail__info {
    padding: var(--wwl-sp-lg) 20px;
}

/* Breadcrumb */
.breadcrumb,
.wwl-detail__breadcrumb {
    font-size: 0.8125rem;
    color: var(--wwl-text-muted);
    margin-bottom: var(--wwl-sp-md);
}

.breadcrumb a,
.wwl-detail__breadcrumb a {
    color: var(--wwl-primary);
    text-decoration: none;
}

/* Product Title */
.product-detail-title,
.wwl-detail__title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--wwl-text);
    line-height: 1.25;
    margin: 0 0 var(--wwl-sp-sm) 0;
}

/* Product Price */
.product-detail-price,
.wwl-detail__price {
    margin-bottom: var(--wwl-sp-lg);
}

.product-detail-price .price-current,
.wwl-detail__price-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--wwl-primary);
}

.product-detail-price .currency,
.wwl-detail__price-currency {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--wwl-text-muted);
    margin-left: 6px;
}

/* Product Highlights */
.product-highlights,
.wwl-detail__highlights {
    display: flex;
    flex-direction: column;
    gap: var(--wwl-sp-sm);
    padding: var(--wwl-sp-md);
    background: var(--wwl-bg-subtle);
    border-radius: 12px;
    margin-bottom: var(--wwl-sp-lg);
}

.product-highlights .highlight,
.wwl-detail__highlight {
    display: flex;
    align-items: center;
    gap: var(--wwl-sp-sm);
    font-size: 0.875rem;
    color: var(--wwl-text);
}

.product-highlights svg,
.wwl-detail__highlight svg {
    width: 18px;
    height: 18px;
    color: var(--wwl-primary);
    flex-shrink: 0;
}

/* Product Actions */
.product-actions,
.wwl-detail__actions {
    display: flex;
    gap: var(--wwl-sp-md);
    align-items: center;
    margin-bottom: var(--wwl-sp-lg);
}

/* ============================================
   QUANTITY SELECTOR - Minimalistic Design
   ============================================ */
.quantity-selector,
.wwl-detail__qty {
    display: inline-flex !important;
    align-items: center !important;
    background: #f8fafc !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 12px !important;
    overflow: hidden !important;
}

.quantity-selector button,
.wwl-detail__qty button {
    width: 48px !important;
    min-width: 48px !important;
    height: 48px !important;
    background: transparent !important;
    border: none !important;
    font-size: 1.5rem !important;
    font-weight: 300 !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #374151 !important;
    flex-shrink: 0 !important;
}

.quantity-selector button:hover,
.wwl-detail__qty button:hover {
    background: #e5e7eb !important;
    color: #111827 !important;
}

.quantity-selector button:active,
.wwl-detail__qty button:active {
    transform: scale(0.9) !important;
    background: #d1d5db !important;
}

.quantity-selector input,
.wwl-detail__qty input {
    width: 50px !important;
    min-width: 50px !important;
    height: 48px !important;
    text-align: center !important;
    font-size: 1.125rem !important;
    font-weight: 600 !important;
    border: none !important;
    border-left: 1px solid #e5e7eb !important;
    border-right: 1px solid #e5e7eb !important;
    background: white !important;
    color: #111827 !important;
    -webkit-appearance: none !important;
    -moz-appearance: textfield !important;
    outline: none !important;
}

.add-to-cart-btn,
.wwl-detail__add-btn {
    flex: 1;
    height: 56px;
    padding: 0 var(--wwl-sp-lg);
    font-size: 1rem;
    font-weight: 600;
    border-radius: 12px;
    background: var(--wwl-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--wwl-sp-sm);
    transition: background 0.2s ease;
}

.add-to-cart-btn:hover,
.wwl-detail__add-btn:hover {
    background: #0f766e;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (min-width: 640px) {
    :root {
        --wwl-thumb-size: 88px;
    }

    .gallery-thumbs,
    .wwl-detail__thumbs {
        padding: 20px 24px;
        gap: 16px;
    }

    .product-detail-info,
    .wwl-detail__info {
        padding: var(--wwl-sp-xl) 24px;
    }

    .product-detail-title,
    .wwl-detail__title {
        font-size: 2rem;
    }
}

@media (min-width: 1024px) {

    .gallery-thumbs,
    .wwl-detail__thumbs {
        padding: 24px 32px;
    }

    .product-detail-info,
    .wwl-detail__info {
        padding: 0;
    }
}

/* ============================================
   RECENTLY VIEWED SECTION - Horizontal Scroll
   ============================================ */
.recently-viewed,
[class*="recent"] {
    padding: 24px 16px !important;
    overflow: hidden !important;
}

/* Target BOTH .products-grid AND .recently-viewed-grid */
.recently-viewed .products-grid,
.recently-viewed .recently-viewed-grid,
.recently-viewed-grid,
[class*="recent"] .products-grid {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 12px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 12px !important;
    scroll-snap-type: x mandatory !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    grid-template-columns: unset !important;
    grid-auto-flow: unset !important;
}

.recently-viewed .products-grid::-webkit-scrollbar,
.recently-viewed .recently-viewed-grid::-webkit-scrollbar,
.recently-viewed-grid::-webkit-scrollbar,
[class*="recent"] .products-grid::-webkit-scrollbar {
    display: none !important;
}

.recently-viewed .products-grid>a,
.recently-viewed .products-grid>div,
.recently-viewed .recently-viewed-grid>a,
.recently-viewed .recently-viewed-grid>div,
.recently-viewed-grid>a,
.recently-viewed-grid>div,
.recently-viewed .product-card,
[class*="recent"] .products-grid>a,
[class*="recent"] .products-grid>div,
[class*="recent"] .product-card {
    flex: 0 0 145px !important;
    min-width: 145px !important;
    max-width: 145px !important;
    scroll-snap-align: start !important;
}

.recently-viewed .product-card .product-image,
[class*="recent"] .product-card .product-image {
    height: 115px !important;
}

.recently-viewed .product-card .product-image-container img,
[class*="recent"] .product-card .product-image-container img {
    transform: scale(1.5) !important;
}
}