/* ============================================================
   IC Popup — سیستم پاپ‌آپ مرکزی وبسایت
   استایل و انیمیشن دقیقاً مطابق PopupManager.tsx اپلیکیشن:
   – overlay: fade-in به 0.4 در 200ms
   – کارت: scale 0.95→1 + opacity 0→1 با spring-like 250ms
   ============================================================ */

.ic-popup {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: none;
}

.ic-popup[hidden] {
  display: none !important;
}

/* --- Overlay --- */
.ic-popup__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.2s ease;
  cursor: pointer;
  border: 0;
  padding: 0;
  margin: 0;
  pointer-events: auto;
}

.ic-popup.is-open {
  pointer-events: auto;
}

.ic-popup.is-open .ic-popup__overlay {
  opacity: 1;
}

/* --- Card --- */
.ic-popup__card {
  position: relative;
  z-index: 1;
  width: min(85%, 380px);
  background: #fff;
  border-radius: 24px;
  padding: 30px 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: auto;
}

.ic-popup.is-open .ic-popup__card {
  opacity: 1;
  transform: scale(1);
}

.ic-popup.is-app-gate .ic-popup__card,
.ic-popup.is-subscribe .ic-popup__card,
.ic-popup.is-use-app .ic-popup__card,
.ic-popup.is-upgrade-official .ic-popup__card,
.ic-popup.is-wallet-confirmation .ic-popup__card {
  width: min(80%, 400px);
  padding-top: 24px;
  padding-bottom: 30px;
}

/* --- نماد (آیکون / تصویر) --- */
.ic-popup__icon {
  width: 50px;
  height: 50px;
  margin-bottom: 8px;
  object-fit: contain;
}

.ic-popup__icon[hidden],
.ic-popup.is-app-gate .ic-popup__icon,
.ic-popup.is-use-app .ic-popup__icon {
  display: none !important;
}

/* --- عنوان --- */
.ic-popup__title {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 700;
  color: #2d3a4a;
  line-height: 1.5;
  text-align: center;
  width: 100%;
}

/* --- متن توضیح --- */
.ic-popup__message {
  margin: 0 0 6px;
  padding: 0 4px;
  font-size: 11.5px;
  color: #4a5a6a;
  line-height: 27px;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}

/* نوع دوم: فاصله عنوان تا متن بیشتر، فاصله متن تا دکمه‌ها کمتر */
.ic-popup.is-subscribe .ic-popup__icon {
  margin-bottom: 2px;
}

.ic-popup.is-subscribe .ic-popup__title {
  margin-top: 0;
  margin-bottom: 18px;
}

.ic-popup.is-subscribe .ic-popup__message {
  margin-bottom: 0;
}

.ic-popup.is-subscribe .ic-popup__actions {
  margin-top: 8px;
}

.ic-popup.is-upgrade-official .ic-popup__icon,
.ic-popup.is-wallet-confirmation .ic-popup__icon {
  display: none !important;
}

.ic-popup.is-upgrade-official .ic-popup__title,
.ic-popup.is-wallet-confirmation .ic-popup__title {
  margin-top: 0;
  margin-bottom: 15px;
}

.ic-popup.is-upgrade-official .ic-popup__message {
  margin-bottom: 0;
  color: #2d3a4a;
  line-height: 27px;
}

.ic-popup.is-wallet-confirmation .ic-popup__message {
  margin-bottom: 0;
  color: #2d3a4a;
  line-height: 27px;
}

.ic-popup.is-upgrade-official .ic-popup__actions {
  margin-top: 18px;
}

.ic-popup.is-wallet-confirmation .ic-popup__actions {
  margin-top: 5px;
}

/* نوع اول و سوم: دکمه‌های بازار / مایکت / دانلود مستقیم */
.ic-popup.is-app-gate .ic-popup__title,
.ic-popup.is-use-app .ic-popup__title {
  margin-bottom: 15px;
}

.ic-popup.is-app-gate .ic-popup__message,
.ic-popup.is-use-app .ic-popup__message {
  margin-bottom: 0;
}

.ic-popup.is-app-gate .ic-popup__stores,
.ic-popup.is-use-app .ic-popup__stores {
  margin-top: 23px;
  gap: 10px;
  width: 90%;
}

.ic-popup.is-app-gate .ic-popup__actions,
.ic-popup.is-use-app .ic-popup__actions {
  margin-top: 10px;
  width: 90%;
}

.ic-popup.is-app-gate .ic-popup__store-btn,
.ic-popup.is-use-app .ic-popup__store-btn {
  gap: 8px;
  height: 48px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 700;
}

.ic-popup.is-app-gate .ic-popup__store-icon,
.ic-popup.is-use-app .ic-popup__store-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex-shrink: 0;
}

.ic-popup.is-app-gate .ic-popup__store-btn--bazaar,
.ic-popup.is-use-app .ic-popup__store-btn--bazaar {
  background: #e7f6ec;
  color: #1f8a4c;
}

.ic-popup.is-app-gate .ic-popup__store-btn--myket,
.ic-popup.is-use-app .ic-popup__store-btn--myket {
  background: #e7f3fc;
  color: #2b8fd8;
}

.ic-popup.is-app-gate .ic-popup__btn--direct,
.ic-popup.is-use-app .ic-popup__btn--direct {
  background: #f0f2f5;
  color: #2d3a4a;
  border-radius: 16px;
  font-weight: 700;
  font-size: 13px;
}

/* --- دکمه‌ها --- */
.ic-popup__actions {
  display: flex;
  flex-direction: row;
  gap: 12px;
  width: 100%;
  margin-top: 20px;
  direction: rtl;
}

.ic-popup__btn {
  flex: 1;
  height: 50px;
  padding: 0 16px;
  border: 0;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: opacity 0.15s;
}

.ic-popup__btn:active {
  opacity: 0.75;
}

/* تأیید (آبی) */
.ic-popup__btn--confirm {
  background: #4e91e6;
  color: #fff;
}

/* لغو / بستن */
.ic-popup__btn--cancel {
  background: #f5f7fd;
  color: #2d3a4a;
}

/* دکمه‌های فروشگاه (بازار / مایکت) */
.ic-popup__stores {
  display: flex;
  flex-direction: row;
  gap: 10px;
  width: 100%;
  margin-top: 20px;
  direction: rtl;
  justify-content: center;
}

.ic-popup__store-btn {
  flex: 1;
  height: 50px;
  padding: 0 12px;
  border: 0;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: opacity 0.15s;
}

.ic-popup__store-btn--primary {
  background: #2d3a4a;
  color: #fff;
}

.ic-popup__store-btn--ghost {
  background: #f5f7fd;
  color: #2d3a4a;
}

.ic-popup__store-btn:active {
  opacity: 0.75;
}

/* --- تک‌دکمه (بدون فضای خالی کناری) --- */
.ic-popup__actions--single {
  justify-content: center;
}

.ic-popup__actions--single .ic-popup__btn {
  max-width: 200px;
}

/* --- نوع چهارم: پاپ قطعات مدار (CircuitModal component) --- */
.ic-popup__close {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  padding: 0;
  border-radius: 50%;
  background: #f1f1f3;
  cursor: pointer;
}

.ic-popup__close[hidden] {
  display: none !important;
}

.ic-popup__close img {
  width: 15px;
  height: 15px;
  opacity: 0.85;
}

.ic-popup__media {
  width: 110px;
  height: 110px;
  margin: 0 auto 15px;
}

.ic-popup__media[hidden],
.ic-popup__detail[hidden] {
  display: none !important;
}

.ic-popup__media-img {
  width: 110px;
  height: 110px;
  object-fit: contain;
  display: block;
}

.ic-popup__detail {
  margin: 0 0 15px;
  padding: 0 8px;
  font-size: 10.5px;
  line-height: 26px;
  color: #919aaf;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.ic-popup.is-component-gate .ic-popup__card {
  width: min(90%, 380px);
  padding: 30px;
  border-radius: 30px;
  overflow: hidden;
}

.ic-popup.is-component-gate .ic-popup__close {
  top: 20px;
  right: 20px;
}

.ic-popup.is-component-gate .ic-popup__icon {
  display: none !important;
}

.ic-popup.is-component-gate .ic-popup__title {
  margin: 0 0 20px;
  padding: 0 28px;
  font-size: 16px;
}

.ic-popup.is-component-gate .ic-popup__message {
  margin: 0 0 15px;
  padding: 0;
  font-size: 10.5px;
  line-height: 26px;
  color: #384152;
}

.ic-popup.is-component-gate .ic-popup__actions {
  flex-direction: column;
  gap: 10px;
  width: 98%;
  margin-top: 0;
}

.ic-popup.is-component-gate .ic-popup__actions--stack .ic-popup__btn {
  flex: none;
  width: 100%;
  max-width: none;
  font-weight: 400;
}

.ic-popup.is-component-gate .ic-popup__btn--confirm {
  height: 55px;
  border-radius: 17px;
  background: #4785ff;
  font-size: 10.7px;
}

.ic-popup.is-component-gate .ic-popup__btn--cancel {
  height: 60px;
  border-radius: 17px;
  background: #f0f5ff;
  color: #4785ff;
  font-size: 10.7px;
}

/* موبایل — عرض کارت، دکمه‌ها و فاصله متن کمی بیشتر */
@media (max-width: 800px) {
  .ic-popup {
    padding: 12px;
  }

  .ic-popup__card {
    width: min(88%, 396px);
    padding-left: 26px;
    padding-right: 26px;
  }

  .ic-popup.is-app-gate .ic-popup__card,
  .ic-popup.is-subscribe .ic-popup__card,
  .ic-popup.is-use-app .ic-popup__card,
  .ic-popup.is-upgrade-official .ic-popup__card,
  .ic-popup.is-wallet-confirmation .ic-popup__card {
    width: min(84%, 408px);
  }

  .ic-popup__message {
    padding-left: 6px;
    padding-right: 6px;
  }

  .ic-popup.is-app-gate .ic-popup__stores,
  .ic-popup.is-use-app .ic-popup__stores,
  .ic-popup.is-app-gate .ic-popup__actions,
  .ic-popup.is-use-app .ic-popup__actions {
    width: 94%;
  }

  .ic-popup__actions--single .ic-popup__btn {
    max-width: 216px;
  }

  .ic-popup.is-component-gate .ic-popup__card {
    width: min(92%, 396px);
    padding-left: 26px;
    padding-right: 26px;
  }

  .ic-popup.is-component-gate .ic-popup__close {
    top: 20px;
    right: 20px;
  }

  .ic-popup.is-component-gate .ic-popup__title {
    padding-left: 32px;
    padding-right: 32px;
  }

  .ic-popup.is-component-gate .ic-popup__actions {
    width: 100%;
  }
}
