/* ==========================================================================
   Alaambra Top Bar CSS - ملف منظم ومُحسن
   ========================================================================== */

/* إعدادات أساسية */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.alaambra-topbar {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.4;
    position: relative;
    z-index: 1000;
}

/* ==========================================================================
   الشريط العلوي
   ========================================================================== */

.top-bar {
    background: linear-gradient(90deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 8px 0;
    font-size: 14px;
    color: #6c757d;
    text-align: center;
    border-bottom: 1px solid #e9ecef;
}

.top-bar-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.sale-info {
    color: #dc3545;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==========================================================================
   الشريط الرئيسي
   ========================================================================== */

.main-header {
    background: white;
    padding: 15px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: relative;
    transition: transform 0.3s ease;
}

.main-header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 0 20px;
}

/* ==========================================================================
   أيقونة القائمة (الجوال فقط)
   ========================================================================== */

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.menu-toggle:hover {
    background-color: #f8f9fa;
}

.hamburger {
    width: 24px;
    height: 24px;
    fill: #495057;
}

/* ==========================================================================
   الشعار
   ========================================================================== */

.logo {
    height: 40px;
    width: auto;
    transition: transform 0.2s ease;
    cursor: pointer;
}

.logo:hover {
    transform: scale(1.05);
}

/* ==========================================================================
   شريط البحث
   ========================================================================== */

.search-container {
    flex: 1;
    max-width: 500px;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 12px 50px 12px 20px;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
    background: #fafbfc;
}

.search-input:focus {
    border-color: #2c5aa0;
    box-shadow: 0 0 0 3px rgba(44, 90, 160, 0.1);
    background: white;
}

.search-input::placeholder {
    color: #6c757d;
}

.search-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.search-btn:hover {
    background-color: rgba(44, 90, 160, 0.1);
}

.search-icon {
    width: 20px;
    height: 20px;
    fill: #6c757d;
}

/* ==========================================================================
   أيقونات الحساب والعربة
   ========================================================================== */

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.cart-info {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

.cart-info:hover {
    background-color: #f8f9fa;
}

.cart-icon {
    width: 24px;
    height: 24px;
    fill: #495057;
}

.cart-count {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    transform: scale(0);
    animation: bounceIn 0.5s ease forwards;
}

@keyframes bounceIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.cart-text {
    font-size: 12px;
    color: #6c757d;
    text-align: center;
    line-height: 1.2;
}

/* ==========================================================================
   شريط التنقل للديسك توب
   ========================================================================== */

.navigation {
    background: white;
    border-top: 1px solid #e9ecef;
    display: block;
}

.nav-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    padding: 0 20px;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 0;
    margin: 0;
    padding: 0;
}

.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 15px 20px;
    text-decoration: none;
    color: #495057;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background: #2c5aa0;
    transition: all 0.3s ease;
}

.nav-link:hover {
    color: #2c5aa0;
    background-color: #f8f9fa;
}

.nav-link:hover::after {
    width: 80%;
    left: 10%;
}

.shipping-badge {
    margin-left: auto;
    background: linear-gradient(135deg, #2c5aa0 0%, #1e3f6f 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(44, 90, 160, 0.3);
}

.shipping-icon {
    width: 16px;
    height: 16px;
    fill: white;
}

/* ==========================================================================
   القائمة المنبثقة للجوال
   ========================================================================== */

.mobile-menu {
    position: fixed;
    top: 0;
    left: -100%;
    width: 280px;
    height: 100vh;
    background: white;
    z-index: 9999;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

.mobile-menu.active {
    left: 0;
}

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-menu-header {
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

.mobile-menu-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.mobile-menu-close:hover {
    background-color: #e9ecef;
}

.close-icon {
    width: 24px;
    height: 24px;
    fill: #495057;
}

.mobile-menu-items {
    padding: 20px 0;
}

.mobile-menu-item {
    display: block;
    padding: 15px 20px;
    text-decoration: none;
    color: #495057;
    font-weight: 500;
    border-bottom: 1px solid #f8f9fa;
    transition: all 0.2s ease;
    position: relative;
}

.mobile-menu-item:hover {
    background-color: #f8f9fa;
    color: #2c5aa0;
    padding-left: 25px;
}

.mobile-menu-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: #2c5aa0;
    transition: width 0.2s ease;
}

.mobile-menu-item:hover::before {
    width: 4px;
}

.mobile-shipping {
    margin: 20px;
    background: linear-gradient(135deg, #2c5aa0 0%, #1e3f6f 100%);
    color: white;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* ==========================================================================
   قائمة اللغات
   ========================================================================== */

.language-selector {
    position: absolute;
    top: 10px;
    right: 20px;
    z-index: 1000;
}

.language-dropdown {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    font-size: 12px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.2s ease;
}

.language-dropdown:hover {
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.language-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 120px;
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.language-dropdown.active .language-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.language-item {
    display: block;
    padding: 10px 15px;
    text-decoration: none;
    color: #495057;
    transition: background-color 0.2s ease;
    font-size: 13px;
}

.language-item:hover {
    background-color: #f8f9fa;
    color: #2c5aa0;
}

.language-item:first-child {
    border-radius: 8px 8px 0 0;
}

.language-item:last-child {
    border-radius: 0 0 8px 8px;
}

/* ==========================================================================
   دعم RTL للعربية
   ========================================================================== */

[dir="rtl"] .search-btn {
    right: auto;
    left: 15px;
}

[dir="rtl"] .cart-count {
    right: auto;
    left: 2px;
}

[dir="rtl"] .mobile-menu {
    left: auto;
    right: -100%;
}

[dir="rtl"] .mobile-menu.active {
    right: 0;
    left: auto;
}

[dir="rtl"] .language-selector {
    right: auto;
    left: 20px;
}

[dir="rtl"] .language-menu {
    right: auto;
    left: 0;
}

[dir="rtl"] .shipping-badge {
    margin-left: 0;
    margin-right: auto;
}

[dir="rtl"] .nav-link:hover {
    padding-right: 25px;
    padding-left: 20px;
}

[dir="rtl"] .mobile-menu-item:hover {
    padding-right: 25px;
    padding-left: 20px;
}

[dir="rtl"] .mobile-menu-item::before {
    left: auto;
    right: 0;
}

/* ==========================================================================
   التجاوب مع الشاشات الصغيرة
   ========================================================================== */

@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .navigation {
        display: none;
    }

    .main-header-content {
        gap: 15px;
        padding: 0 15px;
    }

    .logo {
        height: 35px;
    }

    .search-container {
        order: 3;
        flex-basis: 100%;
        margin-top: 10px;
        max-width: none;
    }

    .header-actions {
        gap: 10px;
    }

    .cart-text {
        display: none;
    }

    .top-bar {
        font-size: 12px;
        padding: 5px 0;
    }

    .top-bar-content {
        padding: 0 15px;
    }

    .language-selector {
        top: 5px;
        right: 15px;
    }

    [dir="rtl"] .language-selector {
        right: auto;
        left: 15px;
    }
}

@media (max-width: 480px) {
    .main-header-content {
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .search-container {
        margin-top: 15px;
    }

    .mobile-menu {
        width: 100%;
        left: -100%;
    }

    [dir="rtl"] .mobile-menu {
        right: -100%;
        left: auto;
    }

    .logo {
        height: 30px;
    }

    .sale-info {
        font-size: 12px;
    }
}

/* ==========================================================================
   تحسينات الأداء والتأثيرات
   ========================================================================== */

.will-change {
    will-change: transform, opacity;
}

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

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

/* تحسين الخطوط */
.alaambra-topbar {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* تحسين الأداء للرسوم المتحركة */
.nav-link,
.mobile-menu-item,
.cart-info,
.menu-toggle,
.search-btn {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Focus states للأشخاص الذين يستخدمون الكيبورد */
.menu-toggle:focus,
.search-btn:focus,
.mobile-menu-close:focus {
    outline: 2px solid #2c5aa0;
    outline-offset: 2px;
}

.nav-link:focus,
.mobile-menu-item:focus,
.language-item:focus {
    outline: 2px solid #2c5aa0;
    outline-offset: -2px;
}

/* حماية من الأخطاء */
.alaambra-topbar * {
    max-width: 100%;
}

.alaambra-topbar img {
    height: auto;
    max-width: 100%;
}

/* طباعة */
@media print {
    .alaambra-topbar {
        display: none;
    }
}