/* تصميم لايت احترافي — عربي */
:root{
  --bg:#f6f7fb;
  --card:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --border:#e5e7eb;
  --primary:#2563eb;
  --primary-2:#1d4ed8;
  --danger:#dc2626;
  --success:#16a34a;
  --shadow: 0 10px 25px rgba(2, 6, 23, .08);
  --radius: 16px;
}

*{box-sizing:border-box}
html,body{
  padding-top: 78px;height:100%}
body{
  margin:0;
  font-family: "Tajawal", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 700px at 80% -10%, rgba(37,99,235,.10), transparent 60%),
              radial-gradient(900px 500px at 10% 0%, rgba(29,78,216,.08), transparent 55%),
              var(--bg);
  color:var(--text);
  direction: rtl;
}

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

.container{max-width:1100px; margin:0 auto; padding:24px}

.topbar{
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2500;
  /* تعزيز الثبات على بعض متصفحات الموبايل */
  will-change: transform;
  backdrop-filter: blur(10px);
  background: rgba(246,247,251,.92);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(2,6,23,.06);
}

.topbar .inner{display:flex; gap:12px; align-items:center; justify-content:space-between; padding:14px 24px; max-width:1100px; margin:0 auto}

.brand{display:flex; align-items:center; gap:12px}
.brand .logo{
  width:40px; height:40px; border-radius:12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 10px 20px rgba(37,99,235,.25);
  display:flex; align-items:center; justify-content:center;
  color:white; font-weight:800;
}
.brand .t{display:flex; flex-direction:column; line-height:1.1}
.brand .t strong{font-size:16px}
.brand .t span{font-size:12px; color:var(--muted)}

.nav{display:flex; gap:8px; flex-wrap:wrap}

.btn{
  border:1px solid var(--border);
  background:var(--card);
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  transition: transform .06s ease, box-shadow .2s ease, border-color .2s ease;
}
.btn:hover{box-shadow: var(--shadow); border-color:#d1d5db}
.btn:active{transform: translateY(1px)}
.btn.primary{background:linear-gradient(135deg, var(--primary), var(--primary-2)); color:white; border-color:transparent}
.btn.danger{background:rgba(220,38,38,.08); color:var(--danger); border-color:rgba(220,38,38,.20)}
.btn.ghost{background:transparent}

.card{
  background: var(--card);
  border:1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card .hd{padding:18px 18px 10px; border-bottom:1px solid var(--border)}
.card .hd h2{margin:0; font-size:18px}
.card .hd p{margin:6px 0 0; color:var(--muted); font-size:13px}
.card .bd{padding:18px}

.grid{display:grid; gap:14px}
.grid.cols-3{grid-template-columns: repeat(3, minmax(0, 1fr))}
.grid.cols-2{grid-template-columns: repeat(2, minmax(0, 1fr))}
@media(max-width:900px){.grid.cols-3{grid-template-columns:1fr;}.grid.cols-2{grid-template-columns:1fr;}}

.input, select, textarea{
  width:100%;
  border:1px solid var(--border);
  border-radius: 12px;
  padding:12px 12px;
  background:white;
  color:var(--text);
  outline:none;
}
.input:focus, select:focus, textarea:focus{border-color:rgba(37,99,235,.55); box-shadow: 0 0 0 4px rgba(37,99,235,.12)}

.row{display:flex; gap:12px; align-items:center}
.row.wrap{flex-wrap:wrap}

.pill{display:inline-flex; gap:8px; align-items:center; padding:8px 10px; border:1px dashed var(--border); border-radius:999px; color:var(--muted); background:rgba(148,163,184,.12)}
.pill strong{color:var(--text)}

.table{width:100%; border-collapse:separate; border-spacing:0; overflow:hidden; border:1px solid var(--border); border-radius:14px}
.table th, .table td{padding:12px 10px; border-bottom:1px solid var(--border); text-align:right; vertical-align:top}
.table th{background:rgba(2,6,23,.03); font-weight:700; font-size:13px; color:#334155}
.table tr:last-child td{border-bottom:none}
.table td small{color:var(--muted)}

.badge{display:inline-flex; align-items:center; gap:6px; padding:6px 10px; border-radius:999px; font-size:12px; border:1px solid var(--border); background:rgba(2,6,23,.03)}
.badge.success{border-color:rgba(22,163,74,.25); background:rgba(22,163,74,.08); color:var(--success)}
.badge.danger{border-color:rgba(220,38,38,.25); background:rgba(220,38,38,.08); color:var(--danger)}

hr.sep{border:none; border-top:1px solid var(--border); margin:16px 0}

.toast{
  position: fixed; bottom:18px; left:18px;
  background: var(--card);
  border:1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding:12px 14px;
  max-width: 340px;
  display:none;
}

/* Global loading overlay */
.loading-overlay{
  position: fixed;
  inset: 0;
  background: rgba(246,247,251,.78);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.loading-overlay.show{display:flex;}
.loading-box{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px 18px;
  display:flex;
  gap: 12px;
  align-items:center;
  max-width: 520px;
}
.spinner{
  width: 22px; height: 22px;
  border-radius: 999px;
  border: 3px solid rgba(100,116,139,.25);
  border-top-color: var(--primary);
  animation: spin .9s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}

/* Admin modal */
.modal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}
.modal-backdrop.show{display:flex;}
.admin-dialog{
  width: min(520px, calc(100% - 28px));
  background: var(--card);
  border:1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow:hidden;
}
.admin-dialog .mhd{padding:16px 16px 10px; border-bottom:1px solid var(--border)}
.admin-dialog .mhd h3{margin:0; font-size:16px}
.admin-dialog .mbd{padding:16px}
.icon-btn{
  width: 44px; height: 44px;
  display:inline-flex; align-items:center; justify-content:center;
  border-radius: 14px;
  border:1px solid var(--border);
  background: var(--card);
  cursor:pointer;
}
.icon-btn:hover{box-shadow: var(--shadow); border-color:#d1d5db}
.toast.show{display:block}
.toast strong{display:block; margin-bottom:4px}
.toast span{color:var(--muted); font-size:13px}

/* متجر الزبائن */
.shop-head{display:flex; gap:12px; align-items:center; justify-content:space-between; flex-wrap:wrap}
.shop-brand{display:flex; gap:12px; align-items:center}
.shop-brand img{width:44px; height:44px; border-radius:14px; border:1px solid var(--border); object-fit:cover; background:white}
.shop-brand .meta strong{font-size:16px}
.shop-brand .meta span{display:block; font-size:12px; color:var(--muted)}

.products{display:grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap:14px}
@media(max-width:1100px){.products{grid-template-columns: repeat(3, minmax(0, 1fr));}}
@media(max-width:820px){.products{grid-template-columns: repeat(2, minmax(0, 1fr));}}
@media(max-width:520px){.products{grid-template-columns: 1fr;}}

.prod{border:1px solid var(--border); border-radius:18px; background:white; overflow:hidden; box-shadow: 0 10px 22px rgba(2,6,23,.06)}
.prod .img{aspect-ratio: 1 / 1; position:relative; overflow:hidden; background:rgba(148,163,184,.18); display:flex; align-items:center; justify-content:center}
.prod .img img{width:100%; height:100%; object-fit:cover; opacity:0; transition: opacity .2s ease}
.prod .img img.loaded{opacity:1}

/* Image shimmer placeholder */
.shimmer{
  position:absolute;
  inset:0;
  background: rgba(148,163,184,.18);
}
.shimmer::after{
  content:"";
  position:absolute;
  top:0;
  left:-60%;
  width:60%;
  height:100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
  animation: shimmerMove 1.2s infinite;
}
@keyframes shimmerMove{
  0%{ transform: translateX(-40%); }
  100%{ transform: translateX(260%); }
}
.noimg{
  color: var(--muted);
  font-size: 12px;
}

/* Delivery methods */
.delivery-methods{display:flex; gap:10px; flex-wrap:wrap}
.delivery-methods .dm{
  display:flex; gap:8px; align-items:center;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius: 14px;
  background: rgba(2,6,23,.02);
  cursor:pointer;
  user-select:none;
}
.delivery-methods .dm input{accent-color: var(--primary)}
.delivery-methods .dm span{font-weight:700; font-size:13px}

.map{height:280px; border:1px solid var(--border); border-radius:16px; overflow:hidden; background:rgba(148,163,184,.12)}

.prod .bd{padding:12px}
.prod h3{margin:0 0 6px; font-size:15px}
.prod .meta{display:flex; align-items:center; justify-content:space-between; gap:10px}
.prod .meta span{color:var(--muted); font-size:12px}

.cart-dock{position:fixed; bottom:18px; right:18px; z-index:20}
.cart-panel{position:fixed; bottom:80px; right:18px; width:min(420px, calc(100vw - 36px)); max-height: calc(100vh - 120px); overflow:auto; display:none}
.cart-panel.show{display:block}

.footer{color:var(--muted); font-size:12px; text-align:center; padding:18px 0}


/* ─────────────────────────────────────────────────────────────────────────────
   Storefront UI Upgrade (V12.1)
   ─────────────────────────────────────────────────────────────────────────── */
.topbar{
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2500;
  will-change: transform;
  backdrop-filter: blur(10px);
  background: rgba(246,247,251,.92);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(2,6,23,.06);
}


.nav .icon-btn{
  width: 40px;
  height: 40px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: 0 10px 22px rgba(15,23,42,.06);
}

.products{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
@media (min-width: 760px){
  .products{ grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
}
@media (min-width: 1100px){
  .products{ grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
}

.prod{
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 18px 38px rgba(15,23,42,.06);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  cursor: pointer;
}
.prod:hover{
  transform: translateY(-2px);
  box-shadow: 0 26px 55px rgba(15,23,42,.10);
  border-color: color-mix(in srgb, var(--primary) 24%, var(--border));
}
.prod .img{
  height: 160px;
  background: linear-gradient(180deg, rgba(99,102,241,.10), rgba(148,163,184,.05));
  display:flex;
  align-items:center;
  justify-content:center;
}
.prod .img img{
  width:100%;
  height:100%;
  object-fit: cover;
  display:block;
}
.prod .img .noimg{
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(148,163,184,.18);
  border: 1px dashed rgba(148,163,184,.55);
  font-size: 28px;
}
.prod .bd{ padding: 12px 12px 14px; }
.prod h3{
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 800;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 38px;
}
.prod .meta{
  margin-top: 8px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 8px;
}
.prod .meta .cat{
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 62%;
}
.prod .meta .price{
  font-weight: 900;
  font-size: 13px;
}
.prod .actions{
  display:flex;
  gap: 10px;
  margin-top: 12px;
}
.prod .actions .btn{
  flex: 1;
  border-radius: 14px;
  padding: 10px 10px;
}
.btn.ghost{
  background: transparent;
  border: 1px solid var(--border);
}
.btn.ghost:hover{
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  background: rgba(99,102,241,.06);
}

/* Sort select */
.select{
  appearance: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  color: var(--text);
  font-weight: 700;
  min-width: 170px;
}

/* Product modal */
.modal{
  position: fixed;
  inset: 0;
  display:none;
  align-items: center;
  justify-content: center;
  background: rgba(15,23,42,.42);
  backdrop-filter: blur(8px);
  z-index: 1100;
}
.modal.show{ display:flex; }
.modal .sheet{
  width: min(980px, calc(100vw - 24px));
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 30px 70px rgba(15,23,42,.25);
  overflow:hidden;
}
.modal .sheet .hd{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.modal .sheet .hd strong{
  font-size: 16px;
  font-weight: 900;
}
.modal .sheet .content{
  display:grid;
  grid-template-columns: 1fr;
}
@media (min-width: 860px){
  .modal .sheet .content{ grid-template-columns: 1.1fr .9fr; }
}
.pm-img{
  min-height: 320px;
  background: linear-gradient(180deg, rgba(99,102,241,.10), rgba(148,163,184,.05));
  display:flex;
  align-items:center;
  justify-content:center;
}
.pm-img img{
  width:100%;
  height:100%;
  object-fit: cover;
  display:block;
}
.pm-noimg{
  width: 86px;
  height: 86px;
  border-radius: 22px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(148,163,184,.18);
  border: 1px dashed rgba(148,163,184,.55);
  font-size: 34px;
}
.pm-info{
  padding: 16px;
}
.pm-info .k{
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}
.pm-info .price{
  font-size: 18px;
  font-weight: 1000;
  margin-top: 10px;
}
.pm-row{
  display:flex;
  gap: 10px;
  align-items:center;
  margin-top: 14px;
}
.pm-row input{
  width: 110px;
  text-align: center;
}


@media (max-width: 640px){
  body{ padding-top: 86px; }
  .topbar .inner{ padding: 12px 14px; }
}
