/* ========================================
   متغيرات CSS - جميع الألوان
   ======================================== */
:root {
    /* الألوان الرئيسية */
    --primary-color: #8b5cf6;      /* بنفسجي */
    --secondary-color: #f97316;    /* برتقالي */
    --accent-color: #ec4899;        /* وردي/بنفسجي فاتح */
    
    /* ألوان النصوص */
    --text-dark: #1f2937;
    --text-gray: #6b7280;
    --text-light: #9ca3af;
    --text-white: #ffffff;
    
    /* ألوان الخلفية */
    --bg-white: #ffffff;
    --bg-light: #f9fafb;
    --bg-gray: #f3f4f6;
    
    /* ألوان الحالة */
    --success: #10b981;
    --error: #ef4444;
    
    /* التدرجات */
    --gradient-primary: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    
    /* الحواف والإحكام */
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    --border-radius-full: 50%;
    
    /* الظلال */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    
    /* الانتقالات */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    
    /* المسافات */
    --header-height: 70px;

    /* الخط — تبدّلو دالة loadGoogleFont() فـ common.js حسب اختيار التاجر */
    --font-family: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans Arabic', sans-serif;
}

/* ========================================
   إعادة تعيين والأنماط الأساسية
   ======================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

button {
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ========================================
   1. شريط إعلاني علوي
   ======================================== */
.announcement-bar {
    background: var(--secondary-color);
    color: var(--text-white);
    text-align: center;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    position: relative;
    z-index: 100;
}

/* ========================================
   2. الهيدر
   ======================================== */
.header {
    background: var(--bg-white);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

/* مكان اللوغو — تُضاف الفئة ديناميكياً من common.js (applyStoreConfig)
   حسب اختيار التاجر فإعدادات → معلومات عامة → مكان اللوغو.
   الصفحة RTL: flex-start = يمين، flex-end = يسار */
.header-container.logo-pos-right .header-center { justify-content: flex-start; }
.header-container.logo-pos-left .header-center { justify-content: flex-end; }
.header-container.logo-pos-center .header-center { justify-content: center; }

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* أيزونات الهيدر */
.icon-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dark);
    transition: background var(--transition-fast), color var(--transition-fast);
    position: relative;
}

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

/* عداد السلة */
.cart-count {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--primary-color);
    color: var(--text-white);
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: var(--border-radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* الشعار */
.store-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-img {
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius-sm);
    object-fit: contain;
    background: var(--bg-gray);
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
}

/* قائمة التصنيفات المنسدلة */
.categories-dropdown {
    position: relative;
}

.dropdown-toggle {
    display: none;
}

.dropdown-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--bg-gray);
    border-radius: var(--border-radius-md);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.dropdown-btn:hover {
    background: var(--bg-light);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-white);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-normal);
    z-index: 60;
}

.dropdown-toggle:checked + .dropdown-btn + .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: block;
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text-dark);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--bg-gray);
    color: var(--primary-color);
}

.dropdown-item:first-child {
    border-radius: var(--border-radius-md) var(--border-radius-md) 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 var(--border-radius-md) var(--border-radius-md);
}

/* قائمة الموبايل */
.mobile-menu {
    display: none;
    background: var(--bg-white);
    border-top: 1px solid var(--bg-gray);
    padding: 16px 20px;
}

.mobile-menu-item {
    display: block;
    padding: 12px 0;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-dark);
    border-bottom: 1px solid var(--bg-gray);
    transition: color var(--transition-fast);
}

.mobile-menu-item:last-child {
    border-bottom: none;
}

.mobile-menu-item:hover {
    color: var(--primary-color);
}

/* ========================================
   2.5 بانر المتجر
   ======================================== */
.store-banner {
    width: 100%;
    max-height: 340px;
    overflow: hidden;
    line-height: 0;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.store-banner img {
    width: 100%;
    height: auto;
    max-height: 340px;
    object-fit: contain;
    display: block;
}

/* ========================================
   3. قسم Hero
   ======================================== */
.hero {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, rgba(249, 115, 22, 0.08) 100%);
    padding: 60px 20px;
    text-align: center;
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
}

.hero-title {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-dark);
    line-height: 1.3;
    margin-bottom: 16px;
}

.hero-title .highlight {
    position: relative;
    display: inline-block;
}

.hero-title .highlight::after {
    content: '';
    position: absolute;
    bottom: -4px;
    right: 0;
    width: 100%;
    height: 4px;
    background: var(--primary-color);
    border-radius: 2px;
}

.hero-description {
    font-size: 16px;
    color: var(--text-gray);
    max-width: 600px;
    margin: 0 auto;
}

/* ========================================
   4. شريط اختيار التصنيفات
   ======================================== */
.categories-section {
    padding: 24px 20px;
    background: var(--bg-white);
    border-top: 1px solid var(--bg-gray);
    border-bottom: 1px solid var(--bg-gray);
}

.categories-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.categories-wrapper::-webkit-scrollbar {
    display: none;
}

.category-card {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-white);
    border: 2px solid var(--bg-gray);
    border-radius: var(--border-radius-lg);
    cursor: pointer;
    transition: all var(--transition-normal);
    min-width: 160px;
}

.category-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.category-card.active {
    border-color: var(--primary-color);
    background: rgba(139, 92, 246, 0.05);
}

/* إخفاء الـ radio button بصرياً */
.category-radio {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.category-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.category-icon-wrapper.all {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: var(--text-white);
}

.category-icon-wrapper.electronics {
    background: #dbeafe;
    color: #2563eb;
}

.category-icon-wrapper.clothing {
    background: #fef3c7;
    color: #d97706;
}

.category-icon-wrapper.home {
    background: #d1fae5;
    color: #059669;
}

.category-icon-wrapper.sports {
    background: #fce7f3;
    color: #db2777;
}

.category-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.category-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
}

.category-hint {
    font-size: 11px;
    color: var(--text-light);
}

/* ========================================
   5. شبكة المنتجات
   ======================================== */
.products-section {
    padding: 32px 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.products-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

/* بطاقة المنتج */
.product-card {
    background: var(--bg-white);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
    position: relative;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.product-image {
    position: relative;
    aspect-ratio: 1;
    background: var(--bg-gray);
    overflow: hidden;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-normal);
}

.product-card:hover .product-image img {
    transform: scale(1.05);
}

.product-placeholder {
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
    color: var(--text-light);
}

.product-info {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.product-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-prices {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.current-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dark);
}

.original-price {
    font-size: 14px;
    color: var(--text-light);
    text-decoration: line-through;
}

/* زر إضافة للسلة */
.add-to-cart-btn {
    position: absolute;
    bottom: 16px;
    left: 16px;
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius-full);
    background: var(--secondary-color);
    color: var(--text-white);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
    opacity: 0;
    transform: scale(0.8);
}

.product-card:hover .add-to-cart-btn {
    opacity: 1;
    transform: scale(1);
}

.add-to-cart-btn:hover {
    background: #ea580c;
    transform: scale(1.1) !important;
}

/* ========================================
   6. الفوتر
   ======================================== */
.footer {
    position: relative;
    margin-top: 60px;
}

.footer-wave {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    transform: translateY(-99%);
    overflow: hidden;
    line-height: 0;
}

.footer-wave svg {
    position: relative;
    display: block;
    width: calc(100% + 1.3px);
    height: 80px;
}

.footer-content {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    padding: 60px 20px 32px;
    text-align: center;
    color: var(--text-white);
}

.footer-social {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 24px;
}

.social-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-full);
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-white);
    transition: all var(--transition-normal);
}

.social-icon:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-3px);
}

.footer-logo {
    margin-bottom: 24px;
}

.footer-logo-box {
    display: inline-block;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius-md);
}

.footer-logo-img {
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-sm);
    background: var(--bg-white);
    object-fit: contain;
}

.footer-about {
    font-size: 13px;
    line-height: 1.8;
    opacity: 0.9;
    max-width: 520px;
    margin: 0 auto 16px;
}

.footer-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.3);
    max-width: 200px;
    margin: 0 auto 20px;
}

.footer-copyright {
    font-size: 14px;
    margin-bottom: 8px;
    opacity: 0.9;
}

.footer-brand {
    font-size: 12px;
    opacity: 0.8;
}

.footer-brand strong {
    font-weight: 700;
}

/* ========================================
   استعلامات الوسائط (Media Queries)
   ======================================== */

/* شاشات أكبر من 480px */
@media (min-width: 480px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .hero-title {
        font-size: 38px;
    }
}

/* شاشات أكبر من 640px */
@media (min-width: 640px) {
    .hero-title {
        font-size: 44px;
    }
    
    .hero-description {
        font-size: 18px;
    }
}

/* شاشات أكبر من 768px (التابلت) */
@media (min-width: 768px) {
    .header-container {
        padding: 12px 32px;
    }
    
    .hero {
        padding: 80px 32px;
    }
    
    .categories-section,
    .products-section {
        padding: 32px;
    }
    
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* شاشات أكبر من 1024px (اللابتوب) */
@media (min-width: 1024px) {
    .hero-title {
        font-size: 52px;
    }
    
    .products-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 24px;
    }
    
    .category-card {
        min-width: 180px;
    }
}

/* شاشات أكبر من 1280px */
@media (min-width: 1280px) {
    .header-container,
    .categories-wrapper,
    .products-section {
        max-width: 1400px;
        margin-left: auto;
        margin-right: auto;
    }
}

/* ========================================
   إخفاء زر القائمة على الشاشات الكبيرة
   ======================================== */
@media (min-width: 768px) {
    .menu-btn {
        display: none;
    }
    
    .mobile-menu {
        display: none !important;
    }
}

/* إظهار زر القائمة على الشاشات الصغيرة */
@media (max-width: 767px) {
    .header-center {
        order: -1;
    }
    
    .header-right .categories-dropdown {
        display: none;
    }
    
    .menu-btn {
        display: flex;
    }
    
    .logo-text {
        font-size: 16px;
    }
    
    .logo-img {
        width: 32px;
        height: 32px;
    }
}

/* ========================================
   تحسينات إضافية للتفاعلات
   ======================================== */

/* تأثير الضغط على بطاقات التصنيف */
.category-card:active {
    transform: scale(0.98);
}

/* تأثير hover على المنتج في الموبايل */
@media (hover: none) {
    .add-to-cart-btn {
        opacity: 1;
        transform: scale(1);
    }
    
    .product-card:hover {
        transform: none;
    }
    
    .product-card:hover .product-image img {
        transform: none;
    }
}

/* ========================================
   أنيميشن بسيط عند التحميل
   ======================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-content {
    animation: fadeInUp 0.6s ease-out;
}

.categories-section {
    animation: fadeInUp 0.6s ease-out 0.1s both;
}

.products-grid .product-card:nth-child(1) { animation: fadeInUp 0.6s ease-out 0.2s both; }
.products-grid .product-card:nth-child(2) { animation: fadeInUp 0.6s ease-out 0.3s both; }
.products-grid .product-card:nth-child(3) { animation: fadeInUp 0.6s ease-out 0.4s both; }
.products-grid .product-card:nth-child(4) { animation: fadeInUp 0.6s ease-out 0.5s both; }

/* ========================================
   إضافات RYADOO — القائمة المتنقلة، البحث،
   مودال المنتج، وفورم الطلب داخل الموقع
   ======================================== */
.mobile-menu.active { display: block; }

.search-box {
    display: none;
    align-items: center;
    gap: 8px;
    background: var(--bg-light);
    border: 1px solid var(--bg-gray);
    border-radius: var(--border-radius-md);
    padding: 6px 12px;
    margin: 0 12px;
    flex: 1;
    max-width: 320px;
}
.search-box.active { display: flex; }
.search-box input {
    border: none;
    background: transparent;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    flex: 1;
    color: var(--text-dark);
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: var(--text-gray);
}

/* ===== نموذج الطلب (تُستعمل فصفحة المنتج product.html) ===== */
.product-checkout-form {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--bg-gray);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.product-checkout-form input,
.product-checkout-form select {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--bg-gray);
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 14px;
    background: var(--bg-white);
    color: var(--text-dark);
}
.product-checkout-form input.error,
.product-checkout-form select.error { border-color: var(--error); }
.product-checkout-delivery-row { display: flex; gap: 16px; font-size: 14px; }
.product-checkout-delivery-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.product-checkout-message { font-size: 13px; min-height: 1em; }
.product-checkout-message.error { color: var(--error); }
.product-checkout-message.success { color: var(--success); }
.product-checkout-confirm-btn {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: var(--border-radius-md);
    background: var(--secondary-color);
    color: var(--text-white);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}
.product-checkout-cancel-btn {
    width: 100%;
    padding: 8px;
    border: none;
    background: transparent;
    color: var(--text-gray);
    font-size: 13px;
    cursor: pointer;
    text-decoration: underline;
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text-dark);
    color: var(--text-white);
    padding: 12px 22px;
    border-radius: var(--border-radius-md);
    font-size: 14px;
    z-index: 1100;
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition-normal);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== COUPON BOX ===== */
.product-coupon-box { margin-bottom: 16px; }
.product-coupon-row { display: flex; gap: 8px; }
.product-coupon-row input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--bg-gray);
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 14px;
}
.product-coupon-row button {
    padding: 0 16px;
    border: 1px solid var(--primary-color);
    background: transparent;
    color: var(--primary-color);
    border-radius: var(--border-radius-sm);
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}
.product-coupon-message { font-size: 13px; margin-top: 6px; min-height: 1em; }
.product-coupon-message.success { color: var(--success); }
.product-coupon-message.error { color: var(--error); }

/* ===== REVIEWS SECTION ===== */
.product-reviews-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--bg-gray);
}
.product-reviews-summary { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-weight: 700; color: var(--text-dark); }
.product-review-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--bg-gray);
    font-size: 14px;
}
.product-review-item .rname { font-weight: 700; color: var(--text-dark); }
.product-review-item .rstars { color: var(--primary-color); letter-spacing: 1px; margin-inline-start: 6px; }
.product-review-item .rcomment { color: var(--text-gray); margin-top: 4px; }
.product-review-empty { font-size: 13px; color: var(--text-light); padding: 8px 0; }
#productReviewForm { margin-top: 16px; }
#productReviewForm h4 { font-size: 15px; margin: 0 0 10px; color: var(--text-dark); }
#productReviewForm input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--bg-gray);
    border-radius: var(--border-radius-sm);
    margin-bottom: 10px;
    font-family: inherit;
    font-size: 14px;
}
.product-star-input { display: flex; gap: 6px; font-size: 22px; cursor: pointer; margin-bottom: 10px; }
.product-star-input span { color: #ddd; transition: color 0.2s; }
.product-star-input span.selected { color: var(--primary-color); }
#productReviewForm button[type="submit"] {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--border-radius-sm);
    background: var(--primary-color);
    color: var(--text-white);
    font-weight: 700;
    cursor: pointer;
}
.product-review-thanks { display: none; color: var(--success); font-size: 13px; margin-top: 8px; }
