/* =========================================================================
 * دكاني — PWA Styles
 * -------------------------------------------------------------------------
 * 1) زر «تثبيت التطبيق» في أعلى شريط الموقع (سطح المكتب + الجوال).
 * 2) بانر إرشادات iOS (iPhone/iPad) — شريط أسفل الشاشة قابل للإغلاق.
 * 3) نافذة الخطوات اليدوية للمتصفحات غير الداعمة.
 * 4) مساحة أمان أدنى أسفل الشاشة لسفاري (env(safe-area-inset-bottom)).
 * ========================================================================= */

/* -------------------- زر التثبيت في الترويسة (سطح المكتب) --------------- */

.pwa-install-header {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border: 2px solid #0d9f6e;
  border-radius: 10px;
  background: #ffffff;
  color: #0a8059;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
  transition: background .15s, box-shadow .15s, transform .1s, border-color .15s;
}

.pwa-install-header:hover {
  background: #e6f7f0;
  border-color: #0a8059;
  box-shadow: 0 4px 12px rgba(13, 159, 110, .25);
  transform: translateY(-1px);
}

.pwa-install-header:active {
  transform: scale(.97);
}

.pwa-install-header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: linear-gradient(135deg, #0d9f6e, #0a8059);
  color: #ffffff;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, .35);
  flex: 0 0 auto;
}

/* ------------------- زر التثبيت في شريط الجوال -------------------------- */

.mobile-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pwa-install-mobile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #0d9f6e, #0a8059);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(13, 159, 110, .35), inset 0 1px 1px rgba(255, 255, 255, .25);
  cursor: pointer;
  transition: transform .1s, box-shadow .15s, filter .15s;
}

.pwa-install-mobile:hover {
  filter: brightness(1.06);
  box-shadow: 0 4px 14px rgba(13, 159, 110, .45), inset 0 1px 1px rgba(255, 255, 255, .25);
}

.pwa-install-mobile:active {
  transform: scale(.9);
}

/* الزر مثبّت التطبيق → إخفاء كامل */
.js-pwa-install.pwa-hidden {
  display: none !important;
}

/* --------------------------- بانر iOS ---------------------------------- */

#pwa-ios-host {
  position: fixed;
  inset-inline: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 9999;
  pointer-events: none;              /* الحاوية لا تحجب النقر */
}

.pwa-ios-banner {
  pointer-events: auto;              /* البانر نفسه يستقبل النقرات */
  background: #ffffff;
  border: 1px solid #dcfce7;
  border-radius: 18px;
  box-shadow: 0 -8px 40px rgba(22, 101, 52, 0.18);
  padding: 16px 16px 14px;
  direction: rtl;
  font-family: inherit;
  transform: translateY(120%);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
}

.pwa-ios-banner.pwa-ios-show {
  transform: translateY(0);
  opacity: 1;
}

.pwa-ios-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pwa-ios-icon {
  font-size: 26px;
}

.pwa-ios-title {
  flex: 1;
  font-size: 15px;
  font-weight: 800;
  color: #166534;
}

.pwa-ios-close {
  background: #f3f4f6;
  color: #4b5563;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.pwa-ios-close:hover {
  background: #e5e7eb;
}

/* السهم الإشاري نحو زر المشاركة */
.pwa-ios-arrow {
  display: flex;
  justify-content: flex-end;
  margin: 2px -6px 6px 0;
  pointer-events: none;
}

.pwa-ios-arrow svg {
  animation: pwa-nudge 1.6s ease-in-out infinite;
}

@keyframes pwa-nudge {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(-6px); }
}

/* خطوات التثبيت */
.pwa-ios-steps {
  margin: 0;
  padding-inline-start: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pwa-ios-steps li {
  font-size: 13px;
  line-height: 1.6;
  color: #374151;
}

.pwa-ios-shareicon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: #eef2ff;
  color: #4f46e5;
  font-size: 12px;
  vertical-align: middle;
}

/* ------------------- نافذة الخطوات اليدوية ------------------------------ */

.pwa-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 24, 39, .55);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.pwa-modal-overlay.pwa-modal-show {
  opacity: 1;
  pointer-events: auto;
}

.pwa-modal {
  width: 100%;
  max-width: 400px;
  direction: rtl;
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
  padding: 22px 22px 18px;
  transform: translateY(14px) scale(.98);
  transition: transform .25s cubic-bezier(.22, 1, .36, 1);
}

.pwa-modal-show .pwa-modal {
  transform: translateY(0) scale(1);
}

.pwa-modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.pwa-modal-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #e6f7f0;
  color: #0a8059;
}

.pwa-modal h3 {
  margin: 0;
  font-size: 1.05rem;
  color: #111827;
}

.pwa-modal-sub {
  margin: 0 0 12px;
  font-size: .85rem;
  color: #6b7280;
}

.pwa-modal-steps {
  margin: 0;
  padding-inline-start: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pwa-modal-steps li {
  font-size: .9rem;
  line-height: 1.6;
  color: #374151;
}

.pwa-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  background: #eef2ff;
  color: #4f46e5;
  font-size: .8rem;
  font-weight: 800;
  vertical-align: middle;
}

.pwa-modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.pwa-modal-btn {
  border: none;
  border-radius: 10px;
  padding: 9px 22px;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  background: #0d9f6e;
  color: #ffffff;
  transition: background .15s;
}

.pwa-modal-btn:hover {
  background: #0a8059;
}

/* ------------------------- تحسينات الجوال ------------------------------ */

/* لا نعرض بانر iOS على الشاشات الواسعة غير الجوال */
@media (min-width: 768px) {
  #pwa-ios-host { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .pwa-ios-arrow svg,
  .pwa-ios-banner,
  .pwa-modal-overlay,
  .pwa-modal { animation: none; transition: none; }
}
