/* Global Styles & Tokens */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600&display=swap');

:root {
    --h: 220;
    --s: 10%;
    --bg-primary: hsl(var(--h), var(--s), 98%);
    --bg-secondary: hsl(var(--h), var(--s), 95%);
    --text-primary: hsl(var(--h), var(--s), 10%);
    --text-secondary: hsl(var(--h), var(--s), 40%);
    --accent: #000000;
    --accent-soft: rgba(0, 0, 0, 0.05);
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.3);
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.05);
    --border-radius-sm: 8px;
    --border-radius-md: 16px;
    --border-radius-lg: 24px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 32px;
    --spacing-xl: 60px;
    --header-height: 56px;
    --font-main: 'Inter', sans-serif;
    --font-display: 'Outfit', sans-serif;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --saT: env(safe-area-inset-top);
    --saB: env(safe-area-inset-bottom);
    --saL: env(safe-area-inset-left);
    --saR: env(safe-area-inset-right);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
    /* Base size */
}

body {
    font-family: var(--font-main);
    background-color: #ffffff;
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    padding-bottom: var(--saB);
    /* Safe area for bottom navigation bar */
}

h1,
h2,
h3,
h4,
.logo {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.app-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
    background-color: white;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

@media (min-width: 600px) {
    .app-container {
        max-width: 600px;
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.1);
        margin: 0 auto;
    }
}

@media (min-width: 1024px) {
    .app-container {
        max-width: 1200px;
    }
}

/* Animations */
.fade-in-up {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.fade-in-up.visible {
    opacity: 1;
    transform: translateY(0);
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    transition: transform 0.1s;
}

button:active {
    transform: scale(0.96);
}

/* Navbar */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--header-height) + var(--saT));
    padding-top: var(--saT);
    z-index: 1000;
    transition: all 0.3s ease;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.navbar.scrolled {
    background-color: rgba(255, 255, 255, 0.98);
    box-shadow: 0 1px 10px rgba(0, 0, 0, 0.05);
}

.navbar-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
}

.nav-links {
    display: none;
}

@media (min-width: 768px) {
    .nav-links {
        display: flex;
        gap: 24px;
    }

    .nav-links a {
        text-decoration: none;
        color: var(--text-secondary);
        font-weight: 500;
    }
}

.cart-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    /* Minimum touch target */
    height: 44px;
    border-radius: 50%;
    color: var(--accent);
}

.cart-count {
    position: absolute;
    top: 6px;
    right: 6px;
    background-color: var(--accent);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

/* Hero */
.hero {
    padding: calc(var(--header-height) + var(--spacing-lg) + var(--saT)) 20px 60px;
    background: radial-gradient(circle at 50% 0%, #fff, #f4f4f4);
    text-align: center;
}

.flash-sale-top {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: #000;
    color: white;
    padding: 8px 16px;
    font-size: 0.8rem;
    font-weight: 700;
    border-radius: 50px;
    margin-bottom: 24px;
}

.hero-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.hero-title {
    font-size: 2.8rem;
    /* Responsive sizing needed */
    line-height: 1.1;
    color: var(--text-primary);
    max-width: 100%;
}

@media (max-width: 400px) {
    .hero-title {
        font-size: 2.2rem;
    }
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 400px;
    line-height: 1.5;
}

.hero-cta {
    background-color: var(--accent);
    color: white;
    padding: 16px 40px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 1.1rem;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
    min-height: 54px;
    /* Touch target */
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 300px;
}

/* Video Section */
.video-section {
    padding: 0 16px;
    margin-top: -30px;
    position: relative;
    z-index: 1;
}

.video-container {
    width: 100%;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    aspect-ratio: 16/9;
    box-shadow: var(--shadow-md);
    background: black;
}

.video-bg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.8;
}

.play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Category Bar */
.category-bar {
    padding: 30px 0 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    scrollbar-width: none;
    /* Hide scrollbar */
    padding-left: 16px;
    /* Start padding */
}

.category-bar::-webkit-scrollbar {
    display: none;
}

.pills-container {
    display: inline-flex;
    gap: 10px;
    padding-right: 16px;
    /* End padding */
}

.category-pill {
    padding: 10px 20px;
    border-radius: 50px;
    background-color: #f5f5f5;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.category-pill.active {
    background-color: black;
    color: white;
}

/* Product Section */
.product-section {
    padding: 10px 16px 40px;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    /* Mobile default */
    gap: 12px;
}

@media (min-width: 768px) {
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 24px;
    }
}

@media (min-width: 1024px) {
    .product-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Product Card */
.product-card {
    background-color: white;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    border: 1px solid #f0f0f0;
}

.product-img-wrap {
    width: 100%;
    aspect-ratio: 1/1;
    /* Square for mobile consistency */
    background-color: #f8f8f8;
    overflow: hidden;
    position: relative;
}

.product-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-discount {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: white;
    color: black;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.product-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.product-name {
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-price-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
}

.product-price {
    font-weight: 700;
    font-size: 1rem;
    color: var(--accent);
}

.quick-add {
    width: 32px;
    height: 32px;
    background-color: black;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

/* Newsletter */
.newsletter-section {
    background-color: #f9f9f9;
    padding: 60px 20px;
    text-align: center;
    margin-top: 40px;
}

.newsletter-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
}

.newsletter-form input {
    padding: 14px 20px;
    border-radius: 50px;
    border: 1px solid #ddd;
    font-size: 1rem;
    width: 100%;
}

.newsletter-form button {
    background: black;
    color: white;
    padding: 14px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 1rem;
}

/* Footer */
footer {
    padding: 60px 20px calc(60px + var(--saB));
    /* Extra padding for bottom */
    text-align: center;
    background: #fff;
    border-top: 1px solid #eee;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

/* Cart Drawer - Full width on Mobile */
.cart-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 3000;
    display: none;
    justify-content: flex-end;
    opacity: 0;
    transition: opacity 0.3s;
}

.cart-overlay.open {
    display: flex;
    opacity: 1;
}

.cart-drawer {
    width: 100%;
    max-width: 100%;
    /* Full width mobile */
    background-color: white;
    height: 100%;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease-out;
}

@media (min-width: 480px) {
    .cart-drawer {
        max-width: 400px;
    }
}

.cart-overlay.open .cart-drawer {
    transform: translateX(0);
}

.cart-header {
    padding: 16px 20px;
    padding-top: max(16px, var(--saT));
    /* Safe area top */
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
}

.cart-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.cart-footer {
    padding: 20px;
    padding-bottom: max(20px, var(--saB));
    /* Safe area bottom */
    border-top: 1px solid #eee;
    background: white;
}

/* Modal - Responsive */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: none;
    align-items: flex-end;
    /* Bottom sheet on mobile */
    justify-content: center;
}

@media (min-width: 600px) {
    .modal-overlay {
        align-items: center;
    }
}

.modal-overlay.open {
    display: flex;
}

.modal-panel {
    background: white;
    width: 100%;
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
    padding: 24px 20px calc(24px + var(--saB));
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

@media (min-width: 600px) {
    .modal-panel {
        width: 90%;
        max-width: 900px;
        border-radius: 20px;
        max-height: 85vh;
        display: grid;
        grid-template-columns: 1fr 1fr;
        padding: 40px;
        animation: fadeIn 0.3s;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.close-panel {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    background: #f0f0f0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    z-index: 10;
}