/* Custom animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

/* Mobile optimizations */
body {
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
}

/* Sticky container */
#sticky-container {
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 1000;
    will-change: transform;
}

#header-wrapper {
    width: 100%;
}

/* Logo height and transition */
#main-logo {
    height: 8rem; /* 128px mobile */
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 100%;
    object-fit: contain;
}

@media (min-width: 768px) {
    #main-logo {
        height: 12rem; /* 192px desktop */
    }
}

/* Compact state */
.compact {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.compact #main-logo {
    transform: scale(0.75);
    transform-origin: center;
}

.compact nav {
    margin-bottom: 0.25rem;
}

/* Transition for header */
#main-header {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Enhanced mobile menu (header-offset aware) */
:root {
    --header-offset: 113px;
}

#mobile-menu {
    display: none !important;
    opacity: 0;
    transition: opacity 0.2s ease;
    max-height: calc(100dvh - var(--header-offset));
    overflow-y: auto;
    top: var(--header-offset);
    z-index: 10003 !important;
    position: fixed !important;
    left: 0;
    right: 0;
    pointer-events: auto;
}

#mobile-menu.active {
    display: block !important;
    opacity: 1;
}

#mobile-menu-overlay {
    z-index: 10002 !important;
    background: rgba(0, 0, 0, 0.25);
}

/* Overlay should never block clicks on the menu (menu z-index is higher) */
#mobile-menu-overlay.hidden {
    pointer-events: none;
}

#mobile-menu-overlay:not(.hidden) {
    pointer-events: auto;
}

/* Lock body scroll when mobile menu is open */
body.mobile-menu-open {
    overflow: hidden;
}

/* Ensure mobile menu is hidden when cart is open */
body.cart-open #mobile-menu,
body.cart-open #mobile-menu-overlay {
    display: none !important;
}

/* Enforce desktop navigation */
@media (min-width: 768px) {
    #menu-toggle {
        display: none !important;
    }
    #mobile-menu {
        display: none !important;
    }
    /* Ensure desktop nav is visible */
    #main-header nav:first-of-type {
        display: flex !important;
    }
}

/* Site Preloader styles moved to assets/css/preloader.css */

/* AJAX Preloader Styles */
.ajax-preloader-content {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ajax-preloader-logo {
    width: 80px;
    height: auto;
    animation: preloaderPulse 1.5s ease-in-out infinite;
}

/* Z-index management for important elements */
#announcement-bar {
    z-index: 999 !important;
}

#main-header {
    z-index: 1000 !important;
    background-color: white !important;
    will-change: transform;
}

/* Cookie consent must be above chat/cart and not be hidden behind other stacking contexts */
#cookie-consent {
    z-index: 999999 !important;
}

#mobile-menu {
    z-index: 10003 !important;
}

/* Fix for z-index stacking context issues */
#main-header, #sticky-container {
    isolation: isolate;
}

/* Frontend confirmation modal - must appear above everything */
#frontend-confirm-overlay {
    z-index: 10005 !important;
}

#frontend-confirm-overlay > div {
    z-index: 10006 !important;
    position: relative;
}

/* Ensure modal appears above header when open */
body #frontend-confirm-overlay {
    z-index: 10005 !important;
}

/* Alternative approach: Use JavaScript to manage header z-index */
.header-modal-open #main-header,
.header-modal-open #sticky-container,
.header-modal-open #announcement-bar {
    z-index: 998 !important;
}

/* Additional fallback: Ensure modal is always on top */
#frontend-confirm-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 10005 !important;
}

/* Ensure modal content is always visible */
#frontend-confirm-overlay > div {
    z-index: 10006 !important;
    position: relative !important;
    margin-top: 80px !important; /* Space for header */
}

/* Mobile specific adjustments */
@media (max-width: 767px) {
    #frontend-confirm-overlay > div {
        margin-top: 60px !important;
    }
}

/* Ensure modal is not affected by other stacking contexts */
#frontend-confirm-overlay {
    isolation: isolate !important;
}

/* Cart overlay must be above everything including header */
#cart-overlay {
    z-index: 10001 !important;
}

/* Cart sidebar must be above all other elements including header */
#sidebar-cart {
    z-index: 10002 !important;
}

/* Site preloader should be below cart but above other content */
#site-preloader {
    z-index: 9997 !important;
}

/* Ensure content is properly layered */
.main-content-area {
    position: relative;
    z-index: 10 !important;
}

/* Fix header wrapper stacking context - remove z-index to prevent interference */
#header-wrapper {
    position: relative;
    z-index: auto !important;
}

/* Slide-in Cart Panel Styles */
#sidebar-cart {
    width: 100%;
    max-width: 100%;
    transition: transform 0.3s ease-in-out;
}

@media (min-width: 768px) {
    #sidebar-cart {
        width: 450px;
        max-width: 450px;
    }
}

/* Cart overlay styles */
#cart-overlay {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    position: fixed;
    inset: 0;
    z-index: 10001 !important;
}

#cart-overlay:not(.hidden) {
    opacity: 1;
}

/* Prevent body scroll when cart is open */
body.cart-open {
    overflow: hidden;
}

/* Smooth slide-in animation */
@keyframes slideIn {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(100%);
    }
}

/* Apply animations - only when cart is open */
#sidebar-cart:not(.translate-x-full) {
    animation: slideIn 0.3s ease-in-out;
}

#sidebar-cart.translate-x-full {
    animation: slideOut 0.3s ease-in-out;
}

/* Fix for transform conflicts - ensure transform is applied correctly */
#sidebar-cart {
    transform: translateX(100%);
}

#sidebar-cart:not(.translate-x-full) {
    transform: translateX(0);
}

/* Ensure animation doesn't conflict with transform */
#sidebar-cart:not(.translate-x-full) {
    animation: slideIn 0.3s ease-in-out;
    transform: translateX(0);
}

#sidebar-cart.translate-x-full {
    animation: slideOut 0.3s ease-in-out;
    transform: translateX(100%);
}

/* Ensure cart sidebar is positioned correctly */
#sidebar-cart {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    height: 100% !important;
    width: 100%;
    max-width: 100%;
    box-shadow: -10px 0 25px -5px rgba(0, 0, 0, 0.1);
}

/* Desktop width */
@media (min-width: 768px) {
    #sidebar-cart {
        width: 450px;
        max-width: 450px;
    }
}

/* Mobile fullscreen overlay */
@media (max-width: 767px) {
    #sidebar-cart {
        width: 100% !important;
        max-width: 100% !important;
        left: 0 !important;
        border-radius: 0 !important;
    }
}

/* Ensure mobile menu doesn't conflict with cart */
/* Note: cart-open hides the menu entirely, so we keep menu z-index consistent (10003). */

/* Prevent body scroll when cart is open */
body.cart-open {
    overflow: hidden;
    position: relative;
}

/* Fix for container stacking */
.main-content-area {
    position: relative;
    z-index: 10;
}

/* Ensure cart overlay covers everything */
#cart-overlay:not(.hidden) {
    position: fixed;
    inset: 0;
    z-index: 10001 !important;
}

/* Cart item styling */
#cart-items {
    scrollbar-width: thin;
    scrollbar-color: #d1d5db #f3f4f6;
}

#cart-items::-webkit-scrollbar {
    width: 8px;
}

#cart-items::-webkit-scrollbar-track {
    background: #f3f4f6;
}
#cart-items::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 4px;
}

/* Ensure cart content is visible and not clipped by header */
#sidebar-cart .flex.flex-col.h-full {
    padding-top: 0;
}

#sidebar-cart .flex.justify-between.items-center.p-6.border-b.border-gray-200 {
    padding-top: 24px;
}

/* Add safe area at top of cart content */
#sidebar-cart:not(.translate-x-full) #cart-items {
    padding-top: 10px !important;
}

/* Ensure cart header is always visible and properly positioned */
#sidebar-cart .flex.justify-between.items-center.p-6.border-b.border-gray-200 {
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

/* Ensure cart items container has proper height and scrolling */
#cart-items {
    min-height: calc(100vh - 200px);
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

/* Ensure cart footer is always visible at bottom */
#sidebar-cart .p-6.border-t.border-gray-200 {
    position: sticky;
    bottom: 0;
    background: white;
    z-index: 10;
}

/* Fix for mobile - ensure cart takes full viewport height */
@media (max-width: 767px) {
    #sidebar-cart {
        height: 100vh !important;
        height: 100dvh !important; /* For modern browsers */
    }
    
    #cart-items {
        min-height: calc(100vh - 250px);
        max-height: calc(100vh - 250px);
    }
}

/* Ensure cart overlay doesn't interfere with header */
#cart-overlay:not(.hidden) {
    pointer-events: auto;
}

/* Fix for header z-index when cart is open */
body.cart-open #main-header {
    z-index: 999 !important;
}

/* Ensure mobile menu doesn't show when cart is open */
body.cart-open #mobile-menu {
    display: none !important;
    z-index: 10003 !important;
}

/* Fix for sticky header when cart is open */
body.cart-open #sticky-container {
    z-index: 999 !important;
}

/* Ensure cart overlay is above header when cart is open */
body.cart-open #cart-overlay {
    z-index: 10001 !important;
}

/* Ensure cart sidebar is above header when cart is open */
body.cart-open #sidebar-cart {
    z-index: 10002 !important;
}

/* Fix for mobile menu z-index when cart is open */
body.cart-open #mobile-menu {
    z-index: 10001 !important;
}

/* Ensure announcement bar doesn't interfere with cart */
body.cart-open #announcement-bar {
    z-index: 999 !important;
}

/* Fix for sticky container when cart is open */
body.cart-open #sticky-container {
    z-index: 999 !important;
}

/* Ensure cart sidebar doesn't have any transform conflicts */
#sidebar-cart {
    transform: translateX(100%);
}

#sidebar-cart:not(.translate-x-full) {
    transform: translateX(0);
}

/* Fix for mobile - ensure cart sidebar is above everything */
@media (max-width: 767px) {
    #sidebar-cart {
        z-index: 10002 !important;
    }
    
    #cart-overlay {
        z-index: 10001 !important;
    }
    
    body.cart-open #main-header {
        z-index: 999 !important;
    }
}

/* Ensure cart sidebar doesn't interfere with touch events */
#sidebar-cart {
    touch-action: pan-y;
}

/* Fix for iOS Safari - ensure proper viewport height */
@supports (-webkit-touch-callout: none) {
    #sidebar-cart {
        height: -webkit-fill-available !important;
    }
}

/* Ensure cart overlay doesn't block interactions when hidden */
#cart-overlay.hidden {
    pointer-events: none !important;
}

/* Wishlist count badge styling */
.wishlist-count {
    display: none;
    min-width: 16px;
    min-height: 16px;
    text-align: center;
    font-size: 10px;
    line-height: 1;
    padding: 2px 4px;
}

.wishlist-count.show {
    display: inline-block;
}

#wishlist-count-desktop {
    top: -8px;
    right: -8px;
}

#wishlist-count-mobile {
    top: -4px;
    right: -4px;
}

/* Wishlist notification styles */
.wishlist-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    padding: 12px 20px;
    border-radius: 0;
    border: 1px solid #000;
    background-color: #fff;
    color: #000;
    font-size: 14px;
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.08);
    transform: translateY(-20px);
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.wishlist-notification.show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.wishlist-notification.success {
    background-color: #fff;
}

.wishlist-notification.error {
    background-color: #fff;
}

.wishlist-notification.info {
    background-color: #fff;
}

/* Wishlist button states */
.wishlist-btn {
    transition: all 0.2s ease;
}

/* (Reverted) Luxury listing styles removed; layout uses original product grid styling */

.wishlist-btn.added {
    background-color: #ef4444;
}

.wishlist-btn.added i {
    color: white;
}

.wishlist-btn.added i:before {
    content: "\f004" !important; /* Solid heart icon */
}

.wishlist-btn.loading {
    opacity: 0.7;
    cursor: wait;
}

/* Fix for cart content clipping */
#sidebar-cart .flex.flex-col.h-full {
    overflow: hidden !important;
}

/* Ensure cart sidebar doesn't have any overflow issues */
#sidebar-cart {
    overflow: hidden !important;
}

/* Ensure cart items container has proper overflow handling */
#cart-items {
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

/* ------------------------------------------------------------------
   Luxury Micro-Interactions (subtle, premium motion)
   ------------------------------------------------------------------ */

:root {
    --luxury-ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
    --luxury-glow-color: rgba(0, 0, 0, 0.18);
    --luxury-glow-shadow: 0 0 0 1px rgba(0, 0, 0, 0.14), 0 12px 28px rgba(0, 0, 0, 0.08);
}

/* Hidden fullscreen overlays must never intercept storefront interactions */
#quick-view-modal.hidden,
#quick-add-modal.hidden,
#cart-overlay.hidden,
#mobile-menu-overlay.hidden,
#frontend-confirm-overlay.hidden,
#site-preloader.hide {
    display: none !important;
    pointer-events: none !important;
}

/* While quick add is open, decorative parallax layers must never capture taps. */
body.ml-quick-add-open .luxury-parallax-surface {
    pointer-events: none !important;
}

/* Ensure quick-add color choices render as true color blocks with visible selection. */
#quick-add-color-container .quick-add-color-btn {
    min-width: 3.1rem;
    min-height: 2.2rem;
    border-width: 1px !important;
}

#quick-add-color-container .quick-add-color-btn.is-selected {
    box-shadow: 0 0 0 2px #111111 inset, 0 0 0 1px #111111 !important;
}

#quick-add-color-container .quick-add-color-btn:disabled {
    opacity: 0.48 !important;
}

/* Keep card swatches visible even when theme layers are aggressive. */
.ml-product-swatch {
    background: var(--ml-swatch-color, #d5d5d5) !important;
}

@media (hover: none), (pointer: coarse) {
    .ml-product-card-add {
        opacity: 1 !important;
        pointer-events: auto !important;
        transform: scale(1) !important;
    }
}

body.luxury-motion-ready .fade-in-up {
    animation: none !important;
    opacity: 0;
    transform: translate3d(0, 18px, 0);
    transition: opacity 760ms var(--luxury-ease-out), transform 760ms var(--luxury-ease-out);
    will-change: opacity, transform;
}

body.luxury-motion-ready .fade-in-up.luxury-in-view {
    opacity: 1;
    transform: translate3d(0, 0, 0);
}

.luxury-hover-button {
    position: relative;
    transition: box-shadow 320ms ease, transform 320ms ease, border-color 320ms ease, background-color 320ms ease, color 320ms ease, filter 320ms ease;
}

.luxury-hover-button::after {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    pointer-events: none;
    display: none !important;
    opacity: 0;
    box-shadow: var(--luxury-glow-shadow);
    transition: opacity 320ms ease;
}

@media (hover: hover) and (pointer: fine) {
    .luxury-hover-button:hover,
    .luxury-hover-button:focus-visible {
        transform: translateY(-1px);
        filter: saturate(1.02);
    }

    .luxury-hover-button:hover::after,
    .luxury-hover-button:focus-visible::after {
        opacity: 1;
    }
}

.luxury-zoom-target {
    transform: translateZ(0) scale(1);
    transform-origin: 50% 50%;
    transition: transform 980ms cubic-bezier(0.16, 0.84, 0.24, 1), opacity 420ms ease, filter 620ms ease;
    will-change: transform, filter;
    filter: saturate(1);
}

@media (hover: hover) and (pointer: fine) {
    .group:hover .luxury-zoom-target,
    .product-item:hover .luxury-zoom-target,
    .luxury-zoom-host:hover .luxury-zoom-target {
        transform: translateZ(0) scale(1.04);
        filter: saturate(1.03);
    }
}

.luxury-parallax-surface {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    --luxury-parallax-shift: 0px;
}

.luxury-parallax-surface::before {
    content: "";
    position: absolute;
    inset: -12% -16% auto -16%;
    height: 72%;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(120% 110% at 12% 0%, rgba(255, 255, 255, 0.98) 0%, rgba(248, 246, 241, 0.72) 42%, rgba(255, 255, 255, 0) 78%),
        radial-gradient(95% 85% at 92% 12%, rgba(236, 231, 223, 0.42) 0%, rgba(255, 255, 255, 0) 74%);
    transform: translate3d(0, var(--luxury-parallax-shift), 0);
    transition: transform 180ms linear;
}

.luxury-parallax-surface[data-luxury-parallax-hero="1"]::before {
    inset: -18% -20% auto -20%;
    height: 84%;
    background:
        radial-gradient(125% 120% at 14% 0%, rgba(255, 255, 255, 0.92) 0%, rgba(247, 241, 231, 0.64) 40%, rgba(255, 255, 255, 0) 80%),
        radial-gradient(95% 95% at 92% 10%, rgba(224, 210, 186, 0.24) 0%, rgba(255, 255, 255, 0) 76%);
}

.luxury-parallax-surface > * {
    position: relative;
    z-index: 1;
}

@media (prefers-reduced-motion: reduce) {
    body.luxury-motion-ready .fade-in-up {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .luxury-hover-button,
    .luxury-zoom-target,
    .luxury-parallax-surface::before {
        transition: none;
    }
}
