/* ============================================
   Parsexpress — PWA / iOS Specific Styles
   استایل‌های مخصوص PWA و آیفون
   ============================================ */

/* ── Safe Area Variables ──────────────────── */
:root {
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}

/* ── Smooth Momentum Scrolling (iOS) ─────── */
html {
  -webkit-overflow-scrolling: touch;
  -webkit-text-size-adjust: 100%;
}

/* ── Disable tap highlight on iOS ──────────  */
* {
  -webkit-tap-highlight-color: transparent;
}
button, a, [role="button"] {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ── Bottom Navigation — Safe Area ─────────  */
.mobile-bottom-nav {
  padding-bottom: max(var(--sab), 12px);
  /* Ensure nav sits above iOS home indicator */
}
.mobile-bottom-nav ul {
  padding-bottom: 0;
}

/* ── Header — Status Bar Safe Area ─────────
   In standalone PWA mode the status bar
   overlaps the fixed header on iOS.           */
@media all and (display-mode: standalone) {
  .header {
    padding-top: var(--sat);
  }
  body {
    /* Body should account for status bar */
    padding-top: 0;
  }
  /* Push page content below the now-taller header */
  .hero,
  main > *:first-child,
  .section:first-of-type {
    /* The header handles its own padding now */
  }
}

/* ── Fix 100vh on iOS ───────────────────────
   Use dvh (dynamic viewport height) so
   it accounts for the Safari toolbar.         */
.hero {
  min-height: clamp(280px, 70dvh, 680px);
}
.hero-slide {
  min-height: clamp(280px, 70dvh, 680px);
}

/* Fallback for browsers that don't support dvh */
@supports not (height: 1dvh) {
  .hero,
  .hero-slide {
    min-height: clamp(280px, 70vh, 680px);
  }
}

/* ── Cart Drawer — Safe Area ────────────── */
.cart-overlay {
  padding-bottom: var(--sab);
}
.cart-panel {
  padding-bottom: max(var(--sab), 16px);
}

/* ── Modal Drawers — Safe Area ──────────── */
.mobile-drawer {
  padding-bottom: max(var(--sab), 24px);
}

/* ── Auth Modal — Safe Area ─────────────── */
.modal {
  padding-bottom: max(var(--sab), 24px);
}

/* ── Prevent Content Under Notch ─────────── */
.header-inner {
  padding-left: max(var(--sal), 16px);
  padding-right: max(var(--sar), 16px);
}
.container {
  padding-left: max(var(--sal), var(--space-md));
  padding-right: max(var(--sar), var(--space-md));
}

/* ── iOS Install Banner ─────────────────── */
#pwa-install-banner {
  position: fixed;
  bottom: max(var(--sab), 80px); /* sits above bottom nav */
  left: 16px;
  right: 16px;
  z-index: 9999;
  transform: translateY(120%);
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
}
#pwa-install-banner.pwa-banner-visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all;
}

.pwa-banner-inner {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 20px;
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 0 40px rgba(212, 175, 55, 0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: relative;
}

.pwa-banner-icon {
  flex-shrink: 0;
}
.pwa-banner-icon img {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.pwa-banner-content {
  flex: 1;
  min-width: 0;
}

.pwa-banner-title {
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
  line-height: 1.3;
}

[dir="rtl"] .pwa-banner-title {
  font-family: var(--font-fa, 'Vazirmatn', sans-serif);
}

.pwa-banner-body {
  font-size: 12px;
  color: rgba(255,255,255,0.65);
  line-height: 1.5;
  margin-bottom: 10px;
}

.pwa-banner-steps {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
  color: #D4AF37;
  font-weight: 600;
}

.pwa-step {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 20px;
  padding: 4px 10px;
}

.pwa-share-icon {
  width: 13px;
  height: 13px;
  stroke: #D4AF37;
  flex-shrink: 0;
}

.pwa-step-arrow {
  color: rgba(212,175,55,0.5);
  font-size: 12px;
}

/* Android install action buttons */
.pwa-banner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.pwa-install-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #B22222, #8B0000);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  min-height: 36px;
  box-shadow: 0 4px 14px rgba(178, 34, 34, 0.45);
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.pwa-install-btn:active {
  transform: scale(0.96);
  box-shadow: 0 2px 8px rgba(178, 34, 34, 0.3);
}

.pwa-later-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 12px;
  cursor: pointer;
  padding: 8px 4px;
  min-height: 36px;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s;
}
.pwa-later-btn:hover { color: rgba(255,255,255,0.8); }

/* Manual hint button (when native prompt not available) */
.pwa-manual-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.85);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  min-height: 36px;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.pwa-manual-btn:active {
  background: rgba(255,255,255,0.15);
}

/* Android vs iOS caret visibility */
#pwa-install-banner[data-platform="android"] .pwa-banner-caret {
  display: none;
}
#pwa-install-banner[data-platform="ios"] .pwa-banner-caret {
  display: block;
}

.pwa-banner-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  cursor: pointer;
  padding: 0;
  min-height: unset;
}
.pwa-banner-close:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

/* Caret arrow pointing down */
.pwa-banner-caret {
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid rgba(212, 175, 55, 0.35);
  margin: 0 auto;
  position: relative;
}
.pwa-banner-caret::before {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 9px solid #1a1a2e;
  top: -11px;
  left: -9px;
}

/* ── PWA Splash / Loading Screen ───────────
   Applied when launched from Home Screen.   */
@media all and (display-mode: standalone) {
  body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: #080C10;
    z-index: 99999;
    opacity: 1;
    animation: pwa-splash-fade 0.6s ease 0.5s forwards;
    pointer-events: none;
  }
}

@keyframes pwa-splash-fade {
  to { opacity: 0; pointer-events: none; }
}

/* ── Overscroll Color (iOS Chrome) ─────── */
html {
  background-color: #080C10;
  overscroll-behavior-y: contain;
}

/* ── Focus Styles for Touch Devices ────── */
@media (hover: none) and (pointer: coarse) {
  .btn:hover {
    transform: none !important;
  }
  .btn:active {
    transform: scale(0.97) !important;
    transition: transform 0.1s ease !important;
  }
  .product-card:hover {
    transform: none !important;
  }
  .product-card:active {
    transform: scale(0.98) !important;
  }
  .category-card:hover {
    transform: none !important;
  }
  .category-card:active {
    transform: scale(0.97) !important;
  }
  .nav-btn:hover {
    transform: none !important;
  }
}

/* ── Larger Tap Targets on Mobile ──────── */
@media (max-width: 768px) {
  .nav-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 10px 14px;
  }
  .mobile-bottom-nav ul li a {
    padding: 10px 4px;
    min-height: 56px;
  }
  .cart-close {
    min-width: 44px;
    min-height: 44px;
  }
  .modal-close {
    min-width: 44px;
    min-height: 44px;
  }
}

/* ── iOS Input Zoom Prevention ──────────
   Prevents Safari from zooming when
   tapping on inputs (font-size >= 16px)  */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="search"],
select,
textarea {
  font-size: max(16px, 1em);
  -webkit-appearance: none;
  border-radius: var(--radius-sm, 8px);
}

/* ── Notch-aware padding for full-bleed sections ── */
.hero {
  padding-left: var(--sal);
  padding-right: var(--sar);
}
.stats-strip {
  padding-left: max(var(--sal), 0px);
  padding-right: max(var(--sar), 0px);
}

/* ── PWA mode: hide browser-styled scrollbars ── */
@media all and (display-mode: standalone) {
  ::-webkit-scrollbar { display: none; }
  * { scrollbar-width: none; }
}
