/* ============================================================
   FORENSIC AUDIT FIX — Art by Adliya Furnishing
   Phase 1-4: Global CSS System, Component Standardization,
   Responsive Grid, Performance & Production Hardening

   This file loads LAST and overrides all prior CSS layers
   to enforce the canonical design system.
   ============================================================ */

/* ===== PHASE 1: GLOBAL DESIGN SYSTEM ===== */

/* --- 1.1 CSS Custom Properties (Canonical Tokens) --- */
:root {
    /* Typography Scale */
    --fs-h1: 42px;
    --fs-h2: 30px;
    --fs-h3: 20px;
    --fs-body: 15px;
    --fs-small: 13px;
    --fs-xs: 11px;

    /* Section Spacing */
    --section-pad: 80px;
    --section-pad-md: 60px;
    --section-pad-sm: 45px;
    --section-pad-xs: 32px;

    /* Container */
    --container-max: 1320px;
    --container-pad: 20px;

    /* Card Standardization */
    --card-radius: 12px;
    --card-hover-lift: -6px;
    --card-shadow-hover: 0 12px 36px rgba(0, 0, 0, 0.12);

    /* Button Standardization */
    --btn-pad-y: 12px;
    --btn-pad-x: 28px;
    --btn-radius: 8px;
    --btn-font-size: 14px;
    --btn-font-weight: 600;
}

/* --- 1.2 Container System --- */
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--container-pad);
}

/* --- 1.3 Section Padding (Canonical 80px) --- */
.section-padding {
    padding: var(--section-pad) 0;
}

/* --- 1.4 Typography Scale --- */
.section-title,
h1.section-title {
    font-family: var(--font-heading, 'Playfair Display', serif);
    font-size: var(--fs-h1);
    font-weight: 700;
    color: var(--dark, #222);
    line-height: 1.2;
}

h2.section-title,
.section-header h2,
.deal-text h2 {
    font-size: var(--fs-h2);
    line-height: 1.3;
}

h3,
.feature-text h3,
.category-card h3,
.sidebar-categories h3,
.sidebar-banner h3 {
    font-size: var(--fs-h3);
    line-height: 1.4;
}

body {
    font-size: var(--fs-body);
    line-height: 1.6;
}

.section-subtitle {
    font-size: var(--fs-small);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--primary, #2D6A4F);
    margin-bottom: 8px;
}

/* ===== PHASE 2: COMPONENT STANDARDIZATION ===== */

/* --- 2.1 Product Card System --- */
.product-card {
    background: var(--white, #fff);
    border-radius: var(--card-radius) !important;
    overflow: hidden;
    border: 1px solid var(--border, #e8e8e8);
    transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1),
                box-shadow 0.4s cubic-bezier(0.23, 1, 0.32, 1),
                border-color 0.3s ease;
    position: relative;
    will-change: transform;
}

/* Override premium-cards.css 16px radius and -8px lift */
.product-card::before {
    border-radius: var(--card-radius) !important;
}

.product-card:hover,
.product-card:focus-within {
    transform: translateY(var(--card-hover-lift)) !important;
    box-shadow: var(--card-shadow-hover) !important;
    border-color: var(--primary, #2D6A4F);
}

/* Product image: 1:1 aspect ratio */
.product-image {
    position: relative;
    overflow: hidden;
    padding: 15px;
    background: var(--lighter, #f5f5f5);
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.5s ease;
}

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

/* Product info padding */
.product-info {
    padding: 16px;
}

.product-name {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 8px;
    height: 39px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-category {
    font-size: var(--fs-xs);
    color: var(--text-light, #666);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.current-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary, #2D6A4F);
    font-variant-numeric: tabular-nums;
}

.old-price {
    font-size: 14px;
    color: var(--text-light, #666);
    text-decoration: line-through;
}

/* --- 2.2 Grid System (4 → 2 → 1) --- */
.products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.trending-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}

/* --- 2.3 Button System --- */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary, #2D6A4F);
    color: var(--white, #fff);
    padding: var(--btn-pad-y) var(--btn-pad-x);
    border-radius: var(--btn-radius);
    font-weight: var(--btn-font-weight);
    font-size: var(--btn-font-size);
    border: 2px solid var(--primary, #2D6A4F);
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.4;
    min-height: 44px; /* Touch target */
}

.btn-primary:hover {
    background: var(--primary-dark, #1B4332);
    border-color: var(--primary-dark, #1B4332);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(45, 106, 79, 0.35);
}

.btn-large {
    padding: 15px 35px;
    font-size: 16px;
    min-height: 50px;
}

.add-to-cart-btn {
    border-radius: var(--btn-radius);
    font-size: var(--fs-small);
    font-weight: var(--btn-font-weight);
    min-height: 40px;
}

/* --- 2.4 Category Card --- */
.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 24px 16px;
    border: 1px solid var(--border, #e8e8e8);
    border-radius: var(--card-radius);
    transition: all 0.3s ease;
    background: var(--white, #fff);
}

.category-card:hover {
    border-color: var(--primary, #2D6A4F);
    box-shadow: var(--card-shadow-hover);
    transform: translateY(var(--card-hover-lift));
}

/* --- 2.5 Feature Card --- */
.feature-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px;
    background: var(--white, #fff);
    border: 1px solid var(--border, #e8e8e8);
    border-radius: var(--card-radius);
    transition: all 0.3s ease;
}

.feature-card:hover {
    border-color: var(--primary, #2D6A4F);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-3px);
}

/* --- 2.6 Section Header --- */
.section-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 32px;
    gap: 16px;
    flex-wrap: wrap;
}

.section-header.centered {
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* --- 2.7 Tab Buttons --- */
.tab-btn {
    padding: 8px 20px;
    border-radius: 30px;
    font-size: var(--fs-small);
    font-weight: 500;
    color: var(--text, #555);
    border: 1px solid var(--border, #e8e8e8);
    transition: all 0.3s ease;
    white-space: nowrap;
    min-height: 38px;
    cursor: pointer;
}

.tab-btn:hover,
.tab-btn.active {
    background: var(--primary, #2D6A4F);
    color: var(--white, #fff);
    border-color: var(--primary, #2D6A4F);
}

/* ===== PHASE 3: RESPONSIVE SYSTEM ===== */

/* --- Large Desktop (1200px) --- */
@media (max-width: 1200px) {
    :root {
        --fs-h1: 36px;
        --fs-h2: 26px;
    }

    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .trending-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .categories-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* --- Tablet / Medium (992px) --- */
@media (max-width: 992px) {
    :root {
        --section-pad: var(--section-pad-md);
    }

    .section-padding {
        padding: var(--section-pad-md) 0;
    }

    .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .trending-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .categories-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 25px;
    }

    .products-layout {
        grid-template-columns: 1fr;
    }

    .products-sidebar {
        display: none;
    }

    .deal-content {
        flex-direction: column;
        text-align: center;
    }

    .deal-countdown {
        justify-content: center;
    }

    .deal-price {
        justify-content: center;
    }

    .deal-image {
        flex: none;
    }

    .newsletter-content {
        flex-direction: column;
        text-align: center;
    }

    .newsletter-form {
        max-width: 100%;
    }
}

/* --- Small Tablet (768px) --- */
@media (max-width: 768px) {
    :root {
        --fs-h1: 30px;
        --fs-h2: 24px;
        --fs-h3: 18px;
    }

    .section-padding {
        padding: var(--section-pad-sm) 0;
    }

    .section-title,
    h1.section-title {
        font-size: var(--fs-h1);
    }

    .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px;
    }

    .trending-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .categories-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }

    .features-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .footer-bottom-content {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .section-tabs {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        white-space: nowrap;
        gap: 0;
        width: 100%;
        padding-bottom: 5px;
    }
    .section-tabs::-webkit-scrollbar {
        display: none;
    }

    .promo-grid {
        grid-template-columns: 1fr;
    }

    .promo-grid .promo-card:last-child {
        grid-column: auto;
    }

    .deal-text h2 {
        font-size: 24px;
    }

    .deal-image img {
        max-height: 250px;
    }

    .hero-text h1 {
        font-size: 28px;
    }

    .hero-text h2 {
        font-size: 20px;
    }
}

/* --- Mobile (480px) --- */
@media (max-width: 480px) {
    :root {
        --fs-h1: 24px;
        --fs-h2: 20px;
        --fs-h3: 16px;
        --container-pad: 15px;
    }

    .container {
        padding: 0 var(--container-pad);
    }

    .section-padding {
        padding: var(--section-pad-xs) 0;
    }

    .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }

    .trending-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }

    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .product-info {
        padding: 10px;
    }

    .product-name {
        font-size: 13px;
        height: auto;
        -webkit-line-clamp: 2;
    }

    .current-price {
        font-size: 16px;
    }

    .header-main-content {
        gap: 12px;
    }

    .logo-text {
        font-size: 22px;
    }

    .hero-text h1 {
        font-size: 22px;
    }

    .hero-text h2 {
        font-size: 15px;
    }

    .btn-large {
        padding: 12px 24px;
        font-size: 14px;
    }

    .category-card {
        padding: 16px 10px;
    }

    .category-icon {
        width: 50px;
        height: 50px;
    }

    .category-icon i {
        font-size: 22px;
    }

    .category-card h3 {
        font-size: 12px;
    }

    .category-card span {
        font-size: 10px;
    }

    .deal-countdown {
        gap: 8px;
    }

    .deal-cd-item {
        padding: 8px 12px;
        min-width: 55px;
    }

    .deal-cd-val {
        font-size: 22px;
    }
}

/* --- Very small screens (360px) --- */
@media (max-width: 360px) {
    .products-grid {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }

    .trending-grid {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }

    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
}

/* ===== PHASE 4: PERFORMANCE & POLISH ===== */

/* --- 4.1 Lazy Loading Placeholder --- */
img[loading="lazy"] {
    background: linear-gradient(135deg, #f5f5f5 25%, #ebebeb 50%, #f5f5f5 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

img[loading="lazy"][src] {
    animation: none;
    background: none;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* --- 4.2 Reduce Motion Preference --- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    img[loading="lazy"] {
        animation: none;
    }
}

/* --- 4.3 Touch Device Optimization --- */
@media (pointer: coarse) {
    /* Ensure add-to-cart and action buttons visible without hover */
    .product-card .product-actions {
        opacity: 1 !important;
        transform: translateX(0) !important;
    }

    .product-card .add-to-cart-btn {
        opacity: 1 !important;
        transform: translateY(0) !important;
    }

    /* Minimum touch targets */
    .action-icon {
        width: 40px;
        height: 40px;
        min-width: 44px;
        min-height: 44px;
    }

    .tab-btn {
        min-height: 44px;
        padding: 10px 20px;
    }

    /* Disable hover transforms on touch */
    .product-card:hover {
        transform: none !important;
    }

    .product-card:active {
        transform: scale(0.98) !important;
        transition-duration: 0.1s !important;
    }

    .category-card:hover {
        transform: none;
    }

    .feature-card:hover {
        transform: none;
    }
}

/* --- 4.4 Print Styles --- */
@media print {
    .announcement-bar, .header, .footer, .back-to-top,
    .newsletter-section, .luxury-preloader, .luxury-cursor,
    .luxury-cursor-ring, .mobile-menu, .mobile-nav,
    .product-actions, .add-to-cart-btn, .btn-primary,
    .exclusive-offers, nav, .whatsapp-sticky,
    .mobile-sticky-cart { display: none !important; }

    body { background: white !important; color: black !important; font-size: 12pt; }
    .container { max-width: 100% !important; padding: 0 !important; }
    img { max-width: 100% !important; }
    a { color: black !important; text-decoration: underline; }
    .product-card { break-inside: avoid; box-shadow: none !important; border: 1px solid #ddd; }
    .section-padding { padding: 20px 0 !important; }
}

/* --- 4.5 Fix: Empty Space Prevention --- */
section:empty,
div:empty:not([class*="badge"]):not([aria-live]):not([id]) {
    display: none;
}

/* --- 4.6 Fix: Image aspect ratio protection --- */
.product-image img,
.category-card img,
.promo-card-image img {
    aspect-ratio: auto;
    max-width: 100%;
    height: auto;
}

/* --- 4.7 Fix: Scrollbar Prevention on body --- */
html, body {
    overflow-x: hidden;
}

/* --- 4.8 Fix: Focus Visible Consolidation --- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--gold, #c9a96e);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(201, 169, 110, 0.2);
}

/* --- 4.9 Fix: Newsletter section spacing --- */
.newsletter-section {
    padding: 50px 0;
}

/* --- 4.10 Fix: Hero section consistent height --- */
.hero-slides {
    min-height: 450px;
}

@media (max-width: 992px) {
    .hero-slides {
        min-height: 350px;
    }
}

@media (max-width: 768px) {
    .hero-slides {
        min-height: 300px;
        max-height: 55vh;
    }
}

@media (max-width: 480px) {
    .hero-slides {
        min-height: 260px;
    }
}

/* --- 4.11 Fix: Smooth page transitions --- */
.product-card,
.category-card,
.feature-card,
.promo-card {
    opacity: 1;
}

/* --- 4.12 Fix: Sidebar banner text readability --- */
.sidebar-banner h3 {
    font-size: 24px;
    font-weight: 700;
    margin: 8px 0;
}

/* --- 4.13 Fix: Deal banner responsiveness --- */
.deal-banner {
    padding: var(--section-pad) 0;
}

@media (max-width: 768px) {
    .deal-banner {
        padding: var(--section-pad-sm) 0;
    }
}

/* --- 4.14 Fix: Footer grid consistency --- */
.footer {
    padding-top: 60px;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1.2fr;
    gap: 30px;
}

@media (max-width: 992px) {
    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .footer-grid {
        grid-template-columns: 1fr;
    }
}

/* --- 4.15 Fix: Products layout sidebar --- */
.products-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 30px;
}

@media (max-width: 992px) {
    .products-layout {
        grid-template-columns: 1fr;
    }
}

/* --- 4.16 Fix: Consistent badge styling --- */
.badge-new,
.badge-sale,
.badge-pack {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* --- 4.17 Fix: Form input standardization --- */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="search"],
input[type="number"],
textarea,
select {
    font-family: var(--font, 'Poppins', sans-serif);
    font-size: 14px;
    padding: 10px 14px;
    border: 1px solid var(--border, #e8e8e8);
    border-radius: var(--btn-radius);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    min-height: 44px;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary, #2D6A4F);
    box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.1);
    outline: none;
}

/* --- 4.18 Fix: Announcement bar consistency --- */
.announcement-bar {
    background: var(--secondary, #1a1a2e);
    color: var(--white, #fff);
    padding: 10px 0;
    font-size: var(--fs-small);
    text-align: center;
}

/* --- 4.19 Fix: Back to Top button --- */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary, #2D6A4F);
    color: var(--white, #fff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    z-index: 900;
    cursor: pointer;
}

.back-to-top:hover {
    background: var(--primary-dark, #1B4332);
    transform: translateY(-3px);
}
