:root {
    --header-height: 130px;
    /* Further reduced for minimalism */
}

/* الحالة الافتراضية للرأس */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1100;
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    width: 100%;
    margin-bottom: 0px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 5px 20px;
    height: var(--header-height);
    justify-content: center;

    /* Force constant layout direction */
    direction: rtl !important;
    text-align: right !important;

    /* تسريع الأجهزة */
    will-change: transform, padding;
    transform: translateZ(0);

    /* انتقال سلس ومحدد لتجنب استهلاك الموارد */
    transition: padding 0.3s ease, gap 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
}

/* إزاحة المحتوى لتعويض الهيدر الثابت */
body {
    padding-top: var(--header-height);
}

.header-row {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    direction: rtl !important;
}

/* حالة التمرير (تبسيط كامل للأداء) */
.header.scrolled {
    padding: 4px 20px;
    gap: 3px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.header.scrolled .header-logo-row {
    display: flex;
    opacity: 1;
    pointer-events: auto;
    justify-content: center;
    margin-top: 140px;
    margin-bottom: 5px;
}

.header.scrolled .header-controls-row {
    padding: 3px 0;
}

.header.scrolled .logo {
    transform: scale(0.85);
}

/* زر العودة للأعلى */
#scrollToTop {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(100px);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: transform, opacity;
}

#scrollToTop.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#scrollToTop:hover {
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4);
    background: var(--primary-dark);
}

#scrollToTop:active {
    transform: translateY(-3px) scale(1.05);
}

/* أنيميشن بسيط وأقل استهلاكاً للطاقة */
#scrollToTop.visible {
    animation: bounce-gentle 2s infinite;
}

@keyframes bounce-gentle {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

/* الوضع الليلي */
.dark-mode .header.scrolled {
    background: rgba(30, 41, 59, 0.95);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.dark-mode #scrollToTop {
    background: var(--primary-color);
}

.dark-mode #scrollToTop:hover {
    background: var(--primary-dark);
}

.mobile-only {
    display: none !important;
}

/* للهواتف المحمولة */
@media (max-width: 768px) {
    .mobile-only {
        display: flex !important;
    }

    .desktop-only {
        display: none !important;
    }

    .header {
        padding: 5px 15px;
        gap: 0;
        height: 80px;
        /* Reduced from 100px */
        -webkit-transform: none !important;
        transform: none !important;
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
        filter: none !important;
        will-change: padding;
    }

    body {
        padding-top: 80px;
        padding-bottom: 80px;
        /* Offset for bottom nav */
    }

    /* نقل أزرار التحكم للأسفل */
    .header-controls-row {
        position: fixed !important;
        bottom: 0 !important;
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        background: var(--glass-bg);
        -webkit-backdrop-filter: blur(15px);
        backdrop-filter: blur(15px);
        border-top: 1px solid var(--border-color);
        padding: 10px 15px !important;
        /* Fixed padding, never shrinks */
        height: 80px !important;
        /* Fixed height */
        z-index: 1200;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
        display: flex !important;
        /* ضمان الظهور دائماً */
        opacity: 1 !important;
        pointer-events: auto !important;

        /* Force constant direction */
        direction: rtl !important;
    }

    .header-controls {
        width: 100%;
        justify-content: space-around;
        gap: 5px;
        direction: rtl !important;
    }

    .header-controls .btn {
        flex: 1;
        max-width: 65px;
        height: 55px;
        padding: 0;
        border-radius: 16px;
        background: transparent;
        color: var(--text-primary);
        box-shadow: none;
        border: none;
    }

    .header-controls .btn i {
        font-size: 1.6rem;
    }

    .header-controls .btn:hover {
        background: rgba(255, 107, 53, 0.1);
        color: var(--primary-color);
        transform: translateY(-2px);
    }

    /* Active State for Mobile Navigation */
    .header-controls .btn.active-nav-btn {
        color: var(--primary-color);
        background: rgba(var(--primary-rgb), 0.1);
        position: relative;
    }

    .header-controls .btn.active-nav-btn::after {
        content: '';
        position: absolute;
        bottom: 5px;
        left: 50%;
        transform: translateX(-50%);
        width: 4px;
        height: 4px;
        background: var(--primary-color);
        border-radius: 50%;
    }

    /* زر العودة للأعلى - رفعه قليلاً ليتجنب التداخل مع الشريط السفلي */
    #scrollToTop {
        bottom: 80px;
        right: 20px;
    }

    /* إبقاء الرأس العلوي ظاهراً دائماً في الهواتف */
    .header.scrolled {
        padding: 5px 15px;
        /* Balanced padding */
        min-height: auto;
        justify-content: center;
    }

    .header.scrolled .header-logo-row {
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: scale(0.95);
        justify-content: center;
        width: 100%;
    }

    .header.scrolled .logo h1 {
        font-size: 1.1rem;
    }

    .header.scrolled .logo-img,
    .header.scrolled .cart-logo-img {
        width: 35px;
        height: 35px;
    }
}

/* للشاشات الصغيرة جداً */
@media (max-width: 480px) {
    #scrollToTop {
        bottom: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
}

/* تأثير إضافي للرأس */
.header-logo-row,
.header-controls-row {
    transition: all 0.3s ease;
}

.logo-container {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
}

@media (max-width: 768px) {
    .header-controls {
        width: 100%;
        justify-content: space-around;
        gap: 5px;
        direction: rtl !important;
    }
}

.logo {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.final-logo-img {
    height: 80px;
    /* More compact size */
    width: auto;
    max-width: 95vw;
    object-fit: contain;
    transition: all 0.3s ease;
    filter: none;
    /* Removed shadow for maximum clarity */
}

.header.scrolled .final-logo-img {
    height: 35px;
}

.header-cart-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 4px;
}

@media (max-width: 768px) {
    :root {
        --header-height: 100px;
    }

    .final-logo-img {
        height: 60px;
    }

    .header.scrolled .final-logo-img {
        height: 30px;
    }
}

/* ===== KOLSHI Logo Styles ===== */
.kolshi-logo {
    display: flex;
    align-items: center;
    font-family: Arial, Helvetica, sans-serif;
    font-weight: 900;
    font-size: 48px;
    color: var(--primary-color, #ff7a00);
    transition: all 0.3s ease;
}

.logo-letter {
    margin: 0 1px;
    transition: all 0.3s ease;
}

.logo-o {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary-color, #ff7a00);
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 4px;
    transition: all 0.3s ease;
}

/* Shopping cart inside O */
.cart {
    width: 30px;
    height: 20px;
    border: 3px solid white;
    border-radius: 4px;
    position: relative;
}

.cart::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 3px;
    width: 20px;
    height: 7px;
    border-top: 3px solid white;
    border-left: 3px solid white;
    border-right: 3px solid white;
    border-radius: 4px 4px 0 0;
}

.wheel {
    position: absolute;
    bottom: -7px;
    width: 7px;
    height: 7px;
    background: white;
    border-radius: 50%;
}

.wheel.left {
    left: 4px;
}

.wheel.right {
    right: 4px;
}

/* Scrolled state - smaller logo */
.header.scrolled .kolshi-logo {
    font-size: 32px;
}

.header.scrolled .logo-o {
    width: 40px;
    height: 40px;
}

.header.scrolled .cart {
    width: 20px;
    height: 14px;
    border: 2px solid white;
}

.header.scrolled .cart::before {
    top: -7px;
    left: 2px;
    width: 14px;
    height: 5px;
    border-top: 2px solid white;
    border-left: 2px solid white;
    border-right: 2px solid white;
}

.header.scrolled .wheel {
    width: 5px;
    height: 5px;
    bottom: -5px;
}

.header.scrolled .wheel.left {
    left: 3px;
}

.header.scrolled .wheel.right {
    right: 3px;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .kolshi-logo {
        font-size: 36px;
    }

    .logo-o {
        width: 48px;
        height: 48px;
    }

    .cart {
        width: 26px;
        height: 18px;
    }

    .cart::before {
        top: -9px;
        left: 2px;
        width: 18px;
        height: 6px;
    }

    .wheel {
        width: 6px;
        height: 6px;
    }

    .header.scrolled .kolshi-logo {
        font-size: 28px;
    }

    .header.scrolled .logo-o {
        width: 36px;
        height: 36px;
    }
}

/* Hover effect */
.logo-container:hover .logo-o {
    transform: rotate(-10deg) scale(1.1);
}

.logo-container:hover .logo-letter {
    transform: translateY(-2px);
}