/* تطبيق متجر بنسلز — تصميم كلاسيكي فاتح يتأقلم مع كل الشاشات (موبايل، تابلت، كمبيوتر) */
:root {
  --navy: #1f3a5f; --navy-2: #2c4f7c; --sun: #f5b301; --sun-soft: #fff6d6;
  --bg: #f3f5f8; --card: #fff; --line: #e3e8ef; --ink: #1e293b; --mute: #64748b;
  --ok: #15803d; --bad: #b91c1c; --r: 16px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 600 15px/1.55 'Cairo', Tahoma, sans-serif; }
body { min-height: 100dvh; overscroll-behavior-y: contain; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

/* ---------- الشريط العلوي + السلة فوق ---------- */
.top { position: sticky; top: 0; z-index: 30; background: #fff; border-bottom: 1px solid var(--line); padding-top: var(--safe-t); box-shadow: 0 6px 18px -14px rgba(30,41,59,.4); }
.top-in { max-width: 1280px; margin: 0 auto; padding: 8px 12px; display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 0; text-align: right; flex: 0 0 auto; }
.brand img { width: 40px; height: 40px; border-radius: 50%; }
.brand b { display: block; font-size: 16px; font-weight: 800; color: var(--navy); line-height: 1.2; }
.brand small { display: block; font-size: 11.5px; color: var(--mute); }
.search { flex: 1; min-width: 0; }
.search input { width: 100%; border: 1.5px solid #cfd8e3; border-radius: 999px; padding: 9px 16px; font-size: 16px; background: #f8fafc; outline: none; }
.search input:focus { border-color: var(--navy-2); background: #fff; box-shadow: 0 0 0 3px rgba(44,79,124,.14); }
.icon-btn { border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 7px 10px; font-weight: 800; color: var(--navy); white-space: nowrap; }
.icon-btn .lbl { margin-inline-start: 4px; }
.cart-btn { position: relative; display: flex; align-items: center; gap: 8px; border: 0; border-radius: 14px; background: var(--navy); color: #fff; padding: 8px 14px; white-space: nowrap; box-shadow: 0 6px 16px -8px rgba(31,58,95,.7); }
.cart-btn .cart-ico { font-size: 20px; }
.cart-btn b { font-size: 16px; }
.cart-btn small { font-size: 12px; opacity: .85; }
.cart-sum { background: var(--sun); color: #3b2a00; border-radius: 999px; padding: 1px 10px; font-weight: 800; font-size: 13.5px; }
.cart-btn.bump { animation: bump .45s ease; }
@keyframes bump { 30% { transform: scale(1.12); } 60% { transform: scale(.96); } }

.cartbar { background: var(--sun-soft); border-top: 1px solid #f3dc8b; }
.cartbar-in { max-width: 1280px; margin: 0 auto; padding: 6px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 700; color: #5b4300; font-size: 14px; }

.cats { max-width: 1280px; margin: 0 auto; display: flex; gap: 8px; overflow-x: auto; padding: 8px 12px 10px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 14px; font-weight: 700; color: #334155; font-size: 14px; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }

/* ---------- الأصناف ---------- */
.view { max-width: 1280px; margin: 0 auto; padding: 12px 12px calc(28px + var(--safe-b)); outline: none; }
.count { color: var(--mute); font-size: 13px; margin: 2px 2px 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.card { position: relative; background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; transition: transform .15s, border-color .2s, box-shadow .2s; user-select: none; }
.card:active { transform: scale(.98); }
.card.in { border-color: #9cc3ff; box-shadow: 0 0 0 3px rgba(37,99,235,.10); }
.card.out { opacity: .6; }
.card .ph { aspect-ratio: 1 / 1; background: #f8fafc; display: grid; place-items: center; overflow: hidden; }
.card .ph img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.card .ph .noimg { font-size: 44px; opacity: .55; }
.card .body { padding: 8px 10px 4px; flex: 1; }
.card .name { font-weight: 700; font-size: 14px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.card .price { font-weight: 800; color: var(--navy); font-size: 16px; margin-top: 2px; }
.card .price small { font-size: 12px; color: var(--mute); font-weight: 700; }
.card .low { font-size: 11.5px; color: #b45309; font-weight: 700; }
.card .act { padding: 6px 10px 10px; }
.add { width: 100%; border: 0; border-radius: 12px; background: var(--sun); color: #3b2a00; font-weight: 800; padding: 9px 6px; font-size: 14px; }
.add:disabled { background: #e2e8f0; color: #94a3b8; cursor: default; }
.qty { display: flex; align-items: center; justify-content: space-between; gap: 6px; background: #eef4ff; border-radius: 12px; padding: 3px; }
.qty button { width: 38px; height: 36px; border: 0; border-radius: 10px; background: #fff; font-size: 20px; font-weight: 800; color: var(--navy); box-shadow: 0 1px 3px rgba(15,23,42,.12); }
.qty b { font-size: 17px; min-width: 28px; text-align: center; }
.badge-in { position: absolute; top: 8px; inset-inline-start: 8px; background: var(--navy); color: #fff; border-radius: 999px; min-width: 26px; height: 26px; display: grid; place-items: center; font-weight: 800; font-size: 13px; padding: 0 7px; }
.more { display: block; margin: 16px auto 0; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 26px; font-weight: 800; color: var(--navy); }
.empty { text-align: center; padding: 50px 10px; color: var(--mute); font-size: 16px; }
.empty b { display: block; font-size: 44px; }

/* ---------- السلة (تنزل من فوق) ---------- */
.sheet { position: fixed; inset: 0; z-index: 60; background: rgba(15,23,42,.42); display: flex; justify-content: center; align-items: flex-start; }
.sheet-panel { background: #fff; width: 100%; max-width: 560px; max-height: calc(100dvh - 10px); margin-top: 0; border-radius: 0 0 22px 22px; display: flex; flex-direction: column; padding-top: var(--safe-t); animation: down .25s ease; box-shadow: 0 20px 40px -20px rgba(15,23,42,.5); }
@keyframes down { from { transform: translateY(-30px); opacity: 0; } }
@media (min-width: 700px) { .sheet { align-items: flex-start; padding-top: 70px; } .sheet-panel { border-radius: 22px; max-height: calc(100dvh - 90px); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 18px; }
.x { border: 0; background: #f1f5f9; border-radius: 10px; width: 38px; height: 38px; font-size: 16px; }
.sheet-body { overflow: auto; padding: 8px 16px; flex: 1; }
.sheet-foot { border-top: 1px solid var(--line); padding: 12px 16px calc(12px + var(--safe-b)); background: #fafbfc; border-radius: 0 0 22px 22px; }
.line { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.line img, .line .noimg { width: 56px; height: 56px; border-radius: 12px; object-fit: contain; background: #f8fafc; flex: 0 0 auto; display: grid; place-items: center; font-size: 26px; border: 1px solid var(--line); }
.line .ln { flex: 1; min-width: 0; }
.line .ln b { display: block; font-size: 14px; line-height: 1.4; }
.line .ln small { color: var(--mute); font-size: 12.5px; }
.line .qty { width: 128px; flex: 0 0 auto; }
.line .warn { color: var(--bad); font-size: 12px; font-weight: 700; }
.tot { display: grid; gap: 3px; margin-bottom: 10px; font-size: 14.5px; }
.tot div { display: flex; justify-content: space-between; }
.tot .big { font-size: 18px; font-weight: 800; color: var(--navy); border-top: 1px solid var(--line); padding-top: 5px; margin-top: 2px; }

/* ---------- الأزرار والنماذج ---------- */
.btn { border: 0; border-radius: 14px; padding: 13px 18px; font-weight: 800; font-size: 16px; }
.btn.primary { background: var(--navy); color: #fff; }
.btn.sun { background: var(--sun); color: #3b2a00; }
.btn.ghost { background: #fff; border: 1.5px solid var(--line); color: var(--navy); }
.btn.green { background: #16a34a; color: #fff; }
.btn.sm { padding: 6px 14px; font-size: 14px; border-radius: 10px; }
.btn.block { display: block; width: 100%; }
.btn:disabled { opacity: .6; cursor: wait; }
.page { max-width: 640px; margin: 0 auto; }
.page h1 { font-size: 21px; margin: 4px 0 12px; }
.back { border: 0; background: none; color: var(--navy-2); font-weight: 800; padding: 4px 0; margin-bottom: 4px; }
.box { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.box h3 { margin: 0 0 10px; font-size: 16px; }
.f { display: grid; gap: 4px; margin-bottom: 11px; font-weight: 700; font-size: 14px; }
.f input, .f textarea, .f select { width: 100%; border: 1.5px solid #cfd8e3; border-radius: 12px; padding: 11px 12px; font-size: 16px; background: #fff; outline: none; }
.f input:focus, .f textarea:focus, .f select:focus { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(44,79,124,.14); }
.f .hint { font-weight: 600; color: var(--mute); font-size: 12.5px; }
.f.err input, .f.err textarea { border-color: var(--bad); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.loc { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--mute); }
.pay { display: flex; align-items: center; gap: 10px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 12px; padding: 10px 12px; color: #166534; font-weight: 700; }
.msg-err { background: #fef2f2; border: 1px solid #fecaca; color: var(--bad); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; font-weight: 700; }
.done { text-align: center; padding: 20px 10px; }
.done .big { font-size: 64px; }
.done .num { display: inline-block; font: 800 22px ui-monospace, Menlo, Consolas, monospace; background: var(--sun-soft); border: 1.5px dashed var(--sun); border-radius: 12px; padding: 6px 16px; margin: 8px 0; direction: ltr; }
.ord { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.ord .n { font: 800 15px ui-monospace, Menlo, Consolas, monospace; direction: ltr; }
.st { border-radius: 999px; padding: 2px 10px; font-size: 12.5px; font-weight: 800; background: #e0ecff; color: #1e40af; white-space: nowrap; }
.st.pending { background: #fff4d6; color: #92400e; } .st.delivered { background: #dcfce7; color: #166534; } .st.cancelled { background: #fee2e2; color: #991b1b; }

/* ---------- رسائل ---------- */
.toast { position: fixed; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translate(-50%, 180%); background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 10px 18px; font-weight: 800; box-shadow: 0 14px 30px -14px rgba(15,23,42,.45); z-index: 80; transition: transform .28s ease; pointer-events: none; max-width: calc(100% - 24px); text-align: center; }
.toast.on { transform: translate(-50%, 0); }
.toast.ok { color: var(--ok); } .toast.bad { color: var(--bad); }
.offline { position: fixed; top: auto; bottom: calc(10px + var(--safe-b)); left: 10px; right: 10px; z-index: 70; background: #fff7ed; border: 1px solid #fdba74; color: #9a3412; border-radius: 14px; padding: 8px 12px; text-align: center; font-weight: 700; font-size: 13px; }
.skel { background: linear-gradient(90deg, #eef2f6 25%, #f8fafc 50%, #eef2f6 75%); background-size: 200% 100%; animation: sh 1.2s infinite; border-radius: var(--r); aspect-ratio: 3 / 4; }
@keyframes sh { to { background-position: -200% 0; } }

/* ---------- تأقلم الحجم مع كل جهاز ---------- */
@media (max-width: 760px) {
  .top-in { flex-wrap: wrap; gap: 8px; }
  .search { order: 5; flex-basis: 100%; }
  .brand { flex: 1; }
  .icon-btn .lbl { display: none; }
  .cart-btn { padding: 7px 11px; }
  .cart-btn small { display: none; }
}
@media (max-width: 520px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .view { padding-inline: 9px; }
  .card .name { font-size: 13px; }
  .card .price { font-size: 15px; }
  .add { font-size: 13px; padding: 8px 4px; }
  .qty button { width: 34px; height: 34px; }
  .row2 { grid-template-columns: 1fr; gap: 0; }
  .brand small { display: none; }
}
@media (max-width: 360px) { .cart-sum { display: none; } }
@media (min-width: 1100px) { .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- الرئيسية بنفس شكل الموقع ---------- */
.hero { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: linear-gradient(120deg, #1f3a5f, #2c4f7c 60%, #3b6aa6); color: #fff; border-radius: 18px; padding: 18px 20px; margin-bottom: 18px; }
.hero b { display: block; font-size: 19px; font-weight: 900; } .hero span { font-size: 13.5px; opacity: .9; }
.sec-h { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--line); margin: 18px 0 12px; }
.sec-h h2 { margin: 0 0 -2px; padding-bottom: 8px; font-size: 18px; font-weight: 900; color: var(--navy); border-bottom: 3px solid var(--sun); }
.sec-h .link { border: 0; background: none; color: var(--navy-2); font-weight: 800; font-size: 13.5px; padding: 0 0 8px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 12px 8px; text-align: center; display: grid; justify-items: center; gap: 4px; }
.tile:hover { border-color: var(--sun); }
.tile-img { width: 84px; height: 84px; border-radius: 50%; background: var(--sun-soft); border: 3px solid #fff3c4; display: grid; place-items: center; overflow: hidden; font-size: 36px; }
.tile-img img { width: 100%; height: 100%; object-fit: cover; }
.tile b { font-size: 14px; } .tile small { color: var(--mute); font-size: 12px; }
.row6 { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1100px) { .row6 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .row6 > :nth-child(n+5) { display: none; } }
@media (max-width: 600px) {
  .row6 { display: flex; overflow-x: auto; gap: 9px; scroll-snap-type: x mandatory; padding-bottom: 4px; }
  .row6 > * { flex: 0 0 46%; scroll-snap-align: start; display: flex !important; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .tile-img { width: 64px; height: 64px; font-size: 28px; } .tile b { font-size: 12.5px; }
  .hero { flex-direction: column; align-items: flex-start; } .hero b { font-size: 17px; }
}
.search input { border-color: var(--sun) !important; border-width: 2px !important; }

/* ---------- عرض صور الأصناف (استوديو موحد) ---------- */
.card .ph { background: #f4f5f7 !important; border-radius: 14px; margin: 8px 8px 0; overflow: hidden; isolation: isolate; }
.card .ph img { background: transparent !important; mix-blend-mode: multiply; padding: 6%; box-sizing: border-box; }
.line img { mix-blend-mode: multiply; background: #f4f5f7 !important; }
.card .ph .ph-logo { display: flex; flex-direction: column; align-items: center; gap: 6px; opacity: 1; font-size: 12px; }
.card .ph .ph-logo img { width: 34%; height: auto; padding: 0; mix-blend-mode: normal; filter: grayscale(1); opacity: .35; border-radius: 50%; }
.card .ph .ph-logo small { color: #94a3b8; font-weight: 700; font-size: 11px; }

/* ---------- تفاصيل الصنف ---------- */
body.noscroll { overflow: hidden; }
.badge-opt { position: absolute; top: 8px; inset-inline-end: 8px; z-index: 2; background: #fff; border: 1px solid var(--line); border-radius: 999px; width: 28px; height: 28px; display: grid; place-items: center; font-size: 14px; box-shadow: 0 1px 3px rgba(15,23,42,.12); }
.card .ph, .card .body { cursor: pointer; }
.add.opt { background: #f3e8ff !important; color: #6b21a8 !important; }
.opt-lbl { display: block; font-size: 12px; color: #6b21a8; font-weight: 700; }
.pd-sheet { align-items: flex-end !important; padding-top: 0 !important; }
.pd-panel { position: relative; background: #fff; width: 100%; max-width: 560px; max-height: calc(100dvh - 24px); border-radius: 22px 22px 0 0; display: flex; flex-direction: column; overflow: hidden; animation: pdUp .25s ease; box-shadow: 0 -20px 40px -20px rgba(15,23,42,.5); }
@keyframes pdUp { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (min-width: 700px) { .pd-sheet { align-items: center !important; } .pd-panel { border-radius: 22px; max-height: calc(100dvh - 60px); } }
.pd-x { position: absolute; top: 10px; inset-inline-start: 10px; z-index: 3; background: rgba(255,255,255,.92); box-shadow: 0 2px 8px rgba(15,23,42,.18); }
.pd-body { overflow: auto; flex: 1; overscroll-behavior: contain; }
.pd-gal { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; background: #f8fafc; scrollbar-width: none; }
.pd-gal::-webkit-scrollbar { display: none; }
.pd-gal img { flex: 0 0 100%; width: 100%; aspect-ratio: 1 / 1; object-fit: contain; scroll-snap-align: center; background: #fff; }
.pd-noimg { width: 100%; aspect-ratio: 16 / 10; display: grid; place-items: center; align-content: center; gap: 6px; color: var(--mute); }
.pd-noimg img { width: 72px; opacity: .7; }
.pd-dots { display: flex; gap: 6px; padding: 8px 12px 0; overflow-x: auto; scrollbar-width: none; }
.pd-dots button { flex: 0 0 auto; width: 52px; height: 52px; border-radius: 10px; border: 2px solid var(--line); background: #fff; padding: 2px; }
.pd-dots button img { width: 100%; height: 100%; object-fit: contain; border-radius: 7px; }
.pd-dots button.on { border-color: var(--sun); box-shadow: 0 0 0 2px rgba(245,179,1,.25); }
.pd-info { padding: 12px 16px 16px; display: grid; gap: 10px; }
.pd-info h2 { margin: 0; font-size: 19px; line-height: 1.5; }
.pd-price { font-size: 24px; font-weight: 800; color: var(--navy); }
.pd-stock { font-weight: 700; color: var(--ok); font-size: 14px; }
.pd-stock.is-out { color: var(--bad); }
.pd-og { border-radius: 14px; transition: background .2s; }
.pd-og.miss { background: #fff1f2; box-shadow: 0 0 0 2px #fda4af; padding: 8px; animation: pdShake .35s; }
@keyframes pdShake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.pd-ol { font-weight: 800; margin-bottom: 8px; } .pd-ol b { color: #b45309; }
.pd-ov { display: flex; flex-wrap: wrap; gap: 8px; }
.pd-o { display: inline-flex; align-items: center; gap: 7px; min-height: 42px; padding: 6px 14px; border-radius: 999px; border: 2px solid var(--line); background: #fff; font: 700 14px 'Cairo', sans-serif; color: var(--ink); }
.pd-o i { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(0,0,0,.18); box-shadow: inset 0 0 0 2px #fff; }
.pd-o.on { border-color: var(--sun); background: var(--sun-soft); box-shadow: 0 0 0 3px rgba(245,179,1,.22); }
.pd-wait { color: var(--mute); font-weight: 700; font-size: 14px; }
.pd-desc { background: #f8fafc; border-radius: 12px; padding: 10px 12px; } .pd-desc p { margin: 4px 0 0; color: #334155; line-height: 1.8; font-size: 14px; }
.pd-code { color: var(--mute); font-size: 12.5px; }
.pd-foot { display: flex; gap: 10px; align-items: center; padding: 10px 14px calc(10px + var(--safe-b, 0px)); border-top: 1px solid var(--line); background: #fff; }
.pd-qty { width: 130px; flex: 0 0 auto; }
.pd-add { flex: 1; }
.pd-add:disabled { opacity: .55; }
