/* ================================================
   LuxuryMart v3 - Mobile First Stylesheet
   Speed Demon + High CPC + Enterprise Ready
   ================================================ */

/* ================================================
   CLS PREVENTION - Core Web Vitals (Complete Fix)
   ================================================ */

/* Reserve space for dynamic content */
.ad-container {
    min-height: 90px;
    background: #f9fafb;
    overflow: hidden;
}

/* Product grid skeleton loading */
.product-card {
    contain: layout style;
}

.product-card__image {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Prevent hero section reflow */
.hero-section,
[class*="py-16"],
[class*="py-24"] {
    min-height: 200px;
}

/* Reserve space for Alpine.js conditional content */
[x-cloak] {
    display: none !important;
}

[x-show] {
    min-height: 0;
}

/* Image placeholder before load */
img {
    background-color: #f3f4f6;
}

/* Prevent h1/headings from reflowing */
h1 {
    min-height: 2.5rem;
}

h2 {
    min-height: 2rem;
}

/* Ad container visible placeholder */
.ad-container:empty::before {
    content: "";
    display: block;
    min-height: inherit;
}

/* ================================================
   CHECKOUT & FORMS CLS FIX
   ================================================ */

/* Fixed height for navigation */
nav {
    min-height: 64px;
}

/* Checkout progress steps - prevent reflow */
.checkout-steps,
.flex.items-center.justify-center {
    min-height: 60px;
}

/* Form inputs - fixed heights */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="password"],
textarea,
select {
    min-height: 48px;
    box-sizing: border-box;
}

/* Buttons - fixed height */
button,
.btn,
[type="submit"] {
    min-height: 44px;
}

/* Checkout form container */
.checkout-form,
form {
    contain: layout;
}

/* Label heights */
label {
    min-height: 24px;
    display: inline-block;
}

/* Error messages space reservation */
.error-message,
.text-red-500,
.text-red-600 {
    min-height: 0;
}

/* Cart summary container */
.cart-summary,
.order-summary {
    min-height: 200px;
}

/* Breadcrumb */
nav.bg-white.border-b {
    min-height: 48px;
}

/* Mobile sticky cart */
.sticky-cart {
    min-height: 72px;
}

/* Trust badges */
.trust-badge {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
}

/* Page main content */
main {
    min-height: calc(100vh - 200px);
}

/* Checkout step cards */
.checkout-card,
.bg-white.rounded-xl,
.bg-white.rounded-2xl {
    contain: layout;
}

/* Prevent price from reflowing */
.price,
.text-green-600.font-bold,
.text-xl.font-bold,
.text-2xl.font-bold,
.text-3xl.font-bold {
    min-height: 1.5em;
}

/* Footer */
footer {
    min-height: 200px;
}

/* Discover more section */
.discover-more,
.flex.flex-wrap.gap-2 {
    min-height: 80px;
}

/* Search bar expansion */
.search-open,
div[x-show="searchOpen"] {
    min-height: 60px;
}

/* Mobile menu */
div[x-show="mobileMenu"] {
    min-height: 200px;
}

/* ================================================
   END CLS PREVENTION
   ================================================ */

/* Base Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* CSS Variables */
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --secondary: #f59e0b;
    --secondary-dark: #d97706;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --dark: #1e293b;
    --light: #f8fafc;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 6px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.2);

    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    --transition: all 0.2s ease;
}

/* Body */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--gray-800);
    background: var(--gray-50);
    min-height: 100vh;
}

/* ================================================
   TOUCH TARGETS - 48x48px minimum (Google CWV)
   ================================================ */
button,
.btn,
a.btn,
input[type="submit"],
input[type="button"] {
    min-height: 48px;
    min-width: 48px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

/* Button Press Effect */
button:active,
.btn:active {
    transform: scale(0.95);
}

/* Primary Button */
.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

/* Secondary Button */
.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: var(--secondary-dark);
}

/* Outline Button */
.btn-outline {
    background: transparent;
    border: 2px solid var(--gray-800);
    color: var(--gray-800);
}

.btn-outline:hover {
    background: var(--gray-800);
    color: white;
}

/* ================================================
   CLS-SAFE AD CONTAINERS (Prevent Layout Shift)
   ================================================ */
.ad-slot {
    min-height: 250px;
    background: linear-gradient(135deg, var(--gray-100) 0%, var(--gray-200) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
}

.ad-slot::before {
    content: "Advertisement";
    color: var(--gray-400);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ad-slot--loaded::before {
    display: none;
}

.ad-slot--small {
    min-height: 90px;
}

.ad-slot--medium {
    min-height: 250px;
}

.ad-slot--large {
    min-height: 600px;
}

.ad-slot--sticky {
    min-height: 50px;
}

/* ================================================
   STICKY MOBILE CART (Amazon Style)
   ================================================ */
.sticky-cart {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    z-index: 100;
    display: none;
    border-top: 1px solid var(--gray-200);
}

@media (max-width: 768px) {
    .sticky-cart {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .desktop-cart-btn {
        display: none !important;
    }
}

/* ================================================
   PRODUCT CARD
   ================================================ */
.product-card {
    background: white;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.product-card__image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.product-card__body {
    padding: 16px;
}

.product-card__brand {
    font-size: 12px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.product-card__title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 8px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card__price {
    font-size: 20px;
    font-weight: 700;
    color: var(--success);
}

.product-card__compare {
    font-size: 14px;
    color: var(--gray-500);
    text-decoration: line-through;
    margin-left: 8px;
}

.product-card__discount {
    display: inline-block;
    background: var(--danger);
    color: white;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    margin-left: 8px;
}

/* ================================================
   TRUST BADGES
   ================================================ */
.trust-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f0fdf4;
    color: #166534;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
}

.trust-badge--warning {
    background: #fffbeb;
    color: #92400e;
}

.trust-badge--info {
    background: #eff6ff;
    color: #1e40af;
}

/* ================================================
   ENTERPRISE SECTION (High CPC)
   ================================================ */
.enterprise-section {
    background: linear-gradient(135deg, var(--gray-900) 0%, #0f172a 100%);
    color: white;
    padding: 64px 0;
}

.enterprise-card {
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    transition: background 0.3s ease;
}

.enterprise-card:hover {
    background: rgba(255, 255, 255, 0.05);
}

.enterprise-card__icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.enterprise-card__title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.enterprise-card__text {
    font-size: 14px;
    color: var(--gray-400);
    line-height: 1.6;
}

.enterprise-card__badge {
    display: inline-block;
    margin-top: 12px;
    font-size: 11px;
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
    padding: 4px 10px;
    border-radius: var(--radius-full);
}

/* ================================================
   LAZY LOADING
   ================================================ */
.lazy {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lazy.loaded {
    opacity: 1;
}

/* ================================================
   LOADING SPINNER
   ================================================ */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* HTMX Loading States */
.htmx-request .spinner {
    display: inline-block;
}

.htmx-request .btn-text {
    display: none;
}

/* ================================================
   FORMS
   ================================================ */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    transition: var(--transition);
    background: white;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

/* ================================================
   CONTAINERS
   ================================================ */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 16px;
}

@media (min-width: 768px) {
    .container {
        padding: 0 24px;
    }
}

/* ================================================
   GRID
   ================================================ */
.grid {
    display: grid;
    gap: 24px;
}

.grid-cols-1 {
    grid-template-columns: repeat(1, 1fr);
}

@media (min-width: 640px) {
    .sm\:grid-cols-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .md\:grid-cols-2 {
        grid-template-columns: repeat(2, 1fr);
    }

    .md\:grid-cols-3 {
        grid-template-columns: repeat(3, 1fr);
    }

    .md\:grid-cols-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-3 {
        grid-template-columns: repeat(3, 1fr);
    }

    .lg\:grid-cols-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ================================================
   UTILITIES
   ================================================ */
.text-center {
    text-align: center;
}

.font-bold {
    font-weight: 700;
}

.hidden {
    display: none;
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 8px;
}

.gap-4 {
    gap: 16px;
}

.mt-4 {
    margin-top: 16px;
}

.mt-8 {
    margin-top: 32px;
}

.mb-4 {
    margin-bottom: 16px;
}

.mb-8 {
    margin-bottom: 32px;
}

.py-4 {
    padding-top: 16px;
    padding-bottom: 16px;
}

.py-8 {
    padding-top: 32px;
    padding-bottom: 32px;
}

.px-4 {
    padding-left: 16px;
    padding-right: 16px;
}

/* ================================================
   TOAST NOTIFICATION
   ================================================ */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-900);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}