/* CSS Reset & Custom Properties */
:root {
    /* Colors: Green, Black, Orange theme */
    --primary-color: #009669; /* Emerald Green matching mockup */
    --primary-hover: #047857;
    --secondary-color: #1f2937; /* Dark Gray/Black */
    --text-main: #111827; /* Near Black */
    --text-muted: #6b7280;
    --bg-color: #f9fafb;
    --surface-color: #ffffff;
    --border-color: #e5e7eb;
    
    /* Accents */
    --accent-orange: #f97316; /* Orange for badges and highlights */
    --danger-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;

    /* Shadow & Radius */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-floating: 0 0px 20px 0 rgb(37 99 235 / 0.3);
    --radius-sm: 0.375rem;
    --radius-md: 0.75rem;
    --radius-lg: 1.25rem;
    --radius-full: 9999px;

    /* Transition for Theme Switching */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

[data-theme="dark"] {
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #333333;
    /* Note: --primary-color is controlled dynamically by SettingsManager */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Tajawal', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    padding-bottom: 80px; /* Space for bottom bar */
}

input, button, textarea, select {
    font-family: inherit;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

button, input, select, textarea {
    font-family: inherit;
    border: none;
    outline: none;
}

button {
    cursor: pointer;
    background: none;
}

/* Container */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Glassmorphism */
.glass {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
    background: var(--surface-color);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: auto;
    min-height: 65px;
}

.logo {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Logo Animation from Top */
@keyframes logoDropIn {
    0% {
        opacity: 0;
        transform: translateY(-40px) scale(0.9);
    }
    70% {
        opacity: 1;
        transform: translateY(5px) scale(1.03);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.animated-logo {
    animation: logoDropIn 0.85s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    color: var(--text-main);
    transition: all var(--transition-fast);
    background: #f8fafc;
}

.icon-btn:hover {
    background-color: var(--primary-color);
    color: white;
}

/* Bottom App Bar (Mobile First) */
.bottom-app-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65px;
    background-color: var(--surface-color);
    box-shadow: 0 -4px 10px rgba(0,0,0,0.05);
    z-index: 100;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 1rem;
    border-top-left-radius: 1.5rem;
    border-top-right-radius: 1.5rem;
}

.bottom-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    transition: color var(--transition-fast);
    flex: 1;
    text-align: center;
}

.bottom-action:hover, .bottom-action.active {
    color: var(--primary-color);
}

.bottom-action i {
    width: 24px;
    height: 24px;
}

/* Floating Cart in center of bottom bar */
.floating-cart-wrapper {
    position: relative;
    top: -25px; /* Protrude outwards */
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.floating-cart-btn {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-floating);
    position: relative;
    transition: transform var(--transition-fast);
}

.floating-cart-btn:hover {
    transform: scale(1.05) translateY(-2px);
}

.floating-cart-btn i {
    width: 28px;
    height: 28px;
}

.floating-cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--danger-color);
    color: white;
    font-size: 0.75rem;
    font-weight: 800;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    border: 2px solid var(--surface-color);
}

/* Shop Toolbar: Single horizontal row on all screen sizes */
.shop-toolbar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.25rem;
    margin-bottom: 0.85rem;
    gap: 0.5rem;
    padding: 0 0.1rem;
    position: relative;
    z-index: 20; /* Ensure dropdown displays over categories */
}

/* Custom Sort Dropdown Container */
.custom-dropdown {
    position: relative;
}

.sort-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: #ffffff;
    border: 1.5px solid #009669;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 700;
    color: #111827;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 150, 105, 0.08);
    transition: all var(--transition-fast);
}

.sort-toggle-btn:hover, .sort-toggle-btn.open {
    border-color: #009669;
    box-shadow: 0 4px 12px rgba(0, 150, 105, 0.2);
}

.sort-toggle-btn .sort-icon {
    width: 15px;
    height: 15px;
    color: #009669;
}

.sort-toggle-btn .chevron-icon {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.sort-toggle-btn.open .chevron-icon {
    transform: rotate(180deg);
}

/* Dropdown Menu Popup */
.sort-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0; /* RTL alignment: opens under toggle button on the right */
    min-width: 210px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.06);
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.96);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.sort-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.sort-option-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: right;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.sort-option-item i:not(.check-icon) {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.sort-option-item .check-icon {
    width: 16px;
    height: 16px;
    margin-right: auto; /* Push checkmark to left edge in RTL */
    color: #009669;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.sort-option-item:hover {
    background-color: rgba(0, 150, 105, 0.08);
    color: #009669;
}

.sort-option-item:hover i:not(.check-icon) {
    color: #009669;
}

.sort-option-item.active {
    background-color: rgba(0, 150, 105, 0.12);
    color: #009669;
}

.sort-option-item.active .check-icon {
    opacity: 1;
}

.sort-option-item.active i:not(.check-icon) {
    color: #009669;
}

/* Product Count Pill: Compact & opposite side */
.product-count-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #ffffff;
    border: 1.5px solid #009669;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-full);
    font-size: 0.82rem;
    font-weight: 700;
    color: #111827;
    box-shadow: 0 2px 8px rgba(0, 150, 105, 0.08);
    white-space: nowrap;
}

/* Live Pulsing Purple Product Count Badge under Categories */
.product-count-live-purple {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: linear-gradient(135deg, #9333ea, #6b21a8) !important;
    color: #ffffff !important;
    padding: 0.45rem 0.95rem;
    border-radius: 9999px;
    font-size: 0.82rem;
    font-weight: 800;
    box-shadow: 0 4px 14px rgba(147, 51, 234, 0.45);
    animation: livePurplePulse 2s infinite ease-in-out;
    letter-spacing: 0.3px;
}

.product-count-live-purple i {
    color: #ffffff;
}

.product-count-live-purple strong {
    color: #ffffff;
    font-weight: 900;
    font-size: 0.92rem;
}

.product-count-live-purple .live-dot {
    width: 7px;
    height: 7px;
    background-color: #ffffff;
    border-radius: 50%;
    animation: liveDotBlink 1.2s infinite ease-in-out;
    box-shadow: 0 0 5px #ffffff;
}

@keyframes livePurplePulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 14px rgba(147, 51, 234, 0.45);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 6px 20px rgba(147, 51, 234, 0.7);
    }
}

/* Product Stock Pill Badge inside product cards */
.stock-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.18rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.68rem;
    font-weight: 800;
    margin: 0.2rem auto 0.45rem auto;
    white-space: nowrap;
    max-width: 100%;
    align-self: center;
    text-align: center;
}

.stock-pill i {
    width: 11px;
    height: 11px;
    flex-shrink: 0;
}

/* Green (stock >= 10) */
.stock-pill.stock-high {
    background-color: rgba(16, 185, 129, 0.12);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

/* Dark Orange (stock >= 5 & stock < 10) */
.stock-pill.stock-medium {
    background-color: rgba(249, 115, 22, 0.14);
    color: #c2410c;
    border: 1px solid rgba(249, 115, 22, 0.3);
}

/* Red Limited (stock < 5) */
.stock-pill.stock-low {
    background-color: rgba(239, 68, 68, 0.14);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.35);
    animation: stockLowPulse 1.8s infinite ease-in-out;
}

@keyframes stockLowPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.75; }
}

/* Out of stock */
.stock-pill.stock-out {
    background-color: rgba(107, 114, 128, 0.12);
    color: #6b7280;
    border: 1px solid rgba(107, 114, 128, 0.2);
}

/* Card Quantity Selector Row */
.card-qty-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 0.5rem;
    padding: 0.2rem 0.4rem;
    background: #f8fafc;
    border-radius: var(--radius-full);
    border: 1px solid rgba(0, 150, 105, 0.2);
}

.qty-label {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--text-muted);
}

.card-qty-selector {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #ffffff;
    border: 1.5px solid rgba(0, 150, 105, 0.3);
    border-radius: var(--radius-full);
    padding: 0.1rem 0.35rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.qty-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    color: var(--primary-color);
    font-size: 0.95rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
    user-select: none;
    line-height: 1;
}

.qty-btn:hover {
    background: var(--primary-color);
    color: #ffffff;
    transform: scale(1.1);
}

.qty-btn:active {
    transform: scale(0.95);
}

.qty-val {
    font-size: 0.85rem;
    font-weight: 900;
    color: var(--text-main);
    min-width: 18px;
    text-align: center;
}

.product-count-pill strong {
    color: #009669;
    font-size: 0.9rem;
    font-weight: 800;
}

/* Category Image Cards */
/* Category Cards matching Mockup Image */
.categories-grid {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.85rem;
    margin-left: -0.5rem;
    margin-right: -0.5rem;
    margin-bottom: 0.5rem;
    overflow-x: auto;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
    padding: 0.85rem 1rem !important; /* Generous 360-degree clearance so cards never clip horizontally or vertically */
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
}

.categories-grid::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    background: transparent !important;
}

@media (min-width: 768px) {
    .categories-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 1.25rem;
        margin-left: 0;
        margin-right: 0;
        overflow-x: visible;
    }
}

/* Floating & Seamless Categories Wrapper (Merged 100% with site background) */
.categories-sticky-wrapper {
    position: relative;
    z-index: 900;
    padding: 0;
    margin-top: -0.25rem;
    margin-bottom: 0.5rem;
    background: transparent !important;
    border: none !important;
    border-top: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
    outline: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* Category Card - Floating & Elevating */
.category-image-card {
    position: relative;
    border-radius: 1.15rem;
    overflow: hidden;
    flex: 0 0 auto;
    width: 130px;
    height: 85px;
    background-color: #111827;
    box-shadow: none;
    cursor: pointer;
    border: none;
    outline: none;
    -webkit-mask-image: -webkit-radial-gradient(white, black);
    mask-image: radial-gradient(white, black);
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    text-decoration: none;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

@media (min-width: 768px) {
    .category-image-card {
        width: auto;
        height: 102px;
    }
}

/* Floating hover effect */
.category-image-card:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 10px 22px rgba(0, 150, 105, 0.28);
}

/* Floating active state - Live pulsing float animation with dynamic background aura matching the live product badge */
.category-image-card.active-cat {
    border: 2.5px solid #009669 !important;
    background-color: rgba(16, 185, 129, 0.16) !important;
    animation: catLiveFloatPulse 2.2s infinite ease-in-out !important;
}

@keyframes catLiveFloatPulse {
    0%, 100% {
        transform: translateY(0px) scale(1.02);
        box-shadow: 0 6px 18px rgba(0, 150, 105, 0.35);
        background-color: rgba(16, 185, 129, 0.14);
    }
    50% {
        transform: translateY(-6px) scale(1.06);
        box-shadow: 0 14px 30px rgba(0, 150, 105, 0.6);
        border-color: #10b981 !important;
        background-color: rgba(16, 185, 129, 0.25) !important;
    }
}

/* Crisp & Clear Category Background Image (No blur) */
.cat-card-bg-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
    transition: transform 0.35s ease;
}

.category-image-card:hover .cat-card-bg-img {
    transform: scale(1.08);
}

/* Gradient Overlay for Text Legibility */
.cat-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0.2) 65%, rgba(0, 0, 0, 0.1) 100%);
    z-index: 2;
    transition: background 0.3s ease;
}

.category-image-card:hover .cat-card-overlay {
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.25) 65%, rgba(0, 0, 0, 0.1) 100%);
}

/* Category Title Text on bottom frosted strip */
.category-image-card .cat-name {
    position: relative;
    z-index: 3;
    color: #ffffff;
    font-size: 0.88rem;
    font-weight: 800;
    text-align: center;
    line-height: 1.2;
    width: 100%;
    padding: 0.45rem 0.3rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.55) 70%, rgba(0, 0, 0, 0) 100%);
    backdrop-filter: blur(2px);
    border-bottom-left-radius: 0.9rem;
    border-bottom-right-radius: 0.9rem;
}

/* Custom vibrant fallback gradients for categories if no image */
.cat-card-all .cat-card-blur-bg {
    background: linear-gradient(135deg, #10b981, #059669, #0f766e);
}
.cat-card-idx-0 .cat-card-blur-bg {
    background: linear-gradient(135deg, #3b82f6, #6366f1, #8b5cf6);
}
.cat-card-idx-1 .cat-card-blur-bg {
    background: linear-gradient(135deg, #a855f7, #ec4899, #f43f5e);
}
.cat-card-idx-2 .cat-card-blur-bg {
    background: linear-gradient(135deg, #f59e0b, #f97316, #ef4444);
}
.cat-card-idx-3 .cat-card-blur-bg {
    background: linear-gradient(135deg, #06b6d4, #14b8a6, #10b981);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    transition: all var(--transition-fast);
    font-size: 0.95rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

/* Hero Section */
.hero {
    padding: 3rem 1rem;
    background: linear-gradient(135deg, rgba(37,99,235,0.05), rgba(37,99,235,0.1));
    text-align: center;
    border-radius: var(--radius-lg);
    margin: 1.5rem 1rem;
    border: 1px solid rgba(37,99,235,0.1);
}

.hero h1 {
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    color: var(--primary-color);
}

.hero p {
    font-size: 1rem;
    color: var(--text-muted);
}

/* Sections */
.section {
    padding: 2rem 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Mobile-First Grids */
.product-grid { 
    display: grid; 
    grid-template-columns: repeat(2, 1fr); 
    gap: 1rem;
    padding: 0 1rem 160px 1rem; /* Prevent cards from sticking to screen edges & ensure floating cart clearance */
}

/* Responsive adjustments */
@media (min-width: 768px) {
    .product-grid { grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }
    .hero h1 { font-size: 2.5rem; }
    .hero p { font-size: 1.2rem; }
}

/* Product Card matching Mockup Image */
.product-card {
    background-color: #ffffff;
    border-radius: 1.25rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    position: relative;
    border: 2px solid rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    outline: none;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.12);
    border-color: rgba(37, 99, 235, 0.4);
}

.product-card:active,
.product-card:focus,
.product-card:focus-within {
    border-color: #2563eb !important; /* Medium Vibrant Blue Border */
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25), 0 10px 25px rgba(37, 99, 235, 0.15) !important;
}

/* Live Dynamic Red Discount Badge */
.discount-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    color: #ffffff !important;
    padding: 0.25rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 800;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.5);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    animation: liveDiscountPulse 2s infinite ease-in-out;
    z-index: 15;
    letter-spacing: 0.5px;
}

.discount-badge::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #ffffff;
    border-radius: 50%;
    animation: liveDotBlink 1.2s infinite ease-in-out;
    box-shadow: 0 0 4px #ffffff;
}

@keyframes liveDiscountPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(239, 68, 68, 0.45);
    }
    50% {
        transform: scale(1.08);
        box-shadow: 0 6px 18px rgba(239, 68, 68, 0.75);
    }
}

@keyframes liveDotBlink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.3; transform: scale(0.7); }
}

.product-image-wrap {
    position: relative;
    padding-top: 70%; /* Compact product card - not too tall */
    background-color: #ffffff;
    overflow: hidden;
}

.product-image-wrap img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; /* Responsive fit like before */
    padding: 0;
    transition: transform var(--transition-fast);
}

.product-info {
    padding: 0.75rem 0.6rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-grow: 1;
    text-align: center;
    align-items: center;
}

.product-title {
    font-size: 0.85rem;
    font-weight: 800;
    color: #111827;
    margin-bottom: 0.3rem;
    line-height: 1.3;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: auto;
}

.product-bottom {
    display: flex;
    flex-direction: column;
    margin-top: auto;
    gap: 0.4rem;
    width: 100%;
    align-items: center;
}

.product-price-wrap, .product-price-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    width: 100%;
    min-height: auto;
}

.product-price {
    font-weight: 800;
    color: #009669; /* Emerald Green price */
    font-size: 1.15rem;
    text-align: center;
}

/* Discounted / Old price in RED */
.product-old-price {
    font-size: 0.82rem;
    color: #ef4444 !important; /* Vivid Red for discounted price */
    text-decoration: line-through;
    font-weight: 700;
    text-align: center;
}

/* Full-Width Add to Cart Button (Vibrant Blue Pill) */
.btn-add-cart-full {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.65rem 1rem;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    color: #ffffff;
    font-weight: 800;
    font-size: 0.92rem;
    white-space: nowrap;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.3);
    transition: all var(--transition-fast);
    line-height: 1;
}

.btn-add-cart-full span {
    white-space: nowrap;
    line-height: 1;
    display: inline-block;
    text-align: center;
    width: 100%;
}

.btn-add-cart-full:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
    transform: translateY(-1px);
}

.btn-add-cart-full:active {
    transform: scale(0.98);
}

.btn-add-cart-full.disabled {
    background: #9ca3af;
    color: #f3f4f6;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.btn-add-cart-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(37, 99, 235, 0.3);
}

.btn-add-cart-icon i {
    width: 16px;
    height: 16px;
}

.btn-add-cart-icon:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: scale(1.1);
}

.btn-add-cart-icon.disabled {
    background-color: var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

.out-of-stock-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: var(--danger-color);
    font-size: 0.75rem;
    z-index: 5;
}

/* Compact Category Cards */
.category-card {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    height: 100px;
    display: flex;
    align-items: flex-end;
    padding: 0.75rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    cursor: pointer;
}

.category-bg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-size: cover;
    background-position: center;
    z-index: 1;
    transition: transform 0.3s;
}

.category-card:hover .category-bg {
    transform: scale(1.1);
}

.category-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), rgba(0,0,0,0.1));
    z-index: 2;
}

.category-card h3 {
    position: relative;
    z-index: 3;
    color: white;
    font-weight: 800;
    font-size: 0.95rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    width: 100%;
}

/* Toast Notification */
.toast-container {
    position: fixed;
    bottom: 90px; /* Above the bottom navigation bar */
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-full);
    box-shadow: 0 3px 10px rgba(37, 99, 235, 0.35);
    font-weight: 700;
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    border: none;
    white-space: nowrap;
    animation: slideUp 0.2s ease-out forwards, fadeOutToast 0.2s ease-out 0.8s forwards;
}

.toast i {
    color: #93c5fd;
    width: 14px;
    height: 14px;
}

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

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

/* Footer (Hidden mostly because of bottom bar) */
.main-footer {
    display: none;
}
@media (min-width: 768px) {
    .main-footer { display: block; }
    .bottom-app-bar { display: none; }
    body { padding-bottom: 0; }
}

/* =========================================
   Modern Cart Redesign (Matches Screenshot)
   ========================================= */

.cart-page-wrapper {
    background-color: #f9fafc;
    min-height: 100vh;
    padding-bottom: 120px; /* Space for sticky bar */
}

/* Cart Header & Hide Bottom Bar */
body.on-cart-page #main-header,
body.on-cart-page .bottom-app-bar {
    display: none !important;
}

.cart-header-modern {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background-color: transparent;
    position: sticky;
    top: 5px;
    z-index: 50;
    pointer-events: none; /* Let scroll pass through */
}

.cart-header-modern > * {
    pointer-events: auto; /* Make elements inside clickable */
}

.cart-header-modern .back-btn, 
.cart-header-modern .empty-cart-btn {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    color: var(--text-main);
    box-shadow: 0 4px 15px rgba(0,0,0,0.06);
}

.cart-header-modern .empty-cart-btn {
    color: var(--danger-color);
}

.cart-header-modern .header-titles {
    text-align: center;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 0.5rem 1.5rem;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.06);
}

.cart-header-modern h2 {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 0.1rem;
}

.cart-header-modern .items-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Cart List */
.cart-content-modern {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.cart-items-list-modern {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Cart Item */
.cart-item-modern {
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 0.75rem;
    display: flex;
    gap: 0.75rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    align-items: stretch;
}

.cart-item-image {
    width: 85px;
    height: 85px;
    background: #f4f6f8;
    border-radius: var(--radius-md);
    flex-shrink: 0;
    padding: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-item-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cart-item-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.cart-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.cart-item-title {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}

.cart-remove-modern {
    background: rgba(239, 68, 68, 0.05);
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    padding: 0.3rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-remove-modern i {
    width: 16px;
    height: 16px;
}

.cart-item-tags {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.cart-item-tags .tag {
    background: #f4f6f8;
    color: var(--text-muted);
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.cart-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
}

.cart-item-price {
    font-weight: 800;
    color: var(--primary-color);
    font-size: 1rem;
}

.quantity-controls-modern {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #f4f6f8;
    border-radius: var(--radius-md);
    padding: 0.2rem 0.4rem;
}

.quantity-controls-modern button {
    background: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-main);
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.quantity-controls-modern button i {
    width: 12px;
}

.quantity-controls-modern span.qty {
    font-weight: 800;
    font-size: 0.85rem;
    min-width: 12px;
    text-align: center;
}

.cart-item-subtotal {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Cart Summary */
.cart-summary-modern {
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.summary-header-inner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.summary-header-inner h3 {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-main);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.summary-total {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--text-main);
}

.summary-total .total-price {
    color: var(--primary-color);
}

.savings-alert {
    background-color: rgba(16, 185, 129, 0.05);
    color: var(--primary-color);
    text-align: center;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    margin-top: 1.5rem;
    font-size: 0.85rem;
    font-weight: 700;
}

.coupon-box {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.coupon-input-wrap {
    flex-grow: 1;
    position: relative;
}

.coupon-input-wrap input {
    width: 100%;
    padding: 0.75rem 3rem 0.75rem 1rem;
    box-sizing: border-box;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: #f9fafc;
    font-family: inherit;
    font-size: 0.85rem;
}

.coupon-input-wrap .coupon-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-color);
    font-weight: 800;
}

.apply-coupon {
    background: rgba(16, 185, 129, 0.1);
    color: var(--primary-color);
    border: none;
    border-radius: var(--radius-md);
    padding: 0 1.5rem;
    font-weight: 800;
    cursor: pointer;
}

/* Recommendations */
.recommendations-section {
    margin-top: 1rem;
}

.recommendations-section h4 {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 1rem;
}

.recommend-scroll {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
    scroll-snap-type: x mandatory;
}

.recommend-scroll::-webkit-scrollbar {
    display: none;
}

.recommend-card {
    min-width: 140px;
    background: #ffffff;
    border-radius: var(--radius-md);
    padding: 0.75rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
    position: relative;
    scroll-snap-align: start;
    border: 1px solid var(--border-color);
}

.recommend-card .wishlist-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    background: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    cursor: pointer;
}

.recommend-card .wishlist-btn i {
    width: 14px;
    color: var(--text-muted);
}

.recommend-card img {
    width: 100%;
    height: 100px;
    object-fit: contain;
    background: #f4f6f8;
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
}

.recommend-card h5 {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.recommend-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.recommend-bottom .price {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--primary-color);
}

.recommend-bottom .add-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    cursor: pointer;
}

.recommend-bottom .add-btn i {
    width: 14px;
}

/* Sticky Checkout Bar */
.sticky-checkout-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    padding: 1rem;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
    z-index: 100;
}

.btn-checkout-modern {
    background: var(--primary-color);
    color: white;
    width: 100%;
    border: none;
    padding: 1.15rem;
    border-radius: var(--radius-full);
    font-size: 1.1rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
}

@media (min-width: 768px) {
    .cart-content-modern {
        display: grid;
        grid-template-columns: 2fr 1fr;
        align-items: start;
        padding-top: 2rem;
    }
    .recommendations-section {
        grid-column: 1 / -1;
    }
    .sticky-checkout-bar {
        position: relative;
        box-shadow: none;
        padding: 0;
        background: transparent;
        margin-top: 1.5rem;
    }
    .cart-summary-modern {
        position: sticky;
        top: 100px;
    }
}

/* Modern Bottom Bar 3 Items */
.bottom-app-bar.modern-3-items {
    justify-content: space-around;
    padding: 0 1rem;
}

/* Side Floating Cart matching User Mockup Image 100% */
.side-floating-cart-modern {
    position: fixed;
    bottom: 85px; /* Safely floating above bottom bar */
    left: 20px; /* Positioned on left side matching user mockup */
    right: auto;
    background: linear-gradient(135deg, #1d4ed8, #2563eb) !important; /* Vibrant Royal Blue */
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3.5px solid #ffffff; /* Thick White Ring Border matching mockup */
    box-shadow: 0 10px 25px rgba(29, 78, 216, 0.45);
    z-index: 99999;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
    touch-action: none;
    -webkit-user-drag: none;
}

.side-floating-cart-modern:active {
    transform: scale(0.92);
}

.side-floating-cart-modern i {
    width: 28px;
    height: 28px;
    color: #ffffff;
    stroke-width: 2.3;
}

.side-floating-cart-modern:hover {
    transform: scale(1.08) translateY(-3px);
    box-shadow: 0 14px 30px rgba(29, 78, 216, 0.6);
}

.side-floating-cart-modern .floating-cart-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: linear-gradient(135deg, #ef4444, #dc2626); /* Vivid Red Badge */
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: 900;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #ffffff; /* Thick White Border around Red Badge */
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.4);
}

/* Contact Modal */
.modal-overlay-modern {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.contact-modal-box {
    background: white;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 350px;
    padding: 2rem 1.5rem;
    position: relative;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    animation: modalSlideUp 0.3s ease-out;
}

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

.close-modal-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
}

.contact-header {
    margin-bottom: 2rem;
}

.contact-icon-large {
    width: 48px;
    height: 48px;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.contact-header h3 {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
}

.contact-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.contact-links {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.contact-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    font-weight: 800;
    color: white;
    text-decoration: none;
}

.contact-link.whatsapp {
    background: #25D366;
}

.contact-link.telegram {
    background: #0088cc;
}

.developer-credit {
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
    font-size: 0.85rem;
}

.developer-credit p {
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.developer-credit h4 {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.developer-credit .dev-phone {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: #f4f6f8;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    color: var(--text-main);
    font-weight: 700;
    text-decoration: none;
}
.developer-credit .dev-phone i {
    width: 14px;
    height: 14px;
}

/* Touch Interactions Smoothness */
* {
    -webkit-tap-highlight-color: transparent; /* Remove blue flash on mobile */
}

body {
    overscroll-behavior-y: none;
}

.product-card {
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.product-card:active {
    transform: scale(0.97);
}

.bottom-action:active,
.side-floating-cart-modern:active,
.btn:active,
.category-image-card:active {
    transform: scale(0.92);
    opacity: 0.8;
}

.main-service-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}

.main-service-card:active {
    transform: scale(0.95);
    opacity: 0.9;
}

/* Mobile Padding & Screen Border Safety */
.container.section {
    padding-bottom: 7rem !important;
}

select.form-control {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 0.75rem center;
    background-size: 1.1rem;
    padding-left: 2.2rem !important;
}

.modal-overlay-modern {
    padding: 1.25rem 1rem !important;
    z-index: 1050 !important;
}

.contact-modal-box {
    margin: auto !important;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 1.5rem !important;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2) !important;
}

/* Safe Area Screen Edge Padding for Mobile */
@media (max-width: 768px) {
    .container {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    .categories-sticky-wrapper {
        padding-left: 0.35rem !important;
        padding-right: 0.35rem !important;
    }
    /* Cart position is now managed by JS drag logic - no forced override */
}

/* Pulsing Live Dot Animation */
@keyframes liveDotBlink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.35; transform: scale(0.85); }
}

/* Global Ultra-Fast Button & Link Response */
button, a, .btn, .icon-btn, .sort-toggle-btn, .category-image-card, .main-service-card, .btn-add-cart-full {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent !important;
    transition: transform 0.08s ease-out, opacity 0.08s ease-out, background-color 0.12s ease !important;
    will-change: transform;
}

button:active, a:active, .btn:active, .icon-btn:active, .sort-toggle-btn:active, .main-service-card:active {
    transform: scale(0.95) translateY(1px) !important;
    opacity: 0.85 !important;
}
