/* ألوان وشكل مطابق لموقع AlAynTech (alayntech.com) — مأخوذة من الموقع بتاريخ 2026-11-13 */
:root {
  color-scheme: light;
  --red: #ef4237;        /* لون المتجر الأساسي (الأزرار، شارة الخصم) */
  --red-dark: #d8352b;
  --header: #dedede;     /* شريط الهيدر الرمادي */
  --bg: #f7f8fa;         /* خلفية الأقسام */
  --card: #ffffff;
  --ink: #050505;        /* النص والأسعار */
  --title: #58595b;      /* عناوين الأقسام */
  --muted: #7f8c8d;      /* اسم الماركة والنص الثانوي */
  --line: #e9ecef;
  --chip: #efefef;
  --ok: #198754;
  --warn: #b45309;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(0, 0, 0, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Cairo', system-ui, sans-serif;
  background: var(--bg); color: var(--ink);
  min-height: 100dvh; -webkit-tap-highlight-color: transparent;
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }

/* الهيدر — نفس شريط المتجر الرمادي مع اللوگو */
.top { background: var(--header); padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; }
.brand { display: flex; gap: 12px; align-items: center; justify-content: space-between; max-width: 560px; margin: 0 auto; }
.brand .logo { height: 40px; width: auto; display: block; }
.brand .titles { text-align: start; }
.brand h1 { font-size: 16px; font-weight: 800; margin: 0; line-height: 1.3; }
.brand p { font-size: 11px; margin: 0; color: #555; }

main { max-width: 560px; margin: 0 auto; padding: 18px 16px calc(env(safe-area-inset-bottom) + 24px); }

.btn-hero {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 12px;
  font: inherit; font-size: 22px; font-weight: 800;
  padding: 20px; border: 0; border-radius: var(--radius);
  background: var(--red); color: #fff; cursor: pointer;
  box-shadow: 0 8px 22px rgba(239, 66, 55, .30);
}
.btn-hero:active { background: var(--red-dark); transform: scale(.98); }
.file-fallback { display: block; text-align: center; margin: 10px 0 18px; color: var(--muted); font-size: 14px; text-decoration: underline; cursor: pointer; }

.search { display: flex; gap: 8px; }
.search input {
  flex: 1; min-width: 0; font: inherit; font-size: 18px; font-weight: 700; letter-spacing: .5px;
  padding: 12px 16px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--ink); text-align: left; box-shadow: var(--shadow);
}
.search input:focus { outline: none; border-color: var(--red); }
.search input::placeholder { font-weight: 400; font-size: 15px; letter-spacing: 0; text-align: right; color: #9aa3a4; }
.btn-primary {
  font: inherit; font-weight: 700; font-size: 16px; padding: 0 22px; border: 0; border-radius: 999px;
  background: var(--ink); color: #fff; cursor: pointer;
}
.btn-primary:active { background: var(--red); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.chips small { color: var(--muted); }
.chip {
  font: inherit; font-size: 14px; font-weight: 600; direction: ltr;
  padding: 4px 14px; border-radius: 999px; border: 0;
  background: var(--chip); color: var(--ink); cursor: pointer;
}
.chip.on { background: var(--red); color: #fff; }

#result { margin-top: 18px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.best { display: grid; grid-template-columns: 1fr; gap: 10px; position: relative; }
.best .img { width: 100%; aspect-ratio: 4/3; object-fit: contain; background: #fff; border-radius: 12px; }

/* شارة الخصم — دائرة حمراء مثل "SAVE" بالمتجر */
.save {
  position: absolute; top: 14px; inset-inline-end: 14px; width: 64px; height: 64px; border-radius: 50%;
  background: var(--red); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800; font-size: 17px; line-height: 1; box-shadow: 0 4px 12px rgba(239, 66, 55, .35);
}
.save small { font-size: 10px; font-weight: 700; margin-top: 3px; letter-spacing: .5px; }

.brand-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; direction: ltr; text-align: right; }
.price { font-size: 38px; font-weight: 900; line-height: 1.15; color: var(--ink); direction: ltr; text-align: right; }
.price .cur { font-size: 18px; font-weight: 800; margin-inline-end: 6px; }
.old { color: var(--muted); text-decoration: line-through; font-size: 15px; font-weight: 600; direction: ltr; text-align: right; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: #fdecea; color: var(--red); }
.badge.ok { background: #e8f5ee; color: var(--ok); }
.badge.warn { background: #fef3c7; color: var(--warn); }
.pname { font-size: 17px; font-weight: 700; margin: 0; direction: ltr; text-align: right; unicode-bidi: plaintext; }
.meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.meta a { color: var(--red); font-weight: 700; text-decoration: none; }

.specs { margin-top: 12px; }
.specs h3 { font-size: 16px; margin: 0 0 8px; color: var(--title); }
.specs .sum { margin: 0 0 8px; font-weight: 600; }
.spec-list { margin: 0; padding-inline-start: 20px; line-height: 1.8; }
.spec-list li::marker { color: var(--red); }
.spec-list li { unicode-bidi: plaintext; }
.ai-note, .ai-src { font-size: 12px; color: var(--muted); margin: 10px 0 0; }
.ai-src a { color: var(--red); font-weight: 700; }
.sk { height: 14px; border-radius: 7px; margin: 10px 0; background: linear-gradient(90deg, var(--line), #fff, var(--line)); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
.sk.short { width: 60%; }
@keyframes sk { to { background-position: -200% 0; } }

.others h3, .recent h2 { font-size: 18px; font-weight: 800; color: var(--title); margin: 22px 0 10px; }
.row {
  display: flex; gap: 10px; align-items: center; width: 100%; text-align: inherit;
  background: var(--card); border: 0; border-radius: var(--radius); padding: 8px; margin-bottom: 10px;
  box-shadow: var(--shadow); font: inherit; color: inherit; cursor: pointer;
}
.row img { width: 60px; height: 60px; object-fit: contain; background: #fff; border-radius: 10px; flex: none; }
.row .n { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; direction: ltr; text-align: right; unicode-bidi: plaintext;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row .p { font-weight: 900; white-space: nowrap; color: var(--ink); direction: ltr; padding-inline-end: 6px; }

.empty { text-align: center; padding: 24px 16px; }
.empty b { display: block; font-size: 18px; margin-bottom: 6px; }

.recent { margin-top: 8px; }
.recent-head { display: flex; justify-content: space-between; align-items: baseline; }
.link { background: none; border: 0; color: var(--red); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
#recentList { list-style: none; padding: 0; margin: 0; }
#recentList:empty::after { content: 'ما كو عمليات بحث بعد.'; color: var(--muted); font-size: 14px; }

.disclaimer { font-size: 12px; color: var(--muted); margin-top: 24px; line-height: 1.7; }

/* الكاميرا */
.camera { position: fixed; inset: 0; background: #000; z-index: 10; }
.camera video { width: 100%; height: 100%; object-fit: cover; }
.guide {
  position: absolute; inset: 0; pointer-events: none; display: flex; flex-direction: column; align-items: center;
  /* الإطار يملي الشاشة تقريباً، ويترك مكان للأزرار تحت */
  padding: calc(env(safe-area-inset-top) + 56px) 4% calc(env(safe-area-inset-bottom) + 128px);
}
.frame { flex: 1; width: 100%; border-radius: 18px; border: 2px solid rgba(255,255,255,.9); box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); position: relative; }
/* زوايا حمراء بلون المتجر */
.frame::before, .frame::after { content: ''; position: absolute; width: 34px; height: 34px; border: 4px solid var(--red); }
.frame::before { top: -3px; inset-inline-start: -3px; border-inline-end: 0; border-bottom: 0; border-start-start-radius: 18px; }
.frame::after { bottom: -3px; inset-inline-end: -3px; border-inline-start: 0; border-top: 0; border-end-end-radius: 18px; }
.guide p {
  position: absolute; top: calc(env(safe-area-inset-top) + 12px); left: 0; right: 0; margin: 0;
  color: #fff; font-weight: 700; text-align: center; text-shadow: 0 1px 4px #000; line-height: 1.4;
}
.cam-bar {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 20px 28px calc(env(safe-area-inset-bottom) + 24px);
  display: flex; justify-content: space-between; align-items: center;
}
.shutter { width: 76px; height: 76px; border-radius: 50%; border: 5px solid #fff; background: var(--red); cursor: pointer; }
.shutter:active { background: var(--red-dark); }
.cam-btn { width: 52px; height: 52px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 22px; cursor: pointer; }
.cam-btn.on { background: #facc15; color: #000; }

.busy { position: fixed; inset: 0; z-index: 20; background: rgba(255,255,255,.92); color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; font-weight: 700; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 5px solid var(--line); border-top-color: var(--red); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

[hidden] { display: none !important; }
