/* ==========================================================================
   category.css — صفحة الأقسام والماركات v2 (category.php)
   بطاقات بفسيفساء صور المنتجات + رقائق الفروع + تبويب أقسام/ماركات + بحث فوري
   يعتمد على متغيرات header.php: --accent --text-primary --text-secondary --text-muted (+ Cairo)
   ========================================================================== */
.cx {
    --cx-r: 20px; --cx-r-sm: 12px;
    --cx-surface: rgba(15, 19, 26, 0.62);
    --cx-surface-2: rgba(255, 255, 255, 0.035);
    --cx-surface-3: rgba(255, 255, 255, 0.07);
    --cx-border: rgba(255, 255, 255, 0.08);
    --cx-border-strong: rgba(255, 255, 255, 0.14);
    --cx-accent: var(--accent, #ffcc00);
    --cx-accent-soft: rgba(255, 204, 0, 0.10);
    --cx-accent-line: rgba(255, 204, 0, 0.38);
    --cx-blue: #38bdf8;
    --cx-text: var(--text-primary, #f8fafc); --cx-text-2: var(--text-secondary, #cbd5e1); --cx-muted: var(--text-muted, #7c8798);
    --cx-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    --cx-header-h: var(--cx-header-d, 80px);
    font-family: 'Cairo', sans-serif; color: var(--cx-text); direction: rtl;
    max-width: 1400px; margin: 0 auto; padding: 18px 20px 80px;
}
.cx *, .cx *::before, .cx *::after { box-sizing: border-box; }
.cx a { text-decoration: none; }
.cx button, .cx input { font-family: inherit; }
.cx [hidden] { display: none !important; }

/* ---------- الهيرو ---------- */
.cx-crumbs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--cx-muted); margin-bottom: 10px; }
.cx-crumbs a { color: var(--cx-text-2); transition: color .2s; }
.cx-crumbs a:hover { color: var(--cx-accent); }
.cx-crumbs i { font-size: 10px; opacity: .6; }
.cx-crumbs [aria-current] { color: #fff; font-weight: 700; }
.cx-hero__row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.cx-hero__text h1 { margin: 0 0 6px; font-size: 28px; font-weight: 900; display: flex; align-items: center; gap: 12px; }
.cx-hero__text h1 i { color: var(--cx-accent); font-size: 22px; }
.cx-hero__text p { margin: 0; color: var(--cx-muted); font-size: 14px; max-width: 640px; }
.cx-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.cx-stat { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 999px; background: var(--cx-surface-2); border: 1px solid var(--cx-border); color: var(--cx-text-2); font-size: 13px; font-weight: 700; }
.cx-stat i { color: var(--cx-accent); font-size: 12px; }
.cx-stat b { color: #fff; font-weight: 900; }

/* ---------- الشريط اللاصق: تبويب + بحث ---------- */
.cx-bar { position: sticky; top: calc(var(--cx-header-h) + 8px); z-index: 40; margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 10px; border-radius: 16px; background: rgba(11, 15, 22, 0.86); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--cx-border); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); }
.cx-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--cx-surface-2); border: 1px solid var(--cx-border); }
.cx-tab { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 18px; border-radius: 9px; border: none; background: transparent; color: var(--cx-text-2); font-size: 14px; font-weight: 800; cursor: pointer; transition: background .2s, color .2s, box-shadow .2s; }
.cx-tab i { font-size: 13px; opacity: .8; }
.cx-tab:hover { color: #fff; }
.cx-tab.is-active { background: linear-gradient(135deg, var(--cx-accent), #e6b800); color: #111; box-shadow: 0 6px 16px rgba(255, 204, 0, 0.25); }
.cx-tab__n { font-size: 11px; font-weight: 800; padding: 1px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); }
.cx-tab.is-active .cx-tab__n { background: rgba(0, 0, 0, 0.16); }
.cx-search { position: relative; display: block; flex: 1 1 280px; max-width: 460px; }
.cx-search > i { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-start: 16px; color: var(--cx-muted); font-size: 14px; pointer-events: none; transition: color .2s; }
.cx-search:focus-within > i { color: var(--cx-accent); }
.cx-search input { width: 100%; height: 46px; border-radius: 999px; border: 1px solid var(--cx-border-strong); background: var(--cx-surface); color: #fff; font-size: 16px !important; font-weight: 600; padding: 0 44px 0 44px; outline: none; -webkit-appearance: none; appearance: none; transition: border-color .2s, box-shadow .2s; }
.cx-search input::placeholder { color: var(--cx-muted); font-weight: 500; }
.cx-search input:focus { border-color: var(--cx-accent-line); box-shadow: 0 0 0 4px var(--cx-accent-soft); }
.cx-search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.cx-search__clear { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-end: 10px; width: 28px; height: 28px; border-radius: 50%; border: none; background: var(--cx-surface-3); color: var(--cx-text-2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.cx-search__clear:hover { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }

/* ---------- الشبكة والبطاقات ---------- */
.cx-panel { display: none; margin-top: 18px; }
.cx-panel.is-active { display: block; }
.cx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.cx-card { position: relative; display: flex; flex-direction: column; background: var(--cx-surface); border: 1px solid var(--cx-border); border-radius: var(--cx-r); overflow: hidden; transition: transform .25s cubic-bezier(.2, .8, .2, 1), border-color .25s, box-shadow .25s; }
.cx-card:hover { transform: translateY(-4px); border-color: var(--cx-border-strong); box-shadow: var(--cx-shadow); }
.cx-card.cx-reveal { opacity: 0; transform: translateY(14px); }
.cx-card.cx-reveal.is-in { opacity: 1; transform: none; transition: opacity .45s ease, transform .45s cubic-bezier(.2, .8, .2, 1), border-color .25s, box-shadow .25s; }
.cx-card.cx-reveal.is-in:hover { transform: translateY(-4px); }
.cx-card.is-empty .cx-mosaic { opacity: .75; }
.cx-card__media { position: relative; display: block; }
.cx-card__count { position: absolute; bottom: 10px; inset-inline-start: 10px; z-index: 2; display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 999px; background: rgba(8, 11, 17, 0.78); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid rgba(255, 255, 255, 0.12); color: #fff; font-size: 12px; font-weight: 800; }
.cx-card__count i { color: var(--cx-accent); font-size: 11px; }
.cx-card__body { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 16px; flex: 1; }
.cx-card__title { margin: 0; font-size: 17px; font-weight: 900; line-height: 1.4; }
.cx-card__title a { color: #fff; transition: color .2s; }
.cx-card__title a:hover { color: var(--cx-accent); }
.cx-card__hint { font-size: 12px; color: var(--cx-muted); }
.cx-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cx-chip { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--cx-border-strong); background: var(--cx-surface-2); color: var(--cx-text-2); font-size: 12px; font-weight: 700; white-space: nowrap; cursor: pointer; transition: border-color .18s, color .18s, background .18s; max-width: 100%; }
.cx-chip b { font-size: 10.5px; font-weight: 800; color: var(--cx-muted); background: rgba(255, 255, 255, 0.07); border-radius: 999px; padding: 0 6px; }
.cx-chip:hover { border-color: var(--cx-accent-line); color: var(--cx-accent); background: var(--cx-accent-soft); }
.cx-chip--toggle { color: var(--cx-accent); border-style: dashed; }
.cx-chip--toggle i { font-size: 10px; }
.cx-card:not(.is-expanded) .cx-chip--more { display: none; }
.cx-card.is-expanded .cx-chip--toggle { display: none; }
.cx-card__cta { margin-top: auto; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; border-radius: var(--cx-r-sm); background: var(--cx-accent-soft); border: 1px solid var(--cx-accent-line); color: var(--cx-accent); font-size: 13px; font-weight: 800; transition: background .2s, color .2s, gap .2s; }
.cx-card__cta i { font-size: 12px; transition: transform .2s; }
.cx-card__cta:hover, .cx-card:hover .cx-card__cta { background: linear-gradient(135deg, var(--cx-accent), #e6b800); color: #111; }
.cx-card:hover .cx-card__cta i { transform: translateX(-4px); }

/* الفسيفساء: 1–4 صور منتجات */
.cx-mosaic { position: relative; aspect-ratio: 4 / 3; display: grid; gap: 4px; padding: 4px; background: radial-gradient(110% 80% at 50% 0%, rgba(255, 204, 0, 0.09), transparent 60%), linear-gradient(180deg, rgba(22, 27, 36, 0.9), rgba(12, 16, 23, 0.95)); border-bottom: 1px solid var(--cx-border); }
.cx-mosaic--n1 { grid-template-columns: 1fr; }
.cx-mosaic--n2 { grid-template-columns: 1fr 1fr; }
.cx-mosaic--n3 { grid-template-columns: 1.4fr 1fr; grid-template-rows: 1fr 1fr; }
.cx-mosaic--n3 .cx-mosaic__cell:first-child { grid-row: 1 / 3; }
.cx-mosaic--n4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.cx-mosaic__cell { display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, 0.035); border-radius: 12px; overflow: hidden; min-height: 0; }
.cx-mosaic__cell img { width: 100%; height: 100%; object-fit: contain; padding: 8px; display: block; transition: transform .5s cubic-bezier(.2, .8, .2, 1); }
.cx-card:hover .cx-mosaic__cell img { transform: scale(1.06); }
.cx-mosaic--empty { display: flex; align-items: center; justify-content: center; padding: 0; }
.cx-mosaic--empty span { width: 76px; height: 76px; border-radius: 22px; background: rgba(0, 0, 0, 0.35); backdrop-filter: blur(6px); color: #fff; font-size: 34px; font-weight: 900; display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); }
.cx-mosaic--empty span i { font-size: 30px; }

/* بطاقة "الكل" */
.cx-card--all { grid-column: span 2; flex-direction: row; background: linear-gradient(135deg, rgba(255, 204, 0, 0.12), rgba(15, 19, 26, 0.7) 60%); border-color: var(--cx-accent-line); color: inherit; }
.cx-card--all .cx-mosaic { flex: 0 0 46%; aspect-ratio: auto; min-height: 220px; border-bottom: 0; border-inline-end: 1px solid var(--cx-border); }
.cx-card--all__body { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 8px; padding: 22px 24px; }
.cx-card--all__kicker { font-size: 12px; font-weight: 800; color: var(--cx-accent); display: inline-flex; align-items: center; gap: 6px; }
.cx-card--all__body h3 { margin: 0; font-size: 24px; font-weight: 900; color: #fff; }
.cx-card--all__body p { margin: 0; color: var(--cx-text-2); font-size: 14px; }
.cx-card--all__body p b { color: var(--cx-accent); }
.cx-card--all__body .cx-card__cta { margin-top: 8px; align-self: flex-start; padding: 0 18px; }
.cx-card--all-brands { background: linear-gradient(135deg, rgba(56, 189, 248, 0.12), rgba(15, 19, 26, 0.7) 60%); border-color: rgba(56, 189, 248, 0.35); }
.cx-card--all-brands .cx-card--all__kicker, .cx-card--all-brands .cx-card--all__body p b { color: var(--cx-blue); }

/* ---------- الحالة الفارغة ---------- */
.cx-empty { text-align: center; padding: 56px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.cx-empty > i { width: 72px; height: 72px; border-radius: 50%; background: var(--cx-accent-soft); border: 1px solid var(--cx-accent-line); color: var(--cx-accent); display: flex; align-items: center; justify-content: center; font-size: 26px; margin-bottom: 8px; }
.cx-empty h3 { margin: 0; font-size: 19px; font-weight: 900; }
.cx-empty p { margin: 0 0 10px; color: var(--cx-muted); font-size: 14px; }
.cx-btn { display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: var(--cx-r-sm); border: 1px solid var(--cx-accent-line); background: var(--cx-accent-soft); color: var(--cx-accent); font-size: 13px; font-weight: 800; cursor: pointer; transition: background .2s, color .2s; }
.cx-btn:hover { background: linear-gradient(135deg, var(--cx-accent), #e6b800); color: #111; }

/* ---------- الاستجابة ---------- */
@media (max-width: 1100px) {
    .cx-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
}
@media (max-width: 768px) {
    .cx { --cx-header-h: var(--cx-header-m, 75px); padding: 12px 12px 80px; }
    .cx-hero__text h1 { font-size: 21px; }
    .cx-hero__text p { font-size: 13px; }
    .cx-stat { height: 32px; padding: 0 11px; font-size: 12px; }
    .cx-bar { top: var(--cx-header-h); margin-top: 12px; padding: 6px 8px; gap: 8px; border-radius: 14px; }
    .cx-tabs { width: 100%; }
    .cx-tab { flex: 1; justify-content: center; height: 38px; padding: 0 10px; font-size: 13px; }
    .cx-search { max-width: none; flex-basis: 100%; }
    .cx-search input { height: 42px; }
    .cx-panel { margin-top: 12px; }
    .cx-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .cx-card { border-radius: 16px; }
    .cx-card__body { padding: 10px 11px 12px; gap: 8px; }
    .cx-card__title { font-size: 14px; }
    .cx-card__count { height: 24px; padding: 0 8px; font-size: 10.5px; bottom: 8px; inset-inline-start: 8px; }
    .cx-mosaic { aspect-ratio: 1 / 1; gap: 3px; padding: 3px; }
    .cx-mosaic__cell { border-radius: 9px; }
    .cx-mosaic__cell img { padding: 5px; }
    .cx-mosaic--empty span { width: 56px; height: 56px; font-size: 26px; border-radius: 16px; }
    .cx-chip { height: 26px; padding: 0 9px; font-size: 11px; }
    .cx-card__cta { height: 36px; font-size: 12px; }
    .cx-card__hint { font-size: 11px; }
    .cx-card--all { grid-column: 1 / -1; flex-direction: row; }
    .cx-card--all .cx-mosaic { flex-basis: 42%; min-height: 150px; aspect-ratio: auto; }
    .cx-card--all__body { padding: 12px 14px; gap: 4px; }
    .cx-card--all__body h3 { font-size: 17px; }
    .cx-card--all__body p { font-size: 12px; }
    .cx-card--all__body .cx-card__cta { height: 34px; font-size: 12px; padding: 0 12px; }
    .cx-empty { padding: 40px 10px; }
}
@media (max-width: 360px) {
    .cx-grid { gap: 8px; }
    .cx-card__title { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
    .cx *, .cx *::before, .cx *::after { transition: none !important; animation: none !important; }
    .cx-card.cx-reveal { opacity: 1; transform: none; }
}
