/* ══════════════════════════════════════════════════════════════════════
   أنماط واجهة تطبيق الويب (pwa.js): بطاقة التثبيت، تنبيه التحديث،
   مؤشّر الاتصال. كلُّ الأسماء بالبادئة rpwa- حتى لا تصطدم بأنماط الصفحات.
   ملفٌّ خارجيٌّ لا <style> محقون: سياسةُ أمان المحتوى تسمح بـ 'self'.
   ══════════════════════════════════════════════════════════════════════ */
.rpwa-root{
  --rpwa-navy:#1B2440; --rpwa-navy2:#2A3557; --rpwa-blue:#2F6FED; --rpwa-ink:#1E2A3E;
  --rpwa-muted:#5B6B85; --rpwa-line:#E1E9F5; --rpwa-ok:#1E7A46; --rpwa-warn:#B3461E;
  font-family:'Tajawal','Segoe UI',system-ui,-apple-system,'Noto Sans Arabic',Tahoma,sans-serif;
  font-size:14px; line-height:1.6; color:var(--rpwa-ink); direction:rtl; text-align:right;
}
.rpwa-root *{box-sizing:border-box}

/* ── حاوية أسفل الشاشة ────────────────────────────────────────────── */
.rpwa-dock{
  position:fixed; z-index:2147483000; left:50%; transform:translateX(-50%);
  bottom:calc(14px + env(safe-area-inset-bottom, 0px));
  width:min(440px, calc(100vw - 24px)); display:flex; flex-direction:column; gap:10px;
  pointer-events:none;
}
.rpwa-dock > *{pointer-events:auto}

/* ── بطاقة التثبيت / تلميح iOS ────────────────────────────────────── */
.rpwa-card{
  display:flex; align-items:center; gap:14px; padding:14px 16px;
  background:#fff; border:1px solid var(--rpwa-line); border-radius:16px;
  box-shadow:0 14px 40px rgba(27,36,64,.18), 0 2px 6px rgba(27,36,64,.08);
  animation:rpwa-up .32s cubic-bezier(.2,.8,.2,1) both;
}
.rpwa-card img{width:48px;height:48px;border-radius:13px;flex:0 0 48px}
.rpwa-bell{width:48px;height:48px;border-radius:14px;background:#EEF3FF;color:var(--rpwa-blue);display:flex;align-items:center;justify-content:center;flex:0 0 48px}
.rpwa-bell svg{width:24px;height:24px}
.rpwa-card .rpwa-text{flex:1 1 auto;min-width:0}
.rpwa-card .rpwa-title{font-weight:800;font-size:15px;margin:0 0 2px}
.rpwa-card .rpwa-sub{color:var(--rpwa-muted);font-size:13px;margin:0}
.rpwa-card .rpwa-sub svg{width:15px;height:15px;vertical-align:-3px;margin:0 2px;stroke:var(--rpwa-blue)}
.rpwa-actions{display:flex;flex-direction:column;gap:6px;flex:0 0 auto}

.rpwa-btn{
  appearance:none; border:0; border-radius:10px; padding:8px 14px; cursor:pointer;
  font:inherit; font-weight:700; font-size:13.5px; line-height:1.3; white-space:nowrap;
  background:var(--rpwa-blue); color:#fff; box-shadow:0 4px 12px rgba(47,111,237,.3);
  transition:transform .12s ease, filter .12s ease;
}
.rpwa-btn:hover{filter:brightness(1.06)}
.rpwa-btn:active{transform:translateY(1px)}
.rpwa-btn.rpwa-ghost{background:transparent;color:var(--rpwa-muted);box-shadow:none;padding:6px 10px}
.rpwa-btn.rpwa-ghost:hover{color:var(--rpwa-ink);background:#F4F7FB}
.rpwa-btn.rpwa-link{padding:2px 0;margin-top:4px;font-size:12.5px;color:var(--rpwa-blue);text-decoration:underline;text-underline-offset:3px}
.rpwa-btn.rpwa-link:hover{background:transparent;color:#1F56C4}

/* ── رمز QR: في البطاقة (على الحاسوب) وفي اللوحة المكبَّرة ────────────── */
.rpwa-card.rpwa-has-qr{align-items:flex-start}
.rpwa-dock:has(.rpwa-has-qr){width:min(520px, calc(100vw - 24px))}
.rpwa-qr-btn{appearance:none;border:1px solid var(--rpwa-line);background:#fff;border-radius:12px;padding:4px;cursor:zoom-in;flex:0 0 auto;line-height:0}
.rpwa-qr-btn:hover{border-color:var(--rpwa-blue)}
.rpwa-qr{width:96px;height:96px;display:block;border-radius:8px}
.rpwa-overlay{
  position:fixed; inset:0; z-index:2147483002; display:flex; align-items:center; justify-content:center;
  background:rgba(27,36,64,.55); padding:16px; animation:rpwa-fade .2s ease both;
}
.rpwa-panel{
  background:#fff; border-radius:20px; padding:22px 24px 20px; text-align:center;
  width:min(360px, 100%); box-shadow:0 24px 60px rgba(27,36,64,.35);
  animation:rpwa-up .28s cubic-bezier(.2,.8,.2,1) both;
}
.rpwa-panel .rpwa-title{font-weight:800;font-size:17px;margin:0 0 12px}
.rpwa-panel .rpwa-sub{color:var(--rpwa-muted);font-size:13px;margin:4px 0}
.rpwa-panel .rpwa-btn{margin-top:14px;padding:9px 26px}
.rpwa-qr-big{width:240px;height:240px;max-width:100%;display:block;margin:0 auto;border:1px solid var(--rpwa-line);border-radius:14px;padding:8px;background:#fff}
.rpwa-url{margin:10px 0 6px;font-weight:700;font-size:14px;color:var(--rpwa-navy);font-family:'IBM Plex Mono',ui-monospace,Consolas,monospace;letter-spacing:.2px}

/* ── تنبيه التحديث ────────────────────────────────────────────────── */
.rpwa-toast{
  display:flex; align-items:center; gap:12px; padding:12px 14px 12px 16px;
  background:linear-gradient(180deg,var(--rpwa-navy2),var(--rpwa-navy)); color:#fff;
  border-radius:14px; box-shadow:0 14px 40px rgba(27,36,64,.28);
  animation:rpwa-up .32s cubic-bezier(.2,.8,.2,1) both;
}
.rpwa-toast .rpwa-text{flex:1 1 auto}
.rpwa-toast .rpwa-title{font-weight:800;font-size:14.5px;margin:0}
.rpwa-toast .rpwa-sub{opacity:.78;font-size:12.5px;margin:0}
.rpwa-toast .rpwa-btn{background:#fff;color:var(--rpwa-navy);box-shadow:none}
.rpwa-toast .rpwa-btn.rpwa-ghost{background:transparent;color:rgba(255,255,255,.75)}
.rpwa-toast .rpwa-btn.rpwa-ghost:hover{color:#fff;background:rgba(255,255,255,.1)}

/* ── مؤشّر الاتصال أعلى الشاشة ────────────────────────────────────── */
.rpwa-net{
  position:fixed; z-index:2147483001; top:calc(10px + env(safe-area-inset-top, 0px)); left:50%;
  transform:translateX(-50%); padding:7px 14px 7px 12px; border-radius:999px;
  display:flex; align-items:center; gap:8px; font-weight:700; font-size:13px; color:#fff;
  background:var(--rpwa-warn); box-shadow:0 8px 24px rgba(0,0,0,.22);
  animation:rpwa-down .28s cubic-bezier(.2,.8,.2,1) both; max-width:calc(100vw - 24px);
}
.rpwa-net.rpwa-online{background:var(--rpwa-ok)}
.rpwa-net svg{width:16px;height:16px;flex:0 0 16px}
.rpwa-net .rpwa-dot{width:8px;height:8px;border-radius:50%;background:#fff;opacity:.9;animation:rpwa-pulse 1.4s ease-in-out infinite}
.rpwa-net.rpwa-online .rpwa-dot{animation:none}

.rpwa-hide{animation:rpwa-out .22s ease both}

@keyframes rpwa-up{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:none}}
@keyframes rpwa-fade{from{opacity:0}to{opacity:1}}
@keyframes rpwa-down{from{opacity:0;transform:translate(-50%,-10px)}to{opacity:1;transform:translate(-50%,0)}}
@keyframes rpwa-out{to{opacity:0;transform:translateY(8px)}}
@keyframes rpwa-pulse{0%,100%{opacity:.35}50%{opacity:1}}

@media (max-width:420px){
  .rpwa-card{padding:12px 12px}
  .rpwa-card img{width:42px;height:42px;flex-basis:42px;border-radius:11px}
  .rpwa-actions{flex-direction:row;align-items:center}
}
@media (prefers-reduced-motion: reduce){
  .rpwa-card,.rpwa-toast,.rpwa-net,.rpwa-hide{animation:none}
  .rpwa-net .rpwa-dot{animation:none}
}
@media print{ .rpwa-root{display:none !important} }
