/* PWA Install — چت‌بات اتد پلاس */
body.chat-pwa-lock {
  overflow: hidden !important;
}

.chat-pwa-overlay {
  position: fixed;
  inset: 0;
  z-index: 99998;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0.28s ease;
  pointer-events: none;
}
.chat-pwa-overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.chat-pwa-card {
  position: fixed;
  z-index: 99999;
  font-family: 'Vazirmatn', system-ui, sans-serif;
  direction: rtl;
  background: #ffffff;
  color: #0f172a;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -12px 48px rgba(15, 23, 42, 0.22);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-bottom: none;
  overflow: hidden;
  opacity: 0;
  transform: translateY(100%);
  transition: opacity 0.32s ease, transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 100%;
  max-height: min(88vh, 640px);
  display: flex;
  flex-direction: column;
}
.chat-pwa-card[hidden] {
  display: none !important;
}
.chat-pwa-card.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.chat-pwa-sheet-handle {
  display: block;
  width: 44px;
  height: 4px;
  border-radius: 99px;
  background: #cbd5e1;
  margin: 10px auto 4px;
  flex-shrink: 0;
}

.chat-pwa-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 20px 14px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  color: #fff;
  position: relative;
  flex-shrink: 0;
}

.chat-pwa-logo {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.55rem;
}

.chat-pwa-head-text {
  flex: 1;
  min-width: 0;
  padding-left: 36px;
}

.chat-pwa-head-text h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.45;
}

.chat-pwa-head-text p {
  margin: 0;
  font-size: 0.82rem;
  opacity: 0.82;
  line-height: 1.65;
}

.chat-pwa-close {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 2;
}
.chat-pwa-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

.chat-pwa-body {
  padding: 18px 20px calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.chat-pwa-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.chat-pwa-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  color: #334155;
  font-weight: 600;
  line-height: 1.55;
}

.chat-pwa-feature-icon {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: #eef2ff;
  color: #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.chat-pwa-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-pwa-btn-primary {
  width: 100%;
  min-height: 48px;
  padding: 13px 18px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.32);
}
.chat-pwa-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(59, 130, 246, 0.4);
}

.chat-pwa-btn-ghost {
  width: 100%;
  min-height: 44px;
  padding: 12px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #f8fafc;
  color: #64748b;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.chat-pwa-btn-ghost:hover {
  background: #f1f5f9;
}

.chat-pwa-ios-hint {
  display: none;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 12px;
  font-size: 0.8rem;
  line-height: 1.75;
  color: #92400e;
}

/* دسکتاپ: کارت مرکزی */
@media (min-width: 768px) {
  .chat-pwa-card {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.96);
    width: min(440px, calc(100vw - 32px));
    max-width: 440px;
    border-radius: 22px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.22);
    max-height: min(90vh, 620px);
  }
  .chat-pwa-card.show {
    transform: translate(-50%, -50%) scale(1);
  }
  .chat-pwa-sheet-handle {
    display: none;
  }
  .chat-pwa-body {
    padding-bottom: 22px;
  }
}

/* دکمهٔ نصب در هدر */
.chat-pwa-header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #2563eb;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.chat-pwa-header-btn[hidden] {
  display: none !important;
}
.chat-pwa-header-btn svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chat-pwa-header-btn:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}
.ch-actions .chat-pwa-header-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
}
.ch-actions .chat-pwa-header-btn svg {
  width: 15px;
  height: 15px;
}
