/**
 * متجر سعد — نسخة جوال (تجربة قريبة من تطبيق المتجر)
 * دعم آمن للمناطق (الشق)، تمرير لمس، أهداف لمس ≥44px، متصفحات WebKit/Samsung/Firefox
 */

/* ========= أساسيات الجوال العامة ========= */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@supports (padding: max(0px)) {
  body.page-heritage,
  body.gate-body,
  body.saad-chat-page,
  body.pricing-app-page {
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
  }
}

/* منع تكدّس أفقي غير مقصود */
body {
  overflow-x: clip;
}

@supports not (overflow-x: clip) {
  body {
    overflow-x: hidden;
  }
}

/* لمس: تقليل تأخير النقر المزدوج، تمييز لمس خفيف */
.app-tile,
.bundle-employees__cta,
.saad-store-ribbon__chip,
.saad-store-ribbon__cta,
.saad-mobile-app-nav__item,
.pricing-tier,
.btn {
  -webkit-tap-highlight-color: rgba(45, 79, 54, 0.12);
  touch-action: manipulation;
}

/* ========= شريط المتجر السفلي (مثل تطبيق الجوال) ========= */
.saad-mobile-app-nav {
  display: none;
}

@media (max-width: 900px) {
  .saad-mobile-app-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 150;
    justify-content: space-around;
    align-items: stretch;
    gap: 0.15rem;
    padding: 0.35rem 0.25rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
    padding-left: max(0.35rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.35rem, env(safe-area-inset-right, 0px));
    background: linear-gradient(180deg, rgba(21, 43, 36, 0.97), rgba(15, 31, 26, 0.99));
    border-top: 1px solid rgba(166, 137, 102, 0.5);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  .saad-mobile-app-nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: 48px;
    max-width: 25%;
    padding: 0.35rem 0.2rem;
    border-radius: 14px;
    text-decoration: none;
    color: #f2f0e4;
    font-size: 0.62rem;
    font-weight: 800;
    line-height: 1.15;
    text-align: center;
    transition: background 0.2s ease, color 0.2s ease;
  }

  .saad-mobile-app-nav__item:active {
    background: rgba(166, 137, 102, 0.22);
  }

  .saad-mobile-app-nav__item[aria-current="page"] {
    color: #c4b896;
    background: rgba(166, 137, 102, 0.25);
    border-radius: 12px;
  }

  .saad-mobile-app-nav__icon {
    font-size: 1.35rem;
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
  }

  /* مساحة للمحتوى فوق الشريط */
  body.saad-mobile-store-body {
    padding-bottom: calc(4.35rem + env(safe-area-inset-bottom, 0px));
  }

  /* ويدجت الدعم فوق الشريط */
  body.saad-mobile-store-body #saad-support-dock {
    bottom: calc(4.65rem + env(safe-area-inset-bottom, 0px)) !important;
  }

  body.saad-mobile-store-body.saad-chat-page #saad-support-dock {
    bottom: calc(9.25rem + env(safe-area-inset-bottom, 0px)) !important;
  }

  html[dir="rtl"] body.saad-mobile-store-body.saad-support-widget-active .support-panel,
  html[dir="ltr"] body.saad-mobile-store-body.saad-support-widget-active .support-panel,
  body.saad-mobile-store-body #saad-lite-support-panel.support-panel {
    bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px)) !important;
  }

  body.saad-mobile-store-body.saad-chat-page #saad-lite-support-panel.support-panel,
  html[dir="rtl"] body.saad-mobile-store-body.saad-chat-page.saad-support-widget-active .support-panel,
  html[dir="ltr"] body.saad-mobile-store-body.saad-chat-page.saad-support-widget-active .support-panel {
    bottom: calc(10rem + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* ========= شريط المتجر العلوي (ribbon) — تمرير أفقي للشرائح ========= */
@media (max-width: 640px) {
  .saad-store-ribbon {
    padding: 0.65rem 0.65rem 0.85rem;
  }

  .saad-store-ribbon__inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
  }

  .saad-store-ribbon__title {
    text-align: center;
    font-size: 0.95rem;
    line-height: 1.35;
  }

  .saad-store-ribbon__chips {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 0.45rem;
    padding: 0.2rem 0 0.45rem;
    margin: 0 -0.35rem;
    padding-inline: 0.35rem;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .saad-store-ribbon__chips::-webkit-scrollbar {
    display: none;
  }

  .saad-store-ribbon__chip {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-height: 44px;
    padding: 0.5rem 0.95rem;
    font-size: 0.8rem;
  }

  .saad-store-ribbon__cta {
    width: 100%;
    text-align: center;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1rem;
  }

  .saad-store-ribbon__hint {
    font-size: 0.65rem;
    line-height: 1.45;
  }

  .saad-store-ribbon__hint kbd {
    display: inline-block;
    margin-top: 0.2rem;
  }
}

/* ========= قسم متجر التطبيقات — كاروسيل أفقي على الهاتف ========= */
@media (max-width: 639px) {
  .saad-app-store-section {
    padding: 2rem 0 2.5rem;
  }

  .saad-app-store-section .section__head {
    padding-inline: 0.85rem;
  }

  .saad-app-store-section .section__title {
    font-size: clamp(1.25rem, 5.5vw, 1.65rem) !important;
    line-height: 1.25 !important;
  }

  .saad-app-store-section .section__desc {
    font-size: 0.88rem !important;
    line-height: 1.65 !important;
  }

  .app-product-grid {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: visible;
    gap: 0.75rem;
    padding: 0.5rem 0.85rem 1rem;
    margin-inline: 0;
    max-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 0.85rem;
    scrollbar-width: thin;
  }

  .app-product-grid::-webkit-scrollbar {
    height: 4px;
  }

  .app-product-grid::-webkit-scrollbar-thumb {
    background: rgba(45, 79, 54, 0.35);
    border-radius: 4px;
  }

  .app-tile {
    flex: 0 0 min(46vw, 168px);
    max-width: min(46vw, 168px);
    scroll-snap-align: start;
    min-height: 210px;
    padding: 1rem 0.65rem 1.1rem;
    border-radius: 20px;
  }

  .app-tile:active {
    transform: scale(0.98);
  }

  .app-tile__icon {
    font-size: 2.35rem;
  }

  .app-tile__name {
    font-size: 0.88rem;
  }

  .app-tile__tag {
    font-size: 0.7rem;
    min-height: auto;
  }

  .app-tile__from {
    font-size: 0.75rem;
  }

  .bundle-employees {
    padding: 0 0.85rem;
    margin-top: 1.5rem;
  }

  .bundle-employees__card {
    padding: 1.35rem 1.1rem 1.5rem;
    border-radius: 22px;
  }

  .bundle-employees__includes li {
    font-size: 0.8rem;
    padding: 0.6rem 0.65rem;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .bundle-employees__cta {
    max-width: none;
    min-height: 50px;
    font-size: 0.9rem;
  }
}

/* ========= صفحة التسعير — جوال ========= */
@media (max-width: 720px) {
  .pricing-app-page .wrap {
    padding-inline: 0.65rem;
  }

  .pricing-app-page .subpage-hero {
    padding-top: 1.5rem !important;
    padding-inline: 0.35rem;
  }

  .pricing-app-page .subpage-hero h1 {
    font-size: clamp(1.35rem, 6vw, 1.85rem) !important;
  }

  .pricing-tool-grid {
    padding: 0 0.35rem;
    gap: 1.1rem;
  }

  .pricing-tool-block {
    padding: 1.1rem 0.9rem 1.2rem;
    border-radius: 20px;
  }

  .pricing-tier {
    min-height: 88px;
    padding: 0.75rem 0.5rem;
  }

  .bundle-employees__price span {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.82rem;
  }
}

/* ========= نافذة الدردشة — شريط إدخال ومساحات آمنة ========= */
@media (max-width: 900px) {
  body.saad-chat-page.saad-mobile-store-body .saad-chat-wrap {
    padding-bottom: calc(10.5rem + env(safe-area-inset-bottom, 0px));
  }

  body.saad-chat-page .saad-chat-bar {
    padding-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
    padding-left: max(0.5rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.5rem, env(safe-area-inset-right, 0px));
  }

  body.saad-chat-page:not(.saad-mobile-store-body) .saad-chat-wrap {
    padding-bottom: 5rem;
  }

  .saad-chat-tools button {
    min-height: 40px;
    padding: 0.45rem 0.65rem;
  }

  .saad-theme-switcher button {
    min-height: 40px;
    padding: 0.45rem 0.75rem;
  }
}

/* ========= الهيدر والـ Hero — جوال ========= */
@media (max-width: 768px) {
  .site-header__inner {
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .hero-platform__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-platform__actions .btn {
    width: 100%;
    min-height: 48px;
    justify-content: center;
  }

  .hero-platform__inner {
    padding: 2.5rem 1rem 2rem;
  }
}

/* ========= تقليل الحركة (إتاحة النظام) ========= */
@media (prefers-reduced-motion: reduce) {
  .app-tile,
  .saad-store-ribbon__chip,
  .saad-store-ribbon__cta {
    transition: none !important;
  }

  .app-product-grid {
    scroll-behavior: auto;
  }
}
