/*
 * @almadah-clean-room — كُتب من الصفر من وصف السلوك، لا نسخًا من كود المورّد (10/11/2026)
 *
 * تنسيق صفحات القوائم الجديدة (resources/views/almadah/listing): بحث · قسم · علامة.
 * كل الأصناف بالبادئة am- ولا تعتمد على ملفات المورّد. الألوان من tokens طبقة almadah-clean.css (--c-*)
 * مع قيم احتياطية — لا تركواز هنا (قاعدة المالك 25/10: التركواز للهيدر والفوتر فقط).
 * الاتجاه منطقي (inline-start/end) فيعمل بالعربية والإنجليزية بلا قواعد مكرّرة.
 */

.am-plp {
    --am-ink: var(--c-ink, #0f1111);
    --am-ink-2: var(--c-ink-2, #565959);
    --am-line: var(--c-line, #d5d9d9);
    --am-line-soft: var(--c-line-soft, #e7e7e7);
    --am-band: var(--c-band, #f7f7f7);
    --am-hover: var(--c-hover, #f7fafa);
    --am-link: var(--c-link, #0b5cad);
    --am-link-h: var(--c-link-h, #c7511f);
    --am-sale: var(--c-sale, #cc0c39);
    --am-yellow: var(--c-yellow, #ffd814);
    --am-yellow-h: var(--c-yellow-h, #f7ca00);
    --am-radius: var(--r-box, 8px);
    --am-cols: 2;
    color: var(--am-ink);
    font-size: 14px;
    line-height: 1.5;
    width: 100%;
    max-width: 1140px;
    margin: 0 auto;
    padding: 4px 15px 8px;
}
.am-plp *, .am-plp *::before, .am-plp *::after { box-sizing: border-box; }
.am-plp h1, .am-plp h2, .am-plp h3, .am-plp p { margin: 0; }
.am-plp button { font: inherit; color: inherit; cursor: pointer; }
.am-plp button:not(.am-btn) { background: none; border: 0; padding: 0; }
.am-plp a { color: inherit; }
.am-plp img { max-width: 100%; }

.am-plp__layout { display: grid; grid-template-columns: 255px minmax(0, 1fr); gap: 30px; align-items: start; }
.am-plp__main { min-width: 0; }

/* ───────── أزرار ───────── */
.am-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 0 16px; border-radius: var(--r-btn, 999px); font-size: 13px; font-weight: 600; text-decoration: none !important; border: 1px solid transparent; cursor: pointer; white-space: nowrap; }
.am-btn--line { background: #fff; border-color: #888c8c; color: var(--am-ink) !important; }
.am-btn--line:hover { background: var(--am-hover); border-color: var(--am-ink); }
.am-btn--yellow { background: var(--am-yellow); border-color: var(--c-yellow-bd, #fcd200); color: var(--am-ink) !important; }
.am-btn--yellow:hover { background: var(--am-yellow-h); }
.am-btn--dark { background: #010100; color: #fff !important; border-radius: 12px; padding: 0 22px; min-height: 40px; }
.am-btn--wa { background: #e8f7ee; border-color: #bfe8cf; color: #1e7b45 !important; }
.am-btn--wa:hover { background: #d5f1e0; }

/* ───────── المسار والعنوان والأدوات ───────── */
.am-plp__crumbs ol { list-style: none; margin: 8px 0 6px; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 12px; }
.am-plp__crumbs li { color: var(--am-ink-2); }
.am-plp__crumbs li + li::before { content: "\203A"; margin-inline-end: 4px; }
.am-plp__crumbs a { color: var(--am-ink-2); text-decoration: none; }
.am-plp__crumbs a:hover { color: var(--am-ink); text-decoration: underline; }
.am-plp__crumbs [aria-current] { color: var(--am-ink); font-weight: 700; }

.am-plp__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 16px; }
.am-plp__title { font-size: 20px; font-weight: 700; line-height: 1.3; color: var(--am-ink); flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; }
.am-plp__tools { display: flex; align-items: center; gap: 12px; }
.am-plp__filter-open { display: none !important; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px !important; border: 1px solid var(--am-line) !important; border-radius: var(--am-radius); font-weight: 600; font-size: 13px; }
.am-plp__sort { display: inline-flex; align-items: center; gap: 6px; margin: 0; border: 1px solid var(--am-line); border-radius: var(--am-radius); padding: 0 10px; height: 36px; background: #fff; color: var(--am-ink-2); }
.am-plp__sort select { border: 0; background: transparent; font-size: 13px; color: var(--am-ink); height: 34px; min-width: 150px; outline: none; cursor: pointer; }
.am-plp__cols { display: flex; gap: 8px; }
.am-plp__cols button { display: inline-flex; align-items: center; justify-content: center; gap: 2px; height: 32px; padding: 0 9px !important; border-radius: 6px; background: var(--am-band) !important; }
.am-plp__cols button i { display: block; width: 3px; height: 14px; border-radius: 1px; background: var(--am-ink-2); }
.am-plp__cols button.is-on { background: var(--am-ink) !important; }
.am-plp__cols button.is-on i { background: #fff; }
.am-plp__busy { font-size: 12px; color: var(--am-ink-2); margin: -8px 0 8px; }

/* ───────── ملخص القسم والتنبيهات ───────── */
.am-plp__intro { background: var(--am-band); border: 1px solid var(--am-line-soft); border-radius: var(--am-radius); padding: 16px; margin: 0 0 16px; }
.am-plp__intro h2 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.am-plp__intro p { font-size: 13px; line-height: 1.9; }
.am-plp__intro details { margin-top: 8px; }
.am-plp__intro summary { font-size: 12px; font-weight: 600; cursor: pointer; color: var(--am-ink); }
.am-plp__intro details p { margin-top: 8px; opacity: .85; }

.am-plp__notice { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 16px; margin-bottom: 16px; border-radius: var(--am-radius); background: #fff8e6; border: 1px solid #f8d77a; color: #b7791f; }
.am-plp__notice-text { flex: 1 1 200px; display: flex; flex-direction: column; color: var(--am-ink); }
.am-plp__notice-text strong { font-size: 15px; }
.am-plp__notice-text span { font-size: 13px; color: var(--am-ink-2); }

.am-plp__soon { text-align: center; padding: 28px 16px; margin-bottom: 24px; border-radius: var(--am-radius); background: #fffaf0; border: 1px solid #f8d77a; color: #b7791f; }
.am-plp__soon h3 { font-size: 20px; font-weight: 800; color: var(--am-ink); margin: 8px 0; }
.am-plp__soon p { font-size: 14px; color: var(--am-ink-2); margin-bottom: 20px; }
.am-plp__soon strong { display: block; font-size: 15px; color: var(--am-ink); margin-bottom: 8px; }

.am-plp__guides { margin-top: 24px; background: var(--am-band); border: 1px solid var(--am-line-soft); border-radius: var(--am-radius); padding: 16px; }
.am-plp__guides h2 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.am-plp__guides ul { list-style: none; margin: 0; padding: 0; }
.am-plp__guides li { margin-bottom: 4px; font-size: 13px; }
.am-plp__guides a { text-decoration: none; }
.am-plp__guides a:hover { color: var(--am-link-h); text-decoration: underline; }

/* ───────── شبكة البطاقات ───────── */
.am-grid { display: grid; grid-template-columns: repeat(var(--am-cols), minmax(0, 1fr)); border-top: 1px solid var(--am-line-soft); border-inline-start: 1px solid var(--am-line-soft); }
.am-grid > * { border-inline-end: 1px solid var(--am-line-soft); border-bottom: 1px solid var(--am-line-soft); }
.am-grid[aria-busy="true"] { opacity: .45; transition: opacity .15s; }

.am-card { position: relative; display: flex; flex-direction: column; background: #fff; padding: 16px 12px 62px; min-width: 0; }
.am-card__media { position: relative; display: block; aspect-ratio: 1 / 1; overflow: hidden; }
.am-card__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.am-card__img--alt { opacity: 0; transition: opacity .25s; }
@media (hover: hover) {
    .am-card:hover .am-card__img--alt { opacity: 1; }
}
.am-card__badges { position: absolute; top: 16px; inset-inline-start: 12px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; z-index: 2; pointer-events: none; }
.am-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 700; line-height: 1.5; white-space: nowrap; background: var(--am-band); color: var(--am-ink-2); }
.am-badge--sale { background: var(--am-sale); color: #fff; }
.am-badge--soft { border: 1px solid var(--am-line-soft); }

.am-card__quick { position: absolute; top: 16px; inset-inline-end: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 2; opacity: 0; transition: opacity .2s; }
.am-card:hover .am-card__quick, .am-card:focus-within .am-card__quick { opacity: 1; }
.am-card__quick button { width: 32px; height: 32px; display: inline-flex !important; align-items: center; justify-content: center; border-radius: 50% !important; background: #fff !important; border: 1px solid var(--am-line-soft) !important; color: #919199 !important; }
.am-card__quick button:hover { background: var(--am-band) !important; color: var(--am-ink) !important; }
@media (hover: none) {
    .am-card__quick { display: none; }
}

.am-card__body { padding-top: 12px; text-align: start; }
.am-card__name { font-size: 14px !important; font-weight: 400 !important; line-height: 1.45 !important; height: 2.9em !important; max-height: 2.9em; overflow: hidden !important; display: -webkit-box !important; -webkit-line-clamp: 2; -webkit-box-orient: vertical; margin: 0 !important; }
.am-card__name a { display: inline; }
.am-card__name a { color: var(--am-ink); text-decoration: none; }
.am-card__name a:hover { color: var(--am-link-h); text-decoration: underline; }
.am-card__price { display: flex; flex-wrap: nowrap; align-items: baseline; gap: 0 8px; margin-top: 8px; white-space: nowrap; overflow: hidden; }
.am-card__now { font-size: 16px; font-weight: 700; color: var(--c-price, #0f1111); }
.am-card__was { font-size: 12px; color: var(--am-ink-2); }
.am-card__min, .am-card__note { font-size: 11px; color: var(--am-ink-2); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.am-card--svc { padding-bottom: 16px; }

.am-card__cart { position: absolute; bottom: 14px; inset-inline: 12px; height: 34px; display: flex !important; align-items: center; justify-content: center; gap: 6px; background: #fff !important; border: 1px solid #888c8c !important; border-radius: var(--r-btn, 999px) !important; color: var(--am-ink) !important; font-size: 13px !important; font-weight: 500; z-index: 2; }
.am-card__cart:hover { background: var(--am-hover) !important; border-color: var(--am-ink) !important; }
.am-card__cart:focus-visible, .am-card__quick button:focus-visible, .am-pager a:focus-visible, .am-check input:focus-visible + span { outline: 2px solid var(--am-link); outline-offset: 2px; }

/* لا نتائج */
.am-empty { grid-column: 1 / -1; text-align: center; padding: 40px 16px; color: var(--am-ink-2); }
.am-empty h2 { font-size: 16px; font-weight: 700; color: var(--am-ink); margin: 8px 0; }
.am-empty p { font-size: 13px; margin-bottom: 16px; }
.am-empty__acts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

/* ───────── الترقيم ───────── */
.am-pager { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin: 24px 0 8px; }
.am-pager__num, .am-pager__step, .am-pager__gap { min-width: 38px; height: 38px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--am-line); border-radius: 6px; font-size: 14px; color: var(--am-ink); text-decoration: none !important; background: #fff; }
.am-pager a:hover { background: var(--am-hover); }
.am-pager__num.is-on { background: var(--am-ink); border-color: var(--am-ink); color: #fff; font-weight: 700; }
.am-pager__step { font-size: 22px; line-height: 1; }
.am-pager__step.is-off { opacity: .4; }
.am-pager__gap { border-color: transparent; }
[dir="rtl"] .am-pager__step span, [dir="rtl"] .am-pager__step.is-off { transform: scaleX(-1); display: inline-block; }

/* ───────── البحث الموحّد ───────── */
.am-extras { margin-bottom: 16px; }
.am-extras__label { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.am-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.am-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 12px; padding-inline-start: 6px; border: 1px solid #e5e7eb; border-radius: 999px; background: #fff; color: var(--am-ink) !important; font-size: 13px; font-weight: 600; text-decoration: none !important; }
.am-chip img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: #f3f4f6; }
.am-chip--brands img { object-fit: contain; background: #fff; }
.am-chip:hover { border-color: #888c8c; background: var(--am-hover); }
.am-extras--svc { margin-top: 24px; }
.am-extras__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.am-extras__head h2 { font-size: 16px; font-weight: 700; }
.am-extras__head a { font-size: 13px; font-weight: 600; color: #b7791f; }

/* ───────── الفلاتر ───────── */
.am-filters { position: sticky; top: 8px; }
.am-filters__veil { display: none; }
.am-filters__panel { background: #fff; }
.am-filters__head { display: none; }
.am-filters__foot { display: none; }
.am-facet { border-bottom: 1px solid var(--am-line-soft); }
.am-facet > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; padding: 16px; font-size: 16px; font-weight: 700; cursor: pointer; }
.am-facet > summary::-webkit-details-marker { display: none; }
.am-facet > summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--am-ink-2); border-bottom: 2px solid var(--am-ink-2); transform: rotate(45deg); margin-top: -4px; transition: transform .2s; }
.am-facet[open] > summary::after { transform: rotate(225deg); margin-top: 4px; }
.am-facet__body { padding: 0 16px 16px; }

.am-check { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 14px; cursor: pointer; line-height: 1.35; }
.am-check input { width: 18px; height: 18px; flex: 0 0 18px; margin: 0; accent-color: var(--am-ink); cursor: pointer; }
.am-check input:checked + span, .am-check input:checked ~ span { font-weight: 700; }
.am-swatch { width: 20px; height: 20px; border-radius: 50%; flex: 0 0 20px; border: 1px solid var(--am-line-soft); }
.am-checks .is-extra { display: none; }
.am-checks.is-all .is-extra { display: flex; }
.am-more { font-size: 13px; font-weight: 700; color: var(--am-link) !important; }

.am-tree { max-height: 300px; overflow-y: auto; scrollbar-width: thin; }
.am-tree__list { list-style: none; margin: 0; padding: 0; }
.am-tree__list .am-tree__list { padding-inline-start: 18px; display: none; }
.am-tree__node.is-open > .am-tree__list { display: block; }
.am-tree__row { display: flex; align-items: flex-start; gap: 4px; }
.am-tree__row .am-check { margin-bottom: 10px; font-size: 14px; }
.am-tree__toggle, .am-tree__pad { flex: 0 0 18px; width: 18px; height: 18px; display: inline-flex !important; align-items: center; justify-content: center; border: 1px solid var(--am-line-soft) !important; border-radius: 4px !important; color: var(--am-ink-2); }
.am-tree__pad { border-color: transparent !important; }
.am-tree__toggle svg { transition: transform .2s; }
[dir="rtl"] .am-tree__toggle svg { transform: scaleX(-1); }
.am-tree__node.is-open > .am-tree__row .am-tree__toggle svg { transform: rotate(90deg); }

.am-price { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
.am-price label { display: flex; flex-direction: column; gap: 4px; margin: 0; font-size: 12px; color: var(--am-ink-2); min-width: 0; }
.am-price input { width: 100%; height: 34px; border: 1px solid var(--am-line); border-radius: 6px; padding: 0 8px; font-size: 14px; color: var(--am-ink); }
.am-price input:focus { outline: 2px solid var(--am-link); outline-offset: 0; }

/* ───────── المقاسات ───────── */
@media (min-width: 576px) { .am-plp { --am-cols: 3; } }
@media (min-width: 992px) { .am-plp { --am-cols: 4; } }
@media (min-width: 1200px) { .am-plp { --am-cols: 3; } }
@media (min-width: 1400px) { .am-plp { --am-cols: 4; } }
@media (min-width: 768px) {
    .am-plp[data-cols="2"] { --am-cols: 2; }
    .am-plp[data-cols="3"] { --am-cols: 3; }
    .am-plp[data-cols="4"] { --am-cols: 4; }
    .am-plp[data-cols="6"] { --am-cols: 6; }
}

/* تحت 1200: الفلاتر درج منزلق من جهة البداية */
@media (max-width: 1199.98px) {
    .am-plp__layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .am-plp__filter-open { display: inline-flex !important; }
    .am-filters { position: fixed; inset: 0; z-index: 2147483000; visibility: hidden; pointer-events: none; }
    .am-filters.is-open { visibility: visible; pointer-events: auto; }
    .am-filters__veil { display: block; position: absolute; inset: 0; background: rgba(15, 17, 17, .5); opacity: 0; transition: opacity .2s; }
    .am-filters.is-open .am-filters__veil { opacity: 1; }
    .am-filters__panel { position: absolute; top: 0; bottom: 0; inset-inline-start: 0; width: min(340px, 88vw); display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; transform: translateX(-100%); transition: transform .25s ease; box-shadow: 0 0 24px rgba(0, 0, 0, .15); }
    [dir="rtl"] .am-filters__panel { transform: translateX(100%); }
    .am-filters.is-open .am-filters__panel { transform: none; }
    .am-filters__head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 16px; padding-inline-start: 16px; border-bottom: 1px solid var(--am-line-soft); position: sticky; top: 0; background: #fff; z-index: 1; }
    .am-filters__head h2 { font-size: 16px; font-weight: 700; }
    .am-filters__x { width: 40px; height: 40px; display: inline-flex !important; align-items: center; justify-content: center; }
    .am-filters__foot { display: flex; gap: 8px; padding: 12px 16px; margin-top: auto; position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--am-line-soft); }
    .am-filters__foot .am-btn { flex: 1; min-height: 40px; }
    .am-tree { max-height: none; }
    body.am-noscroll { overflow: hidden; }
}
@media (max-width: 767.98px) {
    .am-plp { padding: 0 0 8px; }
    .am-plp__crumbs, .am-plp__bar, .am-plp__busy, .am-plp__intro, .am-plp__notice, .am-extras, .am-plp__guides, #am-plp-results { margin-inline: 16px; }
    .am-plp__bar { margin-bottom: 12px; }
    .am-plp__title { font-size: 18px; flex-basis: 100%; }
    .am-plp__tools { width: 100%; }
    .am-plp__sort { flex: 1; }
    .am-plp__sort select { min-width: 0; width: 100%; }
    .am-plp__cols { display: none; }
    .am-card { padding: 12px 10px 58px; }
    .am-card__cart { inset-inline: 10px; }
    .am-card__name { font-size: 13px !important; }
    .am-card__cart svg { display: none; }
    .am-pager__num, .am-pager__step, .am-pager__gap { min-width: 36px; height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
    .am-filters__panel, .am-filters__veil, .am-card__img--alt, .am-card__quick { transition: none; }
}
