/*
Theme Name: AAMFIX OEM
Theme URI: https://aamfix.com
Author: AAMFIX
Author URI: https://aamfix.com
Description: ثيم ووردبريس لعرض منتجات أفلييت AliExpress، بنفس هوية تصميم AAMFIX OEM (وضع ليلي/نهاري، دعم كامل للعربية والإنجليزية RTL/LTR، فيديوهات تيك توك).
Version: 2.6.6
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: LICENSE
Text Domain: aamfix-oem
Tags: e-commerce, affiliate, rtl-language-support, translation-ready, custom-colors, custom-logo, custom-menu, featured-images, threaded-comments, footer-widgets, grid-layout

AAMFIX OEM WordPress Theme is released under the terms of GNU GPL v2 or later.
*/

/* ============================================================
   1. الخطوط
   ============================================================ */
@font-face {
    font-family: 'Segoe UI';
    src: local('Segoe UI'), local('SegoeUI'), local('Segoe UI Variable');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Segoe UI Arabic';
    src: local('Segoe UI Arabic'), local('Segoe UI Variable Display');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ============================================================
   2. المتغيرات (CSS Custom Properties) - قابلة للتعديل من Customizer
   ============================================================ */
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --primary-gradient: linear-gradient(135deg, #4f46e5, #7c3aed);

    --secondary: #64748b;
    --secondary-dark: #475569;
    --secondary-light: #f1f5f9;

    --success: #059669;
    --success-light: #ecfdf5;

    --danger: #dc2626;
    --danger-light: #fef2f2;

    --warning: #f59e0b;
    --warning-light: #fffbeb;

    --info: #0284c7;
    --info-light: #f0f9ff;
    --info-border: #3b82f6;

    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --bg-input: #f1f5f9;
    --bg-hover: #f1f5f9;
    --bg-nav: rgba(255, 255, 255, 0.92);

    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #94a3b8;

    --border: #e2e8f0;
    --border-focus: #4f46e5;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 24px rgba(79, 70, 229, 0.08);
    --shadow-lg: 0 8px 40px rgba(79, 70, 229, 0.12);
    --shadow-xl: 0 16px 64px rgba(79, 70, 229, 0.16);

    --radius: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);

    --font-ar: 'Segoe UI Arabic', 'Segoe UI', 'Tahoma', sans-serif;
    --font-en: 'Segoe UI', 'Segoe UI Variable', 'Helvetica Neue', Arial, sans-serif;

    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;
}

/* ============================================================
   3. الوضع المظلم (Dark Mode)
   ============================================================ */
[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #0f172a;
    --bg-hover: #2d3748;
    --bg-nav: rgba(15, 23, 42, 0.95);

    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;

    --border: #334155;
    --border-focus: #818cf8;

    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 16px 64px rgba(0, 0, 0, 0.6);

    --primary-light: #312e81;
    --secondary-light: #1e293b;

    --success-light: #064e3b;
    --danger-light: #450a0a;
    --warning-light: #451a03;
    --info-light: #0c4a6e;
    --info-border: #60a5fa;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; overflow-x: hidden; }

body {
    font-family: var(--font-en);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition);
    overflow-x: hidden;
}

html[lang="ar"] body,
body.rtl { font-family: var(--font-ar); }

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }

.screen-reader-text { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(1px, 1px, 1px, 1px); }

.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }

/* ============================================================
   5. شريط التنقل - مطابق تماماً لـ oemv3
   ============================================================ */
.navbar {
    background: var(--bg-nav);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    position: sticky; top: 0; z-index: 1000;
    transition: var(--transition-slow);
}

.navbar-inner {
    max-width: 1200px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap;
}

.navbar-left { flex: 0 0 auto; display: flex; align-items: center; gap: 24px; }

.logo {
    display: flex; align-items: center; gap: 0.6rem;
    font-size: var(--font-size-lg); font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    text-decoration: none;
}
.logo-icon {
    width: 38px; height: 38px; background: var(--primary-gradient);
    border-radius: var(--radius); display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: var(--font-size-lg); flex-shrink: 0; -webkit-text-fill-color: #fff;
    object-fit: cover;
}
.site-logo img { border-radius: var(--radius); }

.main-nav { display: flex; align-items: center; gap: 4px; }
.main-nav a {
    padding: 8px 14px; border-radius: var(--radius); font-weight: 500;
    color: var(--text-secondary); transition: var(--transition);
}
.main-nav a:hover, .main-nav .current-menu-item > a { color: var(--primary); background: var(--primary-light); }

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

.nav-social-links { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }
.nav-social-links a {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.2rem 0.8rem 0.2rem 0.6rem; border-radius: var(--radius-full);
    color: var(--text-muted); background: var(--bg-input); border: 1px solid var(--border);
    text-decoration: none; transition: var(--transition);
    font-size: var(--font-size-xs); font-weight: 500;
}
[dir="rtl"] .nav-social-links a { padding: 0.2rem 0.6rem 0.2rem 0.8rem; }
.nav-social-links a:hover { color: var(--primary); background: var(--primary-light); border-color: var(--primary); transform: translateY(-2px); }
.nav-social-icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-social-label { display: none; font-size: var(--font-size-xs); color: var(--text-muted); font-weight: 500; }
@media (min-width: 900px) { .nav-social-label { display: inline; } }

.navbar-right { flex: 0 0 auto; display: flex; align-items: center; gap: 0.6rem; }

/* حاوية مبدّل اللغة من إضافة Weglot - محاذاة رأسية فقط، تصميم القائمة نفسه يُدار من إعدادات Weglot */
.weglot-switcher-wrap { display: flex; align-items: center; }

.theme-toggle,
.lang-switcher-btn,
.menu-toggle {
    padding: 0.4rem 1rem; border: 2px solid var(--border); border-radius: var(--radius-full);
    background: var(--bg-input); color: var(--text-secondary); font-weight: 600;
    font-size: var(--font-size-sm); cursor: pointer; transition: var(--transition);
    font-family: inherit; min-height: 40px;
}
.theme-toggle:hover,
.lang-switcher-btn:hover,
.menu-toggle:hover {
    border-color: var(--primary); color: var(--primary);
    transform: translateY(-2px); box-shadow: 0 4px 16px rgba(79, 70, 229, 0.15);
}
.theme-toggle, .menu-toggle { font-size: var(--font-size-lg); padding: 0.4rem 0.8rem; display: flex; align-items: center; justify-content: center; }

.lang-switcher { position: relative; }
.lang-switcher-btn { min-width: 70px; display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap; }
.lang-switcher-btn[aria-expanded="true"] { border-color: var(--primary); color: var(--primary); }

.lang-switcher-menu {
    position: absolute; top: calc(100% + 0.5rem); inset-inline-end: 0;
    min-width: 180px; max-height: 320px; overflow-y: auto;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18); margin: 0; padding: 0.4rem;
    z-index: 200; display: none; flex-direction: column; gap: 0.15rem;
}
.lang-switcher-menu.open { display: flex; }
.lang-switcher-menu a {
    display: block; padding: 0.5rem 0.7rem; border-radius: 8px;
    color: var(--text-secondary); text-decoration: none;
    font-size: var(--font-size-sm); font-weight: 500; transition: var(--transition);
}
.lang-switcher-menu a:hover { background: var(--primary-light); color: var(--primary); }
.lang-switcher-menu a.active { background: var(--primary); color: #fff; font-weight: 700; }

@media (max-width: 900px) {
    .menu-toggle { display: flex; }
    .main-nav { display: none; }
    .main-nav.open {
        display: flex; flex-direction: column; align-items: stretch; gap: 4px;
        position: absolute; top: 100%; inset-inline-start: 0; inset-inline-end: 0;
        background: var(--bg-card); border-bottom: 1px solid var(--border);
        padding: 12px 20px; box-shadow: var(--shadow-lg);
        max-height: calc(100vh - 100%); overflow-y: auto;
    }
    .main-nav.open a { display: block; width: 100%; padding: 12px 14px; }
    .nav-social-links { display: none; }
}
@media (min-width: 901px) { .menu-toggle { display: none; } }

/* ============================================================
   6. الأزرار - مطابقة تماماً لـ oemv3
   ============================================================ */
.btn {
    padding: 0.65rem 1.4rem; font-size: var(--font-size-sm);
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    border-radius: var(--radius); font-weight: 700; transition: var(--transition);
    cursor: pointer; border: none; font-family: inherit; white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06); text-decoration: none;
}
.btn-primary { background: var(--primary-gradient); color: #fff; box-shadow: 0 3px 12px rgba(79, 70, 229, 0.28); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(79, 70, 229, 0.35); }
.btn-success { background: var(--success); color: #fff; box-shadow: 0 3px 12px rgba(5, 150, 105, 0.28); }
.btn-success:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(5, 150, 105, 0.35); }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); box-shadow: none; }
.btn-outline:hover:not(:disabled) { background: var(--primary); color: #fff; transform: translateY(-2px); box-shadow: 0 4px 16px rgba(79, 70, 229, 0.25); }
.btn-sm { padding: 0.35rem 1rem; font-size: var(--font-size-xs); }
.btn-lg { padding: 0.9rem 1.8rem; font-size: var(--font-size-base); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ============================================================
   6.1 شريط الروابط الخارجية (بديل قسم الترحيب في الصفحة الرئيسية)
   ============================================================ */
.links-bar { padding: 0.9rem 0; }
.links-bar-inner { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.links-bar-item {
    position: relative;
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-weight: 600; font-size: var(--font-size-xs);
    transition: var(--transition);
}

.links-bar-dot {
    width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
    background: var(--primary-gradient);
    transition: var(--transition);
}

.links-bar-arrow {
    display: inline-flex; align-items: center; justify-content: center;
    opacity: 0.6;
    transition: var(--transition);
}

.links-bar-item:hover {
    background: var(--primary-light); color: var(--primary); border-color: var(--primary);
    transform: translateY(-1px);
}
.links-bar-item:hover .links-bar-arrow { opacity: 1; }

/* شارة اللون بين القوسين (مجاني/مدفوع/إلخ) - بخلفية لونية كاملة مطابقة لألوان oemv3 */
.lb-tag {
    display: inline-block; font-size: 10px; font-weight: 800; color: #fff;
    padding: 2px 8px; border-radius: var(--radius-full); line-height: 1.5; background: var(--text-muted);
}
.lb-tag.lb-green { background: var(--success); }
.lb-tag.lb-orange { background: var(--warning); }
.lb-tag.lb-blue { background: var(--info); }
.lb-tag.lb-red { background: var(--danger); }

/* ============================================================
   7. شبكة المنتجات
   ============================================================ */
.section { padding: 48px 0; }
/* تقليل المسافة بين الشريط العلوي (links-bar) وأول قسم منتجات يليه مباشرة في الصفحة الرئيسية */
.links-bar + .section { padding-top: 14px; }
.links-bar + .section .product-card-frame { margin-top: 0; }
.section-title { font-size: var(--font-size-2xl); font-weight: 800; margin-bottom: 24px; text-align: center; }

.section-header {
    display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
    margin-bottom: 22px;
}
.section-header .section-heading { font-size: var(--font-size-2xl); font-weight: 800; }
.section-header .section-heading span { display: block; font-size: var(--font-size-sm); font-weight: 500; color: var(--text-muted); margin-top: 2px; }
.section-view-all {
    display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
    font-size: var(--font-size-sm); font-weight: 700; color: var(--primary);
    padding: 6px 4px; transition: var(--transition);
}
.section-view-all svg { transition: transform .2s ease; }
.section-view-all:hover { gap: 9px; }
[dir="rtl"] .section-view-all svg { transform: scaleX(-1); }

.products-grid {
    display: grid; gap: 14px;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
}

.product-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); overflow: hidden;
    box-shadow: var(--shadow-sm); transition: var(--transition);
    display: flex; flex-direction: column; position: relative;
}
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--primary-light); }

.product-card-media { position: relative; aspect-ratio: 1 / 1; background: var(--bg-input); overflow: hidden; }
.product-card-media img { width: 100%; height: 100%; object-fit: cover; transition: var(--transition-slow); }
.product-card:hover .product-card-media img { transform: scale(1.08); }

.product-badge {
    position: absolute; top: 8px; inset-inline-start: 8px;
    background: var(--primary-gradient); color: #fff; font-size: 10px;
    font-weight: 700; padding: 3px 8px; border-radius: var(--radius-full); z-index: 2;
    letter-spacing: .01em;
}
.product-badge.badge-sale { background: var(--danger); }
.product-badge.badge-video {
    position: absolute; bottom: 8px; inset-inline-end: 8px; top: auto; inset-inline-start: auto;
    background: rgba(0,0,0,.6); backdrop-filter: blur(4px); font-size: 10px;
}

.product-card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-card-title {
    font-size: var(--font-size-sm); line-height: 1.4; font-weight: 600; color: var(--text-primary);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    min-height: 2.6em;
}
.product-card-rating { display: flex; align-items: center; gap: 4px; font-size: var(--font-size-xs); color: var(--text-muted); }
.product-card-rating .stars { color: var(--warning); font-size: var(--font-size-xs); }

.product-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: auto; }
.product-card-price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px; min-width: 0; }
.price-current { font-size: var(--font-size-base); font-weight: 800; color: var(--primary); white-space: nowrap; }
.price-old { font-size: var(--font-size-xs); color: var(--text-muted); text-decoration: line-through; white-space: nowrap; }
.price-discount { font-size: 10px; font-weight: 700; color: var(--danger); background: var(--danger-light); padding: 2px 5px; border-radius: 6px; }

.product-card-arrow {
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--primary-gradient); color: #fff;
    box-shadow: 0 3px 10px rgba(79, 70, 229, 0.30); transition: var(--transition);
}
.product-card-arrow:hover { transform: scale(1.1); box-shadow: 0 5px 16px rgba(79, 70, 229, 0.4); }
[dir="rtl"] .product-card-arrow svg { transform: scaleX(-1); }

@media (max-width: 480px) {
    .products-grid { grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 10px; }
    .product-card-body { padding: 8px 10px 10px; }
}

/* شبكة "منتجات أنصح فيها" في الصفحة الرئيسية - أول منتج (المميز) يظهر بحجم مضاعف */
.products-grid.products-grid--spotlight { grid-template-columns: repeat(4, 1fr); }
.products-grid--spotlight .product-card:first-child { grid-column: span 2; grid-row: span 2; }
.products-grid--spotlight .product-card:first-child .product-card-media {
    aspect-ratio: auto; height: 100%; min-height: 260px;
}
.products-grid--spotlight .product-card:first-child .product-card-title {
    font-size: var(--font-size-base); -webkit-line-clamp: 3; min-height: 3.9em;
}
@media (max-width: 900px) {
    .products-grid.products-grid--spotlight { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .products-grid--spotlight .product-card:first-child { grid-row: span 1; }
    .products-grid--spotlight .product-card:first-child .product-card-media { min-height: 0; height: auto; aspect-ratio: 1 / 1; }
}

/* ============================================================
   7.1 زر المفضلة (❤) - على بطاقة المنتج وصفحة المنتج المفردة
   ============================================================ */
.favorite-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--bg-input); border: 1.5px solid var(--border);
    color: var(--text-secondary); cursor: pointer; transition: var(--transition);
    flex-shrink: 0;
}
.favorite-btn:hover { border-color: var(--danger); color: var(--danger); }
.favorite-btn .favorite-btn-icon { fill: none; stroke: currentColor; stroke-width: 2; transition: var(--transition); }
.favorite-btn.active { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }
.favorite-btn.active .favorite-btn-icon { fill: currentColor; }
.favorite-btn.bump { animation: aamfix-favorite-bump 0.3s ease; }
@keyframes aamfix-favorite-bump {
    0% { transform: scale(1); }
    40% { transform: scale(1.25); }
    100% { transform: scale(1); }
}

/* داخل بطاقة المنتج: زر دائري عائم فوق الصورة بالزاوية المقابلة للشارات */
.product-card > .favorite-btn {
    position: absolute; top: 10px; inset-inline-end: 10px; z-index: 3;
    width: 34px; height: 34px;
    background: rgba(255, 255, 255, 0.9); border-color: transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
[data-theme="dark"] .product-card > .favorite-btn { background: rgba(30, 41, 59, 0.85); }
.product-card > .favorite-btn.active { background: var(--danger-light); }

/* ============================================================
   7.2 أزرار المشاركة وصف الإجراءات في صفحة المنتج المفردة
   ============================================================ */
.product-actions-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 20px; }
.product-info > .product-actions-row:last-child { margin-bottom: 0; }

.share-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.share-buttons-label { font-size: var(--font-size-sm); color: var(--text-muted); font-weight: 600; margin-inline-end: 2px; }
.share-btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.55rem 1rem; border-radius: var(--radius-full);
    background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text-secondary); font-size: var(--font-size-sm); font-weight: 600;
    transition: var(--transition);
}
.share-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.share-btn-whatsapp:hover { background: #25d366; border-color: #25d366; color: #fff; }
.share-btn-email:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.share-btn-icon { width: 18px; height: 18px; }

/* رابط المفضلة في الهيدر */
.nav-favorites-link { position: relative; }
.nav-favorites-count {
    position: absolute; top: -4px; inset-inline-end: -4px;
    min-width: 16px; height: 16px; padding: 0 3px;
    align-items: center; justify-content: center;
    background: var(--danger); color: #fff; border-radius: var(--radius-full);
    font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}

/* بلاطات التصنيفات (الصفحة الرئيسية) */
.section-alt { background: var(--bg-card); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

.category-tiles {
    display: grid; gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}
.category-tile {
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
    padding: 18px 10px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); transition: var(--transition);
}
.category-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: transparent; }
.category-tile-icon {
    width: 44px; height: 44px; border-radius: 50%; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: var(--font-size-lg);
}
.category-tile-name { font-size: var(--font-size-sm); font-weight: 700; color: var(--text-primary); }
.category-tile-count { font-size: var(--font-size-xs); color: var(--text-muted); }

/* فلاتر الأرشيف */
.archive-toolbar {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
    margin-bottom: 22px; padding: 1rem 1.3rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.archive-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.archive-filters a, .archive-filters select {
    padding: 0.3rem 1rem; border-radius: var(--radius-full); background: var(--bg-input);
    color: var(--text-secondary); font-size: var(--font-size-sm); font-weight: 500; border: 1px solid var(--border);
    transition: var(--transition);
}
.archive-filters a.active, .archive-filters a:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); transform: translateY(-2px); }
.archive-sort select {
    padding: 0.55rem 1rem; min-height: 40px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--bg-card); color: var(--text-secondary);
    font-size: var(--font-size-sm); font-family: inherit;
}

/* ============================================================
   8. صفحة المنتج المفردة
   ============================================================ */
/* إطار المنتج الموحّد - يجمع المعرض والمعلومات والوصف داخل بطاقة واحدة (بأسلوب .search-card في oemv3) */
.product-card-frame {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); overflow: hidden; position: relative; margin: 28px 0;
}
.product-card-frame::before {
    content: ''; position: absolute; top: 0; inset-inline-start: 0; inset-inline-end: 0;
    height: 4px; background: var(--primary-gradient);
}
.product-card-frame-pad { padding: 24px; }

/* استخدام البطاقة الموحّدة كإطار لأقسام الصفحة الرئيسية (التصنيفات/المنتجات المميزة) */
.product-card-frame > .section-header { padding: 24px 24px 0; }
.product-card-frame > .category-tiles,
.product-card-frame > .products-grid { padding: 20px 24px 24px; }
@media (max-width: 480px) {
    .product-card-frame > .section-header { padding: 18px 16px 0; }
    .product-card-frame > .category-tiles,
    .product-card-frame > .products-grid { padding: 16px 16px 18px; }
}

.product-tabs-nav { display: flex; gap: 4px; padding: 0 24px; border-bottom: 1px solid var(--border); scroll-margin-top: 90px; }
.product-tabs-nav .tab {
    padding: 12px 16px; font-size: var(--font-size-sm); font-weight: 700; color: var(--text-muted);
    border-bottom: 2px solid transparent; margin-bottom: -1px; transition: var(--transition);
}
.product-tabs-nav .tab.active { color: var(--primary); border-color: var(--primary); }
.product-tabs-nav a.tab:hover { color: var(--primary); cursor: pointer; }

.product-price-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.product-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.product-info > .product-cats:first-child { margin-top: 0; margin-bottom: 14px; }
.product-cats a {
    font-size: var(--font-size-xs); background: var(--bg-input); color: var(--text-secondary);
    padding: 4px 10px; border-radius: var(--radius-full); border: 1px solid var(--border); transition: var(--transition);
}
.product-cats a:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-light); }

.product-single { display: grid; grid-template-columns: 1fr; gap: 28px; }
@media (min-width: 900px) { .product-single { grid-template-columns: 0.85fr 1.15fr; } }
/* بدون min-width:0 يمنع Grid عمود الصور من الانكماش عن العرض الثابت 340px لصندوق
   الفيديو، فيطفح خارج الشاشات الضيقة (يقصّه من جهة ويُخفي السهم/الأزرار) */
.product-gallery-column { min-width: 0; }

/* معرض المنتج - فيديو أولاً بأسلوب AliExpress + صور مصغّرة (بحجم مضبوط، غير مبالغ فيه) */
.product-viewer-wrap { position: relative; width: 340px; max-width: 100%; margin: 0 auto 12px; }
/* فيديو TikTok فقط يحتاج حجمه الطبيعي الحر بدل المربّع الثابت 340px - انظر .product-viewer-free أدناه */
.product-viewer-wrap:has(.product-viewer-free) { width: fit-content; }
.product-viewer {
    position: relative; border-radius: var(--radius-lg); overflow: hidden;
    background: #0f172a; aspect-ratio: 1/1; display: flex; align-items: center; justify-content: center;
    margin: 0; max-width: 340px;
}
.product-viewer img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* أسهم التنقّل + عداد "١ / ٦" فوق المعرض - تعمل مع الصور والفيديو وTikTok معاً */
.gallery-nav-btn {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 3;
    width: 34px; height: 34px; border-radius: 50%; border: none;
    background: rgba(255, 255, 255, 0.92); color: var(--text-primary); box-shadow: var(--shadow-sm);
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    transition: var(--transition); font-size: 17px; line-height: 1;
}
.gallery-nav-btn:hover { background: #fff; transform: translateY(-50%) scale(1.08); }
.gallery-nav-prev { inset-inline-start: 10px; }
.gallery-nav-next { inset-inline-end: 10px; }
@media (hover: hover) and (pointer: fine) {
    .gallery-nav-btn { opacity: 0; }
    .product-viewer-wrap:hover .gallery-nav-btn { opacity: 1; }
}
.gallery-nav-btn:focus-visible { opacity: 1; }
.gallery-counter {
    position: absolute; bottom: 10px; inset-inline-end: 10px; z-index: 3;
    background: rgba(15, 23, 42, 0.65); color: #fff; font-size: 11px; font-weight: 700;
    padding: 3px 9px; border-radius: var(--radius-full); font-variant-numeric: tabular-nums;
}
@media (prefers-reduced-motion: reduce) { .gallery-nav-btn { transition: none !important; } }
.product-viewer video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }

.video-frame { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.video-frame-poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.55; }
.play-btn {
    position: relative; z-index: 2;
    width: 64px; height: 64px; border-radius: 50%;
    background: rgba(255, 255, 255, 0.15); backdrop-filter: blur(6px);
    border: 2px solid rgba(255, 255, 255, 0.6);
    display: flex; align-items: center; justify-content: center;
    color: #fff; cursor: pointer; transition: var(--transition);
}
.play-btn:hover { transform: scale(1.08); background: rgba(255, 255, 255, 0.25); }
.play-btn svg { margin-inline-start: 3px; }
.video-badge-corner {
    position: absolute; top: 10px; inset-inline-start: 10px; z-index: 2;
    background: var(--primary-gradient); color: #fff; font-size: var(--font-size-xs); font-weight: 700;
    padding: 4px 10px; border-radius: var(--radius-full); display: flex; align-items: center; gap: 4px;
}

.gallery-thumbs { display: flex; gap: 10px; flex-wrap: wrap; max-width: 340px; margin: 0 auto; justify-content: center; }
.thumb {
    position: relative; width: 64px; height: 64px; border-radius: var(--radius);
    overflow: hidden; cursor: pointer; border: 2px solid var(--border);
    background: var(--bg-input); flex-shrink: 0; transition: var(--transition);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.active, .thumb:hover { border-color: var(--primary); }
.thumb-video-mark {
    position: absolute; inset: 0; background: rgba(15, 23, 42, 0.55);
    display: flex; align-items: center; justify-content: center; color: #fff;
}
.thumb-tiktok-mark {
    position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 9px; font-weight: 800; letter-spacing: 0.02em;
}

/* الحجم الثابت (المربّع) يبقى خاصاً بروابط mp4 والصور فقط. فيديو TikTok يُلغي هذا القيد
   تماماً ويأخذ حجمه الطبيعي الحر بالكامل بدون أي قصّ أو تحديد نسبة أبعاد مسبقة منّا. */
.product-viewer-free {
    aspect-ratio: auto; max-width: none; width: auto; height: auto;
    background: transparent; display: block; overflow: visible;
}
.tiktok-embed-wrap { display: flex; justify-content: center; border-radius: var(--radius-lg); overflow: visible; }
.tiktok-embed-wrap blockquote.tiktok-embed { margin: 0 auto !important; }

.product-info h1 { font-size: var(--font-size-xl); font-weight: 800; margin-bottom: 10px; line-height: 1.4; }
.product-info .product-card-rating {
    display: inline-flex; align-items: center; gap: 8px; margin-bottom: 14px;
    font-size: var(--font-size-sm); font-weight: 700; color: var(--text-primary);
    background: var(--warning-light); border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: var(--radius-full); padding: 6px 14px; width: fit-content;
}
.product-info .product-card-rating .stars { font-size: 13px; letter-spacing: 1px; }
.product-price-box-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.product-price-row .price-current { font-size: var(--font-size-2xl); color: var(--primary); font-weight: 800; }
.product-price-save {
    display: inline-flex; align-items: center; gap: 5px; margin-bottom: 14px;
    font-size: var(--font-size-sm); font-weight: 700; color: var(--success);
    background: var(--success-light); padding: 5px 10px; border-radius: var(--radius-full);
}

.product-buy-btn {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 16px; background: var(--primary-gradient); color: #fff;
    border-radius: var(--radius-lg); font-weight: 800; font-size: var(--font-size-lg);
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.30); transition: var(--transition); margin-bottom: 14px;
    letter-spacing: 0.02em;
}
.product-buy-btn:hover { transform: translateY(-3px); box-shadow: 0 8px 32px rgba(79, 70, 229, 0.40); }

.product-trust-badges {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px;
}
.trust-badge {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 0.7rem 0.4rem; text-align: center; box-shadow: var(--shadow-sm); transition: var(--transition);
}
.trust-badge:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.trust-badge-icon { display: block; font-size: var(--font-size-lg); margin-bottom: 4px; line-height: 1; }
.trust-badge-text { display: block; font-size: var(--font-size-xs); font-weight: 600; color: var(--text-secondary); line-height: 1.3; }

.product-section-heading {
    font-size: var(--font-size-lg); font-weight: 800; color: var(--text-primary);
    margin-bottom: 10px; padding-bottom: 10px; border-bottom: 2px solid var(--border);
}
.product-description { color: var(--text-secondary); line-height: 1.8; max-width: 100%; overflow-x: auto; }
/* بعض أوصاف AliExpress المنسوخة تتبع نمط "فقرة تبدأ بعنوان عريض" (مثال: "١. عنوان: نص...")
   نبرزه كعنوان فرعي صغير بدل أن يبقى مطموساً داخل سطر النص العادي - بدون أي تغيير في المحتوى نفسه */
.product-description p > b:first-child { display: block; color: var(--text-primary); font-size: var(--font-size-base); margin-bottom: 4px; }
/* وصف AliExpress المنسوخ غالباً يحتوي صوراً/جداول بعرض ثابت بالبكسل (سمات HTML
   أو أنماط inline)، تتجاوز عرض الشاشة على الهاتف رغم قاعدة img { max-width:100% }
   العامة (لأن السمات inline لها أولوية أعلى) - نفرض هذا صراحةً هنا فقط */
.product-description img { max-width: 100% !important; width: auto !important; height: auto !important; }
.product-description table { max-width: 100%; display: block; overflow-x: auto; }
.product-description iframe, .product-description video { max-width: 100%; }
/* ============================================================
   التنبيهات (Alerts) - مطابقة تماماً لعنصر .alert في oemv3
   ============================================================ */
.alert {
    padding: 0.8rem 1rem; border-radius: var(--radius); margin-bottom: 0.8rem;
    font-size: var(--font-size-sm); border-inline-start: 4px solid transparent;
    display: flex; align-items: flex-start; gap: 0.6rem;
}
.alert-info { background: var(--info-light); color: var(--text-secondary); border-color: var(--info-border); }
.alert-success { background: var(--success-light); color: var(--text-secondary); border-color: var(--success); }
.alert-danger { background: var(--danger-light); color: var(--text-secondary); border-color: var(--danger); }
.alert-warning { background: var(--warning-light); color: var(--text-secondary); border-color: var(--warning); }
.alert-icon { flex-shrink: 0; line-height: 1.4; }

.aamfix-sb-disabled-alert { font-size: var(--font-size-base); }
.aamfix-sb-disabled-alert .alert-icon { font-size: var(--font-size-lg); }

.affiliate-disclaimer { margin-top: 20px; }

/* ============================================================
   جداول البيانات (مواصفات المنتج) - مطابقة تماماً لـ .table-wrapper في oemv3/admin
   ============================================================ */
.table-wrapper {
    background: var(--bg-card); border-radius: var(--radius-lg); border: 1px solid var(--border);
    overflow: hidden; box-shadow: var(--shadow); margin: 0.5rem 0; overflow-x: auto;
}
.table-wrapper table { width: 100%; border-collapse: collapse; font-size: var(--font-size-sm); }
.table-wrapper th {
    background: var(--bg-hover); padding: 0.6rem 1rem; text-align: start; font-weight: 600;
    border-bottom: 2px solid var(--border); color: var(--text-secondary);
    font-size: var(--font-size-xs); text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
.table-wrapper td { padding: 0.5rem 1rem; border-bottom: 1px solid var(--border); color: var(--text-secondary); vertical-align: middle; }
.table-wrapper tr:last-child td { border-bottom: none; }
.table-wrapper tr:hover td { background: var(--bg-hover); }

/* شريط الشراء اللاصق على الجوال */
.mobile-sticky-buy {
    display: none; position: fixed; bottom: 0; inset-inline-start: 0; inset-inline-end: 0; z-index: 500;
    align-items: center; gap: 12px; padding: 10px 16px;
    background: var(--bg-card); border-top: 1px solid var(--border);
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.08);
    transform: translateY(100%); transition: transform .25s ease;
}
.mobile-sticky-buy.visible { transform: translateY(0); }
.mobile-sticky-buy-price { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 6px; overflow: hidden; }
.mobile-sticky-buy .price-current, .mobile-sticky-buy-price .price { font-size: var(--font-size-lg); font-weight: 800; color: var(--primary); white-space: nowrap; }
.mobile-sticky-buy .price-old { font-size: var(--font-size-xs); color: var(--text-muted); text-decoration: line-through; }
.mobile-sticky-buy .btn { padding: 0.7rem 1.3rem; min-height: 0; font-size: var(--font-size-sm); flex-shrink: 0; }
@media (max-width: 900px) {
    .mobile-sticky-buy { display: flex; }
    body.has-sticky-buy .site-footer { padding-bottom: 78px; }
}

/* ============================================================
   9. الفوتر - مطابق تماماً لـ oemv3
   ============================================================ */
.site-footer {
    margin-top: 4rem; padding: 2rem 1.5rem; background: var(--bg-card);
    border-top: 1px solid var(--border); text-align: center; color: var(--text-muted);
    transition: var(--transition-slow);
}
.footer-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; }

/* شارة الإصدار - مطابقة تماماً لعنصر .version-badge في oemv3 */
.version-badge {
    display: inline-block; font-size: 0.7rem; font-weight: 600;
    background: var(--primary-gradient); color: #fff;
    padding: 0.15rem 0.6rem; border-radius: var(--radius-full);
    letter-spacing: 0.02em; border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.2); margin-bottom: 10px;
}

.social-links {
    display: flex; justify-content: center; align-items: center;
    gap: 0.8rem; margin-top: 1.2rem; flex-wrap: wrap;
}
.social-links a {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.3rem 1rem 0.3rem 0.8rem; border-radius: var(--radius-full);
    color: var(--text-muted); background: var(--bg-input); border: 1px solid var(--border);
    text-decoration: none; transition: var(--transition);
    font-size: var(--font-size-sm); font-weight: 500;
}
[dir="rtl"] .social-links a { padding: 0.3rem 0.8rem 0.3rem 1rem; }
.social-links a:hover { color: var(--primary); background: var(--primary-light); border-color: var(--primary); transform: translateY(-2px); }
.social-icon { width: 20px; height: 20px; flex-shrink: 0; }
.social-label { font-size: var(--font-size-sm); color: var(--text-muted); font-weight: 500; }

.footer-bottom {
    display: flex; flex-direction: column; align-items: center;
    text-align: center; padding-top: 20px; margin-top: 1rem;
    border-top: 1px solid var(--border); color: var(--text-muted); font-size: var(--font-size-xs);
}
.footer-bottom-text { max-width: 480px; line-height: 1.6; }

/* ============================================================
   10. عناصر عامة
   ============================================================ */
.empty-state { text-align: center; padding: 64px 20px; color: var(--text-muted); }
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 32px; }
.pagination a, .pagination span {
    min-width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius); background: var(--bg-card); border: 1px solid var(--border); color: var(--text-secondary);
}
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

.related-products { margin-top: 48px; }

/* ============================================================
   مراجعات المنتج (تعليقات ووردبريس حقيقية، غالباً مستوردة من AliExpress)
   ============================================================ */
.product-reviews-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.review-card {
    background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 16px;
}
.review-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.review-card-author { font-weight: 700; font-size: var(--font-size-sm); color: var(--text-primary); }
.review-card-head .stars { color: var(--warning); font-size: var(--font-size-sm); letter-spacing: 1px; }
.review-card-content { color: var(--text-secondary); font-size: var(--font-size-sm); line-height: 1.7; margin: 0 0 6px; }
.review-card-images { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 8px; }
.review-card-images img {
    width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border);
    transition: var(--transition);
}
.review-card-images img:hover { transform: scale(1.05); }
.review-card-date { font-size: var(--font-size-xs); color: var(--text-muted); }

#respond, .comment-respond { margin-top: 12px; }
.comment-reply-title { font-size: var(--font-size-lg); font-weight: 800; color: var(--text-primary); margin-bottom: 12px; }
.comment-form p { margin-bottom: 12px; }
.comment-form label { display: block; font-weight: 600; font-size: var(--font-size-sm); color: var(--text-secondary); margin-bottom: 6px; }
.comment-form input[type="text"], .comment-form input[type="email"], .comment-form input[type="url"], .comment-form textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg-card); color: var(--text-primary); font-family: inherit; font-size: var(--font-size-sm);
}
.comment-form textarea { resize: vertical; min-height: 90px; }
.comment-form #submit {
    padding: 10px 22px; border: none; border-radius: var(--radius); font-weight: 700; font-size: var(--font-size-sm);
    cursor: pointer; background: var(--primary-gradient); color: #fff; box-shadow: 0 3px 12px rgba(79, 70, 229, 0.28);
}
.comment-form #submit:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(79, 70, 229, 0.35); }

@media (max-width: 600px) {
    .product-single { gap: 20px; }

    /* شريط فئات الأرشيف على الهاتف: تمرير أفقي واحد بدل عشرات الشرائح تحتل الشاشة رأسياً */
    .archive-toolbar { flex-direction: column; align-items: stretch; }
    .archive-filters {
        flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
        padding-bottom: 6px; margin: 0 -4px; padding-inline: 4px;
    }
    .archive-filters::-webkit-scrollbar { height: 4px; }
    .archive-sort select { width: 100%; }

    /* راحة اللمس على الهاتف: تكبير مساحة الضغط على الشرائح والروابط الصغيرة */
    .archive-filters a { padding: 0.6rem 1.1rem; min-height: 40px; display: inline-flex; align-items: center; flex-shrink: 0; }
    .social-links a,
    .nav-social-links a { padding-top: 0.5rem; padding-bottom: 0.5rem; min-height: 40px; }
    .lang-switcher-menu a { padding: 0.75rem 0.7rem; }
    .pagination a, .pagination span { min-width: 44px; height: 44px; }
}
