:root {
    --app-bg: #f9f9f9;
    --primary: #0a2240;
    /* Dark Blue from screenshot */
    --primary-light: #153c6b;
    --accent: #ff4757;
    /* Red/Pink for badges/buttons */
    --text-dark: #2f3640;
    --text-gray: #718093;
    --border: #f1f2f6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--app-bg);
    color: var(--text-dark);
    padding-top: 105px;
    padding-bottom: 70px;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    user-select: none;
    overscroll-behavior-y: none;
}

/* Desktop App Emulator Mode */
@media (min-width: 600px) {
    html {
        background-color: #57606f;
        /* Cool dark background for the edges */
    }

    body {
        max-width: 450px;
        margin: 0 auto;
        min-height: 100vh;
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.4);
        position: relative;
        background: var(--app-bg);
    }

    .app-header,
    .bottom-nav,
    #pwa-install-banner,
    .toast-notification,
    .floating-chat {
        max-width: 450px !important;
        margin-left: auto !important;
        margin-right: auto !important;
        left: 0 !important;
        right: 0 !important;
    }

    .side-panel {
        max-width: 450px !important;
    }
}

input,
textarea {
    -webkit-user-select: auto;
    user-select: auto;
}

a {
    text-decoration: none;
    color: inherit;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

.spin {
    animation: spin 1s linear infinite;
}

/* App Header */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--primary);
    color: #fff;
    z-index: 1000;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    gap: 12px;
}

.header-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    cursor: pointer;
}

.search-bar {
    flex: 1;
    display: flex;
    align-items: center;
    background: #ffffff;
    border-radius: 6px;
    padding: 0 10px;
    height: 38px;
}

.search-bar input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.9rem;
    padding: 0 10px;
    color: #333;
}

.search-bar i {
    color: var(--primary);
    width: 18px;
}

/* Header Nav Tabs */
.header-nav {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 0 10px;
    background: var(--primary);
    -webkit-overflow-scrolling: touch;
}

.header-nav::-webkit-scrollbar {
    display: none;
}

.nav-tab {
    padding: 12px 15px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.95rem;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    flex-shrink: 0;
}

.nav-tab.active {
    color: #fff;
    border-bottom-color: #fff;
}

/* Banner Slider */
.banner-slider {
    width: 100%;
    position: relative;
    overflow: hidden;
    background: #fff;
}

.banner-track {
    display: flex;
    transition: transform 0.3s ease;
}

.banner-slide {
    min-width: 100%;
    height: 160px;
}

.banner-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Marquee */
.marquee-container {
    background: #fbf7eb;
    padding: 8px 15px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #555;
    overflow-x: auto;
    white-space: nowrap;
    border-bottom: 1px solid #eee;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.marquee-container::-webkit-scrollbar {
    display: none;
}

.marquee-text {
    display: inline-block;
    padding-left: 20px;
}

/* Circular Categories */
.cats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px 10px;
    padding: 20px 15px;
    background: #fff;
    margin-bottom: 10px;
}

.responsive-cats-page {
    grid-template-columns: repeat(4, 1fr);
}


.cat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    cursor: pointer;
}

.cat-circle {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid #eaeaea;
    padding: 2px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
    display: flex;
    align-items: center;
    justify-content: center;
}

.cat-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.cat-name {
    font-size: 0.8rem;
    font-weight: 800;
    color: #222;
    line-height: 1.2;
}

/* Section Title */
.section-title {
    padding: 15px;
    background: #fff;
    font-size: 1.1rem;
    font-weight: 900;
    color: #111;
    border-bottom: 1px solid #f5f5f5;
}

/* Sort Bar */
.sort-bar {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 15px;
    background: #fff;
    border-bottom: 1px solid #f1f2f6;
    scrollbar-width: none;
}

.sort-bar::-webkit-scrollbar {
    display: none;
}

.sort-btn {
    background: #f8f9fa;
    color: #555;
    border: 1px solid #eee;
    padding: 6px 15px;
    border-radius: 6px;
    font-weight: bold;
    font-size: 0.8rem;
    white-space: nowrap;
    cursor: pointer;
    transition: 0.2s;
}

.sort-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 10px;
    background: var(--app-bg);
}



.product-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    border: 1px solid #f1f2f6;
    position: relative;
}

.fav-icon-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    color: #777;
    z-index: 2;
    transition: all 0.2s;
}

.fav-icon-btn.active {
    color: #ff4757;
}

.product-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.product-img.loaded {
    opacity: 1;
}

.product-info {
    padding: 10px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.product-title {
    font-size: 0.85rem;
    font-weight: 800;
    margin-bottom: 5px;
    color: #2f3640;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price {
    font-size: 1.1rem;
    font-weight: 900;
    color: var(--accent);
    margin-top: auto;
    text-align: left;
    margin-bottom: 12px;
}

.add-cart-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 10px;
    border-radius: 8px;
    font-weight: 700;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
}

/* Toast Notification */
.toast-notification {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: #fff;
    padding: 10px 25px;
    border-radius: 25px;
    font-weight: bold;
    font-size: 0.9rem;
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    pointer-events: none;
}

.toast-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65px;
    background: #fff;
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 15px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    border-top: 1px solid #eaeaea;
}

.b-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-gray);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    flex: 1;
}

.b-nav-item i {
    width: 22px;
    height: 22px;
}

.b-nav-item.active {
    color: var(--primary);
}

.b-nav-item.active .icon-wrap {
    background: var(--primary);
    color: #fff;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-5px);
    box-shadow: 0 4px 10px rgba(10, 34, 64, 0.3);
}

.b-nav-item.active .icon-wrap i {
    width: 20px;
    height: 20px;
}

/* Modals Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal-overlay.show {
    display: block;
    opacity: 1;
}

/* Side Panel (Cart / Product) */
.side-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    right: -100%;
    width: 100%;
    max-width: 400px;
    background: #f9f9f9;
    z-index: 2001;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.side-panel.open {
    right: 0;
}

/* Panel Header */
.panel-header {
    background: #fff;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    z-index: 10;
}

.panel-title {
    font-weight: 900;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.close-btn {
    background: #f1f2f6;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #333;
}

/* Product Details inside Panel */
.p-image-box {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background: #fff;
    overflow: hidden;
}

.p-image-track {
    display: flex;
    width: 100%;
    height: 100%;
    transition: transform 0.3s ease-out;
}

.p-image-slide {
    min-width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.p-image-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.p-image-dots {
    position: absolute;
    bottom: 15px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 6px;
}

.p-image-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
    transition: 0.3s;
}

.p-image-dot.active {
    background: var(--primary);
    transform: scale(1.2);
}

.gallery-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.8);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    color: #333;
}

.gallery-arrow.prev {
    right: 10px;
}

.gallery-arrow.next {
    left: 10px;
}

.p-info-box {
    padding: 20px;
    background: #fff;
    margin-bottom: 10px;
}

.p-title {
    font-size: 1.2rem;
    font-weight: 900;
    color: #111;
    margin-bottom: 10px;
}

.p-price-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.p-price {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--accent);
}

.p-currency {
    font-size: 0.9rem;
    color: #777;
}

/* Attributes block */
.p-attributes {
    background: #f8f9fa;
    border: 1px solid #eef2f5;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
}

.p-attr-title {
    font-weight: 900;
    font-size: 1rem;
    color: #111;
    margin-bottom: 10px;
    text-align: center;
}

.p-attr-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.p-attr-item {
    background: #fff;
    padding: 8px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #444;
    border: 1px solid #eee;
    text-align: center;
}

.p-desc {
    line-height: 1.8;
    color: #555;
    font-size: 0.95rem;
    white-space: pre-wrap;
}

/* Sticky Bottom Bar (Product) */
.p-bottom-bar {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding: 15px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    z-index: 10;
}

.btn-add {
    flex: 1;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 15px;
    border-radius: 12px;
    font-weight: 900;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
}

.btn-fav {
    width: 55px;
    height: 55px;
    border: 1px solid #ddd;
    background: #fff;
    color: #777;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
}

.btn-fav.active {
    color: #ff4757;
    border-color: #ff4757;
    background: #fff1f2;
}

/* Cart Items */
.cart-item-card {
    background: #fff;
    margin: 15px;
    border-radius: 12px;
    padding: 15px;
    border: 1px solid #eee;
    display: flex;
    gap: 15px;
    align-items: center;
}

.cart-item-img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #eee;
}

.cart-item-info {
    flex: 1;
}

.cart-item-title {
    font-weight: 800;
    font-size: 0.9rem;
    margin-bottom: 5px;
    color: #111;
}

.cart-item-price {
    font-weight: 900;
    color: var(--accent);
}

.cart-qty-ctrl {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 4px;
}

.qty-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Checkout Form */
.checkout-section {
    background: #fff;
    padding: 15px;
    margin-bottom: 10px;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
}

.checkout-title {
    font-weight: 900;
    font-size: 1rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
}

.checkout-input {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px;
    font-size: 0.95rem;
    outline: none;
    margin-bottom: 10px;
    background: #fafafa;
}

.checkout-input:focus {
    border-color: var(--primary);
}

.checkout-total-row {
    display: flex;
    justify-content: space-between;
    font-weight: 900;
    font-size: 1.1rem;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px dashed #ddd;
}

/* Floating WhatsApp */
.wa-float {
    position: fixed;
    bottom: 85px;
    right: 15px;
    width: 50px;
    height: 50px;
    background: #25d366;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(37, 211, 102, 0.4);
    z-index: 1500;
    cursor: pointer;
}

/* Side Menu (Hamburger) */
.side-menu-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    right: -100%;
    width: 280px;
    background: #fff;
    z-index: 3000;
    transition: right 0.3s ease;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.side-menu-panel.open {
    right: 0;
}

.sm-header {
    padding: 20px;
    background: var(--primary);
    color: #fff;
    font-weight: 900;
    font-size: 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sm-link {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    color: #333;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sm-link:active {
    background: #f5f5f5;
}

/* ===== Skeleton Loaders ===== */
@keyframes shimmer {
    0% {
        background-position: -400px 0;
    }

    100% {
        background-position: 400px 0;
    }
}

.skeleton-img {
    width: 100%;
    aspect-ratio: 1;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 800px 100%;
    animation: shimmer 1.4s infinite linear;
}

.skeleton-line {
    border-radius: 6px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 800px 100%;
    animation: shimmer 1.4s infinite linear;
}

/* ===== Micro-animations on Product Card ===== */
.product-card {
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.product-card:active {
    transform: scale(0.97);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}

/* Fade-in animation for newly loaded products */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(18px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.product-card.animate-in {
    animation: fadeInUp 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* ===== Add-to-cart button animation ===== */
.add-cart-btn {
    transition: transform 0.15s, opacity 0.15s, background 0.2s;
}

.add-cart-btn:active {
    transform: scale(0.94);
    opacity: 0.85;
}

/* ===== Smooth image reveal ===== */
.product-img {
    transition: opacity 0.4s ease, transform 0.4s ease;
}

/* ===== Load More Button Hover ===== */
#load-more-btn {
    transition: transform 0.18s, box-shadow 0.18s;
}

#load-more-btn:active {
    transform: scale(0.96);
    box-shadow: 0 2px 8px rgba(10, 34, 64, 0.15);
}

/* ===== Sort Button Active animation ===== */
.sort-btn {
    transition: background 0.18s, color 0.18s, transform 0.13s;
}

.sort-btn:active {
    transform: scale(0.94);
}

/* ===== Pulse animation for cart badge ===== */
@keyframes badgePulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
    }
}

.badge-pulse {
    animation: badgePulse 0.3s ease;
}

/* ===== Category card hover ===== */
.cat-item {
    transition: transform 0.18s;
}

.cat-item:active {
    transform: scale(0.92);
}

.cat-circle {
    transition: box-shadow 0.2s, border-color 0.2s;
}

.cat-circle:hover {
    box-shadow: 0 6px 18px rgba(10, 34, 64, 0.13);
    border-color: var(--primary);
}