:root {
    --font-main: 'Urbanist', 'Cairo', sans-serif;
    --header-height: 100px;
    
    --font-size-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
    --font-size-sm: clamp(0.875rem, 0.8rem + 0.375vw, 1rem);
    --font-size-base: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);
    --font-size-lg: clamp(1.125rem, 1rem + 0.625vw, 1.25rem);
    --font-size-xl: clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem);

    --primary-color: #206E7A;
    --surface-color: #1C1C23;
    --bg-color: #0B0B0F;
    --text-color: #F5F5F7;
    --text-color-high-contrast: #FFFFFF;
    --text-muted: #8A8A8E;
    --text-muted-high-contrast: #B0B0B5;
    --pill-bg-color: #2c2c34;
    --border-color: rgba(255, 255, 255, 0.1);
    --cart-btn-icon: #FFFFFF;
    --header-icon-bg: rgba(255, 255, 255, 0.05);

    --gradient-primary: linear-gradient(135deg, var(--primary-color) 0%, color-mix(in srgb, var(--primary-color) 80%, white) 100%);
    --gradient-surface: linear-gradient(135deg, var(--surface-color) 0%, color-mix(in srgb, var(--surface-color) 97%, white) 100%);
    --glow-primary: 0 0 20px rgba(32, 110, 122, 0.3);
    --glow-primary-strong: 0 0 40px rgba(32, 110, 122, 0.5);
}

body.light-mode {
    --bg-color: #F4F4F6;
    --surface-color: #FFFFFF;
    --text-color: #1C1C23;
    --text-color-high-contrast: #000000;
    --primary-color: #206E7A;
    --text-muted: #5A5A5E;
    --text-muted-high-contrast: #505055;
    --pill-bg-color: #e9e9ed;
    --border-color: rgba(0, 0, 0, 0.08);
    --cart-btn-icon: #FFFFFF;
    --header-icon-bg: #f0f0f0;
}

body {
    background: radial-gradient(ellipse at top,
        color-mix(in srgb, var(--bg-color) 95%, var(--primary-color)) 0%,
        var(--bg-color) 50%
    );
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

#page-wrapper {
    padding-top: calc(var(--header-height) + env(safe-area-inset-top));
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: var(--header-height);
}

/* =================================================================
   [2] ACCESSIBILITY - FOCUS STATES
   ================================================================= */
*:focus-visible { 
    outline: 2px solid var(--primary-color); 
    outline-offset: 3px; 
    border-radius: 4px; 
}

*:focus:not(:focus-visible) {
    outline: none;
}

.quick-add-btn:focus-visible,
.header-icon-btn:focus-visible,
.pill-button:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: 
        0 0 0 4px rgba(32, 110, 122, 0.2),
        0 10px 30px rgba(0, 0, 0, 0.3);
}

.subcat-tab:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 4px;
    background-color: rgba(32, 110, 122, 0.1);
}

/* =================================================================
   [3] COMPONENT: FLOATING ACTION BAR (ENHANCED)
   ================================================================= */
.floating-action-bar { 
    position: fixed; 
    bottom: calc(1rem + env(safe-area-inset-bottom));
    left: 50%; 
    transform: translateX(-50%); 
    z-index: 800; 
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease; 
}

.floating-action-bar.is-hidden { 
    transform: translate(-50%, 150%); 
    opacity: 0; 
}

.pill-container { 
    display: flex; 
    align-items: center; 
    gap: 0.5rem; 
    padding: 0.5rem; 
    background: linear-gradient(135deg,
        var(--pill-bg-color) 0%,
        color-mix(in srgb, var(--pill-bg-color) 95%, white) 100%
    );
    border-radius: 999px; 
    border: 1px solid var(--border-color); 
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.05),
        0 0 30px rgba(32, 110, 122, 0.1);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pill-container:hover {
    transform: scale(1.05);
    box-shadow: 
        0 15px 50px rgba(0, 0, 0, 0.4),
        0 0 40px rgba(32, 110, 122, 0.2);
}

.pill-button { 
    min-width: 44px;
    min-height: 44px;
    width: 48px; 
    height: 48px; 
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 1.125rem; 
    color: var(--text-muted); 
    background-color: transparent; 
    border: none; 
    cursor: pointer; 
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.pill-button::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, 
        var(--primary-color) 0%, 
        transparent 70%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
}

.pill-button:hover::before {
    opacity: 0.15;
}

.pill-button:hover { 
    color: var(--text-color);
    transform: scale(1.1);
}

.pill-button:active {
    transform: scale(0.95);
}

.pill-button.active { 
    background: linear-gradient(135deg, 
        var(--primary-color) 0%, 
        color-mix(in srgb, var(--primary-color) 85%, white) 100%
    );
    color: var(--cart-btn-icon);
    transform: scale(1.15);
    box-shadow: 
        0 5px 15px rgba(0,0,0,0.2),
        0 0 20px rgba(32, 110, 122, 0.3);
}

.cart-counter-badge { 
    position: absolute; 
    top: 6px; 
    right: 6px; 
    min-width: 18px; 
    height: 18px; 
    border-radius: 50%; 
    background-color: var(--primary-color); 
    color: var(--cart-btn-icon); 
    font-size: 0.7rem; 
    font-weight: 700; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    padding: 2px;
    animation: badgePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
               badgePulse 2s ease-in-out 0.4s infinite;
}

@keyframes badgePulse {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(32, 110, 122, 0.7);
    }
    50% { 
        box-shadow: 0 0 0 4px rgba(32, 110, 122, 0);
    }
}

.hamburger-icon { 
    display: flex; 
    flex-direction: column; 
    gap: 5px; 
}

.hamburger-icon span { 
    width: 22px; 
    height: 2px; 
    background-color: currentColor; 
    border-radius: 2px; 
    transition: transform 0.3s ease, opacity 0.3s ease; 
}

body.nav-open .hamburger-icon span:nth-child(1) { 
    transform: translateY(7px) rotate(45deg); 
}

body.nav-open .hamburger-icon span:nth-child(2) { 
    opacity: 0; 
}

body.nav-open .hamburger-icon span:nth-child(3) { 
    transform: translateY(-7px) rotate(-45deg); 
}

/* =================================================================
   [4] COMPONENT: SIDE NAVIGATION
   ================================================================= */
body.nav-open { 
    overflow: hidden; 
}

.nav-overlay { 
    position: fixed; 
    inset: 0; 
    background-color: rgba(0, 0, 0, 0.7); 
    backdrop-filter: blur(16px); 
    -webkit-backdrop-filter: blur(16px); 
    z-index: 900; 
    opacity: 0; 
    visibility: hidden; 
    transition: opacity 0.5s ease, visibility 0.5s ease; 
}

.side-nav { 
    position: fixed; 
    top: 0; 
    bottom: 0; 
    left: 0; 
    width: 320px; 
    max-width: 90vw; 
    z-index: 950; 
    display: flex; 
    flex-direction: column; 
    justify-content: center; 
    background: none; 
    box-shadow: none; 
    border: none; 
    pointer-events: none; 
    transform: translateX(-100%); 
    transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1); 
}

.side-nav > * { 
    pointer-events: auto; 
}

body.nav-open .nav-overlay { 
    opacity: 1; 
    visibility: visible; 
}

body.nav-open .side-nav { 
    transform: translateX(0); 
}

.nav-content { 
    padding: 0 1rem; 
    overflow: visible; 
    width: 100%; 
}

.nav-list { 
    list-style: none; 
    padding: 0; 
    margin: 0; 
    display: flex; 
    flex-direction: column; 
    gap: 0.75rem; 
}

.nav-list-item { 
    position: relative; 
    border-radius: 1rem; 
    background-color: rgba(45, 45, 55, 0.5); 
    backdrop-filter: blur(20px) saturate(1.8); 
    -webkit-backdrop-filter: blur(20px) saturate(1.8); 
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); 
    border: 1px solid rgba(255, 255, 255, 0.1); 
    overflow: hidden; 
}

.nav-list-item::before { 
    content: ''; 
    position: absolute; 
    inset: 0; 
    border-radius: inherit; 
    box-shadow: inset 0 0 40px color-mix(in srgb, var(--primary-color) 20%, transparent); 
    opacity: 0; 
    transition: opacity 0.4s ease; 
    z-index: 1; 
}

.nav-list-item:hover::before, 
.nav-list-item.is-active::before { 
    opacity: 1; 
}

.nav-link { 
    display: flex; 
    align-items: center; 
    position: relative; 
    z-index: 2; 
    gap: 1rem; 
    height: 52px; 
    padding: 0 1.25rem; 
    border-radius: inherit; 
    text-decoration: none; 
    font-size: 1rem; 
    font-weight: 500; 
    outline: none; 
    color: #c0c0d0; 
    transition: color 0.3s ease, background-color 0.3s ease; 
}

.nav-link:hover, 
.nav-link:focus-visible { 
    color: #ffffff; 
}

.nav-list-item.is-active .nav-link { 
    color: #ffffff; 
    font-weight: 600; 
}

body.light-mode .nav-list-item { 
    background-color: rgba(255, 255, 255, 0.5); 
    border-color: rgba(0, 0, 0, 0.1); 
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1); 
}

body.light-mode .nav-link { 
    color: #3a3a4a; 
}

body.light-mode .nav-link:hover, 
body.light-mode .nav-link:focus-visible { 
    color: #000000; 
}

body.light-mode .nav-list-item.is-active .nav-link { 
    color: #000000; 
    font-weight: 600; 
}

.nav-list-item { 
    opacity: 0; 
    transform: translateX(-40px); 
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.7s cubic-bezier(0.16, 1, 0.3, 1); 
}

body.nav-open .nav-list-item { 
    opacity: 1; 
    transform: translateX(0); 
    transition-delay: calc(var(--item-index) * 80ms + 250ms); 
}

/* =================================================================
   [5] COMPONENT: UNIFIED & FIXED HEADER (GLASSMORPHISM)
   ================================================================= */
#unified-category-bar {
    position: fixed; 
    top: env(safe-area-inset-top);
    left: 0; 
    right: 0; 
    z-index: 40;
    
    background-color: rgba(11, 11, 15, 0.85);
    backdrop-filter: blur(12px); 
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    padding-top: env(safe-area-inset-top);
}

body.light-mode #unified-category-bar {
    background-color: rgba(244, 244, 246, 0.85);
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

#unified-category-bar.is-scrolled {
    background-color: rgba(28, 28, 35, 0.95);
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

body.light-mode #unified-category-bar.is-scrolled {
    background-color: rgba(255, 255, 255, 0.95);
}

#back-to-categories.is-hidden {
    opacity: 0; 
    pointer-events: none; 
    transform: scale(0.8);
}

.header-icon-btn, 
#category-hero-title {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.category-title-bar {
    display: flex; 
    align-items: center; 
    height: 56px; 
    padding: 0 0.75rem; 
    gap: 0.75rem;
}

#category-hero-title {
    position: static; 
    transform: none; 
    font-size: var(--font-size-base);
    font-weight: 600; 
    color: var(--text-color); 
    margin: 0; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis;
}

.header-actions {
    display: flex; 
    align-items: center; 
    gap: 0.5rem; 
    margin-left: auto;
}

.header-icon-btn {
    min-width: 44px;
    min-height: 44px;
    width: 36px; 
    height: 36px; 
    font-size: 0.9rem; 
    border-radius: 50%; 
    background-color: var(--header-icon-bg); 
    color: var(--text-color); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    border: none; 
    cursor: pointer; 
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.header-icon-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle, 
        var(--primary-color) 0%, 
        transparent 70%
    );
    transform: scale(0);
    transition: transform 0.4s ease-out;
}

.header-icon-btn:active::before {
    transform: scale(2);
    opacity: 0;
}

.header-icon-btn:active {
    transform: scale(0.9);
}

body.light-mode .header-icon-btn { 
    border: 1px solid var(--border-color); 
}

.header-icon-btn:hover { 
    background-color: var(--primary-color);
    color: var(--cart-btn-icon);
    transform: scale(1.15);
    box-shadow: 0 5px 15px rgba(32, 110, 122, 0.3);
}

/* Love/Favorite button active state */
.header-icon-btn.is-favorite {
    color: #ff4757;
}

.header-icon-btn.is-favorite i {
    animation: heartBeat 0.5s ease;
}

@keyframes heartBeat {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.3); }
    50% { transform: scale(1.1); }
    75% { transform: scale(1.2); }
}

body.light-mode .header-icon-btn:hover { 
    background-color: var(--primary-color);
    color: var(--cart-btn-icon);
}

/* =================================================================
   [5.1] TABS STYLING
   ================================================================= */
#sub-category-tabs-container {
    display: flex; 
    align-items: center; 
    padding: 0 1rem; 
    height: 44px; 
    border-top: 1px solid var(--border-color);
    position: relative;
}

.hamburger-btn {
    background: none; 
    border: none; 
    color: var(--text-color); 
    font-size: 1.25rem; 
    padding: 0; 
    margin-right: 1rem; 
    cursor: pointer;
}

#sub-category-swiper { 
    min-width: 0; 
    flex-grow: 1; 
}

/* ✅ اخفاء السكرول بار */
#sub-category-swiper::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

#sub-category-swiper {
    -ms-overflow-style: none;
    scrollbar-width: none; 
}

#sub-category-swiper .swiper-wrapper { 
    display: flex !important;
    align-items: center; 
}

#sub-category-swiper .swiper-slide { 
    width: auto !important;
}

/* ✅ ستايل التابات الجديد */
.subcat-tab {
    padding: 0.5rem 0.75rem;
    margin-right: 0.5rem;
    font-size: 0.95rem; 
    font-weight: 500; 
    color: var(--text-muted); 
    background: none; 
    border: none; 
    cursor: pointer; 
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    white-space: nowrap; 
    position: relative; 
    outline: none;
    opacity: 0.7;
    transform: scale(1);
    
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.subcat-tab::before,
.subcat-tab::after {
    display: none;
}

.subcat-tab:hover { 
    color: var(--text-color);
    opacity: 1;
}

.subcat-tab.active { 
    color: var(--primary-color) !important; 
    font-weight: 800;
    opacity: 1;
    transform: scale(1.1);
    text-shadow: 0 0 15px rgba(32, 110, 122, 0.25);
}

/* =================================================================
   [6] COMPONENT: BOTTOM DRAWER
   ================================================================= */
.drawer-overlay { 
    position: fixed; 
    inset: 0; 
    z-index: 1000; 
    background-color: rgba(0,0,0,0.5); 
    backdrop-filter: blur(4px); 
    opacity: 0; 
    visibility: hidden; 
    transition: opacity 0.3s ease, visibility 0.3s ease; 
}

.drawer-overlay.is-open { 
    opacity: 1; 
    visibility: visible; 
}

.bottom-drawer { 
    position: fixed; 
    bottom: 0; 
    left: 0; 
    right: 0; 
    z-index: 1010; 
    background: linear-gradient(to top,
        var(--surface-color) 0%,
        color-mix(in srgb, var(--surface-color) 98%, white) 100%
    );
    border-top-left-radius: 1.5rem; 
    border-top-right-radius: 1.5rem; 
    padding: 1rem; 
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    box-shadow: 
        0 -10px 40px rgba(0,0,0,0.3),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    transform: translateY(100%); 
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
}

.bottom-drawer::before {
    content: '';
    position: absolute;
    top: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background-color: var(--text-muted);
    border-radius: 2px;
    opacity: 0.3;
}

.bottom-drawer.is-open { 
    transform: translateY(0); 
}

.drawer-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding-bottom: 1rem; 
    margin-bottom: 1rem; 
    border-bottom: 1px solid var(--border-color); 
}

.drawer-title { 
    font-size: 1.25rem; 
    font-weight: 700; 
    color: var(--text-color); 
}

.drawer-close-btn { 
    font-size: 2rem; 
    font-weight: 300; 
    line-height: 1; 
    color: var(--text-muted); 
    background: none; 
    border: none; 
    cursor: pointer; 
}

.drawer-content { 
    max-height: 50vh; 
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) transparent;
}

.drawer-content::-webkit-scrollbar {
    width: 6px;
}

.drawer-content::-webkit-scrollbar-track {
    background: transparent;
}

.drawer-content::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

.drawer-content::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--primary-color) 80%, white);
}

.drawer-list { 
    list-style: none; 
    padding: 0; 
    margin: 0; 
}

.drawer-item { 
    font-size: 1.1rem; 
    font-weight: 500; 
    color: var(--text-color); 
    padding: 0.75rem 1rem; 
    border-radius: 0.75rem; 
    cursor: pointer; 
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.drawer-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleX(0);
    width: 4px;
    height: 60%;
    background: var(--primary-color);
    border-radius: 0 2px 2px 0;
    transition: transform 0.3s ease;
}

.drawer-item:hover::before {
    transform: translateY(-50%) scaleX(1);
}

.drawer-item:hover { 
    background-color: var(--header-icon-bg);
    padding-left: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* =================================================================
   [7] COMPONENT: CATEGORY CARDS
   ================================================================= */
.category-card-v2 { 
    display: flex; 
    flex-direction: column; 
    background-color: var(--surface-color); 
    border-radius: 1rem; 
    overflow: hidden; 
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid var(--border-color);
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    perspective: 1000px;
    will-change: transform;
}

body.light-mode .category-card-v2 { 
    border-color: rgba(0,0,0,0.1); 
}

.category-card-v2::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, 
        rgba(32, 110, 122, 0.1) 0%, 
        transparent 50%
    );
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.category-card-v2:hover {
    transform: translateY(-10px) rotateX(5deg);
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.4),
        0 0 30px rgba(32, 110, 122, 0.15);
}

.category-card-v2:hover::after {
    opacity: 1;
}

.category-card-v2 .image-container { 
    width: 100%; 
    aspect-ratio: 1 / 1; 
    background-size: cover; 
    background-position: center;
    background-color: var(--pill-bg-color);
    position: relative; 
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.category-card-v2 .image-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        110deg,
        var(--pill-bg-color) 0%,
        color-mix(in srgb, var(--pill-bg-color) 90%, white) 50%,
        var(--pill-bg-color) 100%
    );
    background-size: 200% 100%;
    animation: shimmerLoad 1.5s ease-in-out infinite;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.category-card-v2 .image-container.loading::before {
    opacity: 1;
}

.category-card-v2:hover .image-container { 
    transform: scale(1.1) translateZ(20px);
}

.category-card-v2 .overlay { 
    position: absolute; 
    inset: 0; 
    background: linear-gradient(to top, 
        rgba(0,0,0,0.8) 0%, 
        rgba(0,0,0,0.3) 40%,
        transparent 70%
    );
    transition: background 0.4s ease;
}

.category-card-v2:hover .overlay {
    background: linear-gradient(to top, 
        rgba(0,0,0,0.6) 0%, 
        rgba(0,0,0,0.2) 40%,
        transparent 70%
    );
}

.category-card-v2 .text-container { 
    padding: 1rem; 
    text-align: center; 
}

.category-card-v2 .text-container h2 { 
    color: var(--text-color);
    font-size: var(--font-size-lg);
}

.category-card-v2 .item-count { 
    font-size: var(--font-size-xs);
    color: var(--item-description, var(--text-muted)); 
    margin-top: 4px; 
}

/* =================================================================
   [8] COMPONENT: ITEM CARDS (LAZY LOAD ENABLED)
   ================================================================= */
.item-card-modern { 
    background-color: var(--surface-color); 
    border-radius: 1rem; 
    border: 1px solid var(--border-color);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden; 
    cursor: pointer; 
    display: flex; 
    flex-direction: column;
    position: relative;
    will-change: transform;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.item-card-modern::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(45deg, 
        var(--primary-color), 
        transparent, 
        var(--primary-color)
    );
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: -1;
}

.item-card-modern:hover::before {
    opacity: 0.3;
    animation: borderGlow 2s linear infinite;
}

@keyframes borderGlow {
    0%, 100% { filter: hue-rotate(0deg); }
    50% { filter: hue-rotate(20deg); }
}

body.light-mode .item-card-modern { 
    border-color: rgba(0,0,0,0.08); 
    box-shadow: 0 4px 20px -5px rgba(0,0,0,0.04); 
}

.item-card-modern:hover { 
    transform: translateY(-8px) scale(1.02);
    box-shadow: 
        0 20px 40px -15px rgba(0,0,0,0.3),
        0 0 20px rgba(32, 110, 122, 0.2);
}

.item-card-modern:active {
    transform: translateY(-4px) scale(0.98);
}

.item-card-modern h4 { 
    color: var(--item-name, var(--text-color));
    font-size: var(--font-size-base);
}

.item-card-modern p { 
    color: var(--item-price, var(--primary-color));
    font-size: var(--font-size-lg);
}

.item-card-image-container { 
    position: relative; 
    width: 100%; 
    aspect-ratio: 1 / 1; 
    overflow: hidden; 
}

/* ✅ LAZY LOAD STYLES */
.item-card-image { 
    width: 100%; 
    height: 100%; 
    background-size: cover; 
    background-position: center;
    background-color: var(--pill-bg-color);
    position: relative;
    
    /* Transitions for Transform AND Opacity */
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.5s ease;
    
    /* Hidden Initially */
    opacity: 0;
}

/* Fade In when Loaded */
.item-card-image.loaded {
    opacity: 1;
}

/* Placeholder Style */
.item-card-image.lazy-bg {
    background-color: var(--pill-bg-color);
}

.item-card-image::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        110deg,
        var(--pill-bg-color) 0%,
        color-mix(in srgb, var(--pill-bg-color) 90%, white) 50%,
        var(--pill-bg-color) 100%
    );
    background-size: 200% 100%;
    animation: shimmerLoad 1.5s ease-in-out infinite;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Show Shimmer when Lazy Loading */
.item-card-image.lazy-bg::before,
.item-card-image.loading::before {
    opacity: 1;
}

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

.item-card-modern:hover .item-card-image { 
    transform: scale(1.15) rotate(2deg);
}

.item-card-overlay { 
    position: absolute; 
    inset: 0; 
    background: linear-gradient(to top, rgba(0,0,0,0.4), transparent 50%); 
    z-index: 5; 
}

.quick-add-btn { 
    min-width: 44px;
    min-height: 44px;
    width: 40px; 
    height: 40px; 
    border-radius: 999px; 
    background: linear-gradient(135deg, 
        var(--primary-color) 0%, 
        color-mix(in srgb, var(--primary-color) 80%, white) 100%
    );
    color: var(--cart-btn-icon); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 1rem; 
    flex-shrink: 0; 
    margin-left: 0.5rem; 
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.quick-add-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    transform: scale(0);
    transition: transform 0.5s ease-out;
}

.quick-add-btn:active::before {
    transform: scale(2.5);
    opacity: 0;
}

.quick-add-btn:hover { 
    transform: scale(1.15) rotate(90deg);
    box-shadow: 
        0 5px 15px rgba(0,0,0,0.2),
        0 0 20px rgba(32, 110, 122, 0.4);
}

.quick-add-btn:active {
    transform: scale(0.9) rotate(90deg);
}

.quick-add-btn.added { 
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    transform: scale(1.2) rotate(360deg);
}

/* ✅ SUCCESS BUTTON STATE */
.quick-add-btn.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
    color: #FFFFFF !important;
    transform: scale(1.15) rotate(360deg) !important;
    box-shadow: 
        0 8px 25px rgba(40, 167, 69, 0.4),
        0 0 30px rgba(40, 167, 69, 0.3) !important;
    animation: successPulse 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes successPulse {
    0% {
        transform: scale(1) rotate(0deg);
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
    }
    50% {
        transform: scale(1.2) rotate(180deg);
        box-shadow: 0 0 0 15px rgba(40, 167, 69, 0);
    }
    100% {
        transform: scale(1.15) rotate(360deg);
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

.quick-add-btn.btn-success i {
    animation: checkmarkBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes checkmarkBounce {
    0% {
        transform: scale(0) rotate(-45deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.3) rotate(10deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.quick-add-btn:disabled {
    cursor: not-allowed;
    opacity: 0.9;
}

.quick-add-btn.btn-success::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transform: scale(0);
    animation: rippleEffect 0.6s ease-out;
}

@keyframes rippleEffect {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

.item-card-modern { 
    opacity: 0; 
    animation: fadeInSlideUp 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; 
}

.item-card-modern:nth-child(1) { animation-delay: 0.05s; }
.item-card-modern:nth-child(2) { animation-delay: 0.1s; }
.item-card-modern:nth-child(3) { animation-delay: 0.15s; }
.item-card-modern:nth-child(4) { animation-delay: 0.2s; }

@keyframes fadeInSlideUp { 
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    } 
    to { 
        opacity: 1; 
        transform: translateY(0); 
    } 
}

/* =================================================================
   [9] FLYING CART ANIMATION
   ================================================================= */
.flying-item {
    position: fixed;
    width: 80px;
    height: 80px;
    border-radius: 12px;
    background-size: cover;
    background-position: center;
    z-index: 99999;
    pointer-events: none;
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(32, 110, 122, 0.3);
    will-change: transform, opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
}

@keyframes cartShake {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    15% { transform: translateX(-5px) rotate(-3deg); }
    30% { transform: translateX(5px) rotate(3deg); }
    45% { transform: translateX(-4px) rotate(-2deg); }
    60% { transform: translateX(4px) rotate(2deg); }
    75% { transform: translateX(-2px) rotate(-1deg); }
}

@keyframes badgePop {
    0% { transform: scale(1) rotate(0deg); }
    30% { transform: scale(1.5) rotate(10deg); }
    50% { transform: scale(1.3) rotate(-5deg); }
    70% { transform: scale(1.4) rotate(3deg); }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes cartPulse {
    0% { box-shadow: 0 0 0 0 rgba(32, 110, 122, 0.7); }
    50% { box-shadow: 0 0 0 10px rgba(32, 110, 122, 0); }
    100% { box-shadow: 0 0 0 0 rgba(32, 110, 122, 0); }
}

/* =================================================================
   [10] VIEW TRANSITIONS
   ================================================================= */
.view-container {
    position: relative;
    width: 100%;
}

@keyframes slideInRight {
    from {
        transform: translateX(30%) scale(0.95);
        opacity: 0;
        filter: blur(5px);
    }
    to {
        transform: translateX(0) scale(1);
        opacity: 1;
        filter: blur(0);
    }
}

/* =================================================================
   [11] SKELETON LOADER
   ================================================================= */
.skeleton-card {
    background: linear-gradient(
        90deg,
        var(--surface-color) 0%,
        color-mix(in srgb, var(--surface-color) 95%, white) 50%,
        var(--surface-color) 100%
    );
    background-size: 200% 100%;
    border-radius: 1rem;
    overflow: hidden;
    border: 1px solid var(--border-color);
    animation: skeletonWave 1.5s ease-in-out infinite;
}

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

.skeleton-card .image {
    width: 100%;
    aspect-ratio: 1 / 1;
    background-color: var(--pill-bg-color);
}

.skeleton-card .text-line {
    height: 1rem;
    margin: 1rem;
    border-radius: 0.5rem;
    background-color: var(--pill-bg-color);
}

.skeleton-card .text-line.short {
    width: 60%;
    margin-top: 0.5rem;
}

/* =================================================================
   [12] PREMIUM: TAB STYLE - TEXT ONLY (Replaces Magic Ink)
/* ================================================================= */
.magic-indicator {
    display: none !important;
}

/* =================================================================
   [13] SCROLL PROGRESS INDICATOR
   ================================================================= */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg,
        var(--primary-color) 0%,
        color-mix(in srgb, var(--primary-color) 70%, white) 100%
    );
    z-index: 9999;
    transition: width 0.1s ease-out;
    box-shadow: var(--glow-primary);
}

/* =================================================================
   [14] EMPTY & ERROR STATES
   ================================================================= */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    min-height: 300px;
    position: relative;
}

.empty-state::before {
    content: '';
    position: absolute;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, 
        rgba(32, 110, 122, 0.1) 0%, 
        transparent 70%
    );
    border-radius: 50%;
    z-index: 0;
}

.empty-state-icon {
    font-size: 4rem;
    color: var(--text-muted);
    opacity: 0.4;
    margin-bottom: 1rem;
    animation: emptyFloat 3s ease-in-out infinite;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

@keyframes emptyFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.empty-state-text {
    color: var(--text-muted);
    font-size: 1.1rem;
    position: relative;
    z-index: 1;
}

.error-shake {
    animation: errorShake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* =================================================================
   [15] ACCESSIBILITY - REDUCED MOTION
   ================================================================= */
@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;
    }
    .item-card-modern:hover, .category-card-v2:hover, .quick-add-btn:hover {
        transform: none;
    }
}

/* =================================================================
   [16] RESPONSIVE ADJUSTMENTS
   ================================================================= */
@media (max-width: 768px) {
    .category-card-v2:hover { transform: translateY(-5px) rotateX(0deg); }
    .item-card-modern:hover { transform: translateY(-4px) scale(1.01); }
}

/* =================================================================
   [17] PERFORMANCE OPTIMIZATIONS
   ================================================================= */
.item-card-modern, .category-card-v2 { contain: layout style paint; }
.item-card-modern, .category-card-v2, .quick-add-btn, .pill-button {
    transform: translateZ(0);
    backface-visibility: hidden;
}

@media (prefers-reduced-data: reduce) {
    .pill-container, .bottom-drawer, .nav-overlay {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

@media (hover: none) and (pointer: coarse) {
    .item-card-modern::before, .category-card-v2::after { display: none; }
}

/* =================================================================
   [18] HIGH REFRESH RATE SUPPORT
   ================================================================= */
@media (min-resolution: 120dpi) {
    .item-card-modern, .category-card-v2, .quick-add-btn, .pill-button, .subcat-tab {
        transition-timing-function: cubic-bezier(0.22, 0.61, 0.36, 1);
    }
    .flying-item {
        animation-timing-function: cubic-bezier(0.22, 0.61, 0.36, 1);
    }
}

/* =================================================================
   [19] PRINT STYLES
   ================================================================= */
@media print {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    body { background: white; color: black; padding: 0; }
    #unified-category-bar, .floating-action-bar, .header-actions, .quick-add-btn,
    .scroll-progress, .nav-overlay, .side-nav, .bottom-drawer { display: none !important; }
    .item-card-modern, .category-card-v2 {
        break-inside: avoid; page-break-inside: avoid; border: 1px solid #ddd; margin-bottom: 1rem; box-shadow: none;
    }
    .item-card-modern h4 { color: #000; }
    .item-card-modern p { color: #333; }
}

/* =================================================================
   [20] MINI TOAST ANIMATIONS
   ================================================================= */
.mini-toast { animation: toastSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes toastSlideUp {
    0% { transform: translateX(-50%) translateY(50px) scale(0.8); opacity: 0; }
    100% { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
}
.mini-toast.hiding { animation: toastSlideDown 0.3s ease-in forwards; }
@keyframes toastSlideDown {
    0% { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
    100% { transform: translateX(-50%) translateY(50px) scale(0.8); opacity: 0; }
}

/* =================================================================
   [21] PERFORMANCE & SECTIONS
   ================================================================= */
.flying-item, .cart-counter-badge, .quick-add-btn, .pill-button {
    transform: translateZ(0); backface-visibility: hidden; perspective: 1000px;
}

.category-section {
    margin-bottom: 4rem; scroll-margin-top: 180px; opacity: 0;
    animation: sectionFadeIn 0.6s ease-out forwards;
    animation-delay: calc(var(--section-index, 0) * 0.1s);
}

@keyframes sectionFadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-title {
    font-size: var(--font-size-xl); font-weight: 700; color: var(--text-color);
    margin-bottom: 1.5rem; padding-bottom: 0.75rem; position: relative; display: inline-block; width: 100%;
}
.section-title::after {
    content: ''; position: absolute; bottom: 0; left: 0; width: 80px; height: 3px;
    background: linear-gradient(90deg, var(--primary-color) 0%, transparent 100%);
    border-radius: 2px; transition: width 0.3s ease;
}
.section-title:hover::after { width: 120px; }
.section-title::before {
    content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 1px;
    background: var(--border-color); opacity: 0.3;
}

.section-title.sticky {
    position: sticky; top: 160px; background: var(--bg-color); padding: 1rem 0;
    margin: 0 -1rem 1.5rem -1rem; padding-left: 1rem; padding-right: 1rem; z-index: 10;
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    background: color-mix(in srgb, var(--bg-color) 90%, transparent);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1); border-radius: 12px; transition: all 0.3s ease;
}

.category-section:empty::after {
    content: 'No items available'; display: block; text-align: center;
    padding: 3rem 1rem; color: var(--text-muted); font-size: var(--font-size-sm);
}

.category-section.is-visible {
    animation: sectionSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes sectionSlideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}