/* ==============================
   Toast Notification
   ============================== */
.toast-container {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 380px;
  margin-bottom: 10px;
  pointer-events: all;
  animation: toastSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.toast.toast-hide {
  animation: toastSlideOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastSlideOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-16px) scale(0.96); }
}

.toast-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  color: white;
}

.toast-message {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--on-surface);
  flex: 1;
}

.toast-progress {
  position: absolute;
  bottom: 0;
  right: 0;
  height: 3px;
  background: currentColor;
  animation: toastProgress linear forwards;
}

@keyframes toastProgress {
  from { width: 100%; }
  to   { width: 0%; }
}

/* ==============================
   Dialog / Modal
   ============================== */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  animation: dlgFadeIn 0.25s cubic-bezier(0.4,0,0.2,1) forwards;
}

.dialog-overlay.dialog-hide {
  animation: dlgFadeOut 0.25s cubic-bezier(0.4,0,0.2,1) forwards;
}

@keyframes dlgFadeIn  { to { opacity: 1; } }
@keyframes dlgFadeOut { to { opacity: 0; } }

.dialog {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 380px;
  width: 100%;
  overflow: hidden;
  transform: scale(0.88) translateY(12px);
  animation: dlgSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.dialog-overlay.dialog-hide .dialog {
  animation: dlgSlideOut 0.22s cubic-bezier(0.4,0,0.2,1) forwards;
}

@keyframes dlgSlideIn  { to { transform: scale(1) translateY(0); } }
@keyframes dlgSlideOut { to { transform: scale(0.9) translateY(8px); opacity: 0; } }

.dialog-header {
  padding: 20px 20px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border);
}

.dialog-icon {
  width: 50px;
  height: 50px;
  border-radius: 13px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface-3);
}

.dialog-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dialog-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--on-surface);
}

.dialog-body {
  padding: 18px 20px;
}

.dialog-message {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--on-surface-2);
}

.dialog-actions {
  padding: 12px 20px 18px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.dialog-btn {
  padding: 9px 22px;
  border-radius: 20px;
  border: none;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.dialog-btn-primary   { background: var(--primary); color: white; }
.dialog-btn-secondary { background: var(--surface-3); color: var(--on-surface-2); }

.dialog-btn-primary:hover  { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,115,232,.3); }
.dialog-btn-secondary:hover{ background: var(--border); }

/* ==============================
   Grid 4x2  — آیکون + تایتل
   محاسبه خودکار ستون‌ها با CSS
   ============================== */
.apps-grid-4x2 {
  display: grid;
  /*
    هر آیتم حداقل 64px عرض دارد.
    مرورگر بیشترین ستون ممکن را محاسبه می‌کند.
    در صفحه 360px → 5 ستون (360/64=5.6)
    در صفحه 320px → 4 ستون
    در صفحه 414px → 6 ستون
  */
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px 4px;
  margin-bottom: 12px;
}

/* کارت grid4x2 */
.apps-grid-4x2 .app-card-grid {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 8px 2px;
  border-radius: var(--radius-md);
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.apps-grid-4x2 .app-card-grid:active {
  background: var(--surface-3);
}

.apps-grid-4x2 .app-icon-wrap {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.14);
  background: var(--surface-3);
  flex-shrink: 0;
  position: relative;
}

.apps-grid-4x2 .app-icon-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.apps-grid-4x2 .app-badge {
  position: absolute;
  top: 1px;
  font-size: 0.56rem;
  padding: 2px 4px;
  border-radius: 5px;
  color: white;
  font-weight: 700;
  line-height: 1.2;
  z-index: 2;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.apps-grid-4x2 .app-title {
  font-size: 0.52rem;
  font-weight: 600;
  color: var(--on-surface);
  text-align: center;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  width: 100%;
}

/* آیتم‌های hidden */
.apps-grid-4x2 .app-card-grid.hidden,
.apps-list-download .list-download-card.hidden {
  display: none;
}

/* ==============================
   دکمه بیشتر (show-more)
   ============================== */
.show-more-btn {
  width: 100%;
  padding: 10px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--primary);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
}

.show-more-btn:hover {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ==============================
   List Download
   ============================== */
.apps-list-download {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-download-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}

.list-download-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: rgba(26,115,232,0.2);
}

.list-download-icon {
  width: 52px;
  height: 52px;
  border-radius: 13px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface-3);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.list-download-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.list-download-info {
  flex: 1;
  min-width: 0;
}

.list-download-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--on-surface);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.list-download-desc {
  font-size: 0.76rem;
  color: var(--on-surface-2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.list-download-meta {
  display: flex;
  gap: 8px;
  margin-top: 5px;
  font-size: 0.68rem;
  color: var(--on-surface-2);
  flex-wrap: wrap;
}

.download-btn {
  padding: 7px 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 18px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}

.download-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(26,115,232,.3);
}

/* ==============================
   Horizontal-3  — App Store style
   آیتم بعدی جزئاً نمایش داده شود
   ============================== */
.apps-h3-outer {
  /* overflow hidden روی wrapper بیرونی */
  overflow: hidden;
  position: relative;
}

.apps-h3-scroll {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
  /* padding-left باعث می‌شود بخشی از صفحه بعد دیده شود */
  padding-bottom: 4px;
  gap: 0;
  /* مهم: cursor برای نشان دادن قابلیت scroll */
  cursor: grab;
}

.apps-h3-scroll:active { cursor: grabbing; }
.apps-h3-scroll::-webkit-scrollbar { display: none; }

/* هر صفحه — عرض 85% تا آیتم‌های صفحه بعدی دیده شوند */
.apps-h3-page {
  display: flex;
  flex-direction: column;
  gap: 0;
  /* 88% عرض کانتینر = آیتم بعدی ~12% قابل مشاهده */
  flex: 0 0 88%;
  scroll-snap-align: start;
  padding-left: 0;
}

/* آیتم row */
.apps-h3-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 4px 9px 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.apps-h3-item:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.apps-h3-item:active {
  background: var(--surface-3);
}

.apps-h3-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface-3);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.apps-h3-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.apps-h3-info {
  flex: 1;
  min-width: 0;
}

.apps-h3-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.apps-h3-desc {
  font-size: 0.73rem;
  color: var(--on-surface-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.apps-h3-btn {
  padding: 6px 13px;
  background: var(--surface-3);
  color: var(--primary);
  border: none;
  border-radius: 16px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
  /* فاصله از لبه راست صفحه بعدی */
  margin-left: 4px;
}

.apps-h3-btn:hover {
  background: var(--primary);
  color: white;
}

/* نشانگر صفحات */
.apps-h3-dots {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-top: 10px;
}

.apps-h3-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
  transition: all 0.3s;
}

.apps-h3-dot.active {
  background: var(--primary);
  width: 18px;
  border-radius: 3px;
}

/* ==============================
   Multi Banners — بخشی از بنر بعدی دیده شود
   ============================== */
.multi-banners-section {
  margin-bottom: 8px;
  margin-top: 4px;
  /* overflow hidden روی section */
  overflow: hidden;
}

.multi-banners-container {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 4px 0 6px;
  /* padding-left منفی برای نمایش بخشی از بنر بعدی */
}

.multi-banners-container::-webkit-scrollbar { display: none; }

.multi-banner {
  /*
    عرض هر بنر = ~46% از container
    → دو بنر 92% + 10px gap ≈ پر می‌شود
    → بخشی از بنر سوم (~8%) قابل مشاهده
  */
  flex: 0 0 46%;
  min-width: 130px;
  height: 110px;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-sm);
  scroll-snap-align: start;
}

.multi-banner:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.multi-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.1) 100%);
  z-index: 1;
}

.multi-banner img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.multi-banner-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.multi-banner-text {
  position: relative;
  z-index: 2;
  padding: 10px 12px;
  color: white;
  height: 100%;
  display: flex;
  align-items: flex-end;
}

.multi-banner-text h3 {
  font-size: 0.84rem;
  font-weight: 700;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
  line-height: 1.3;
}

/* ==============================
   Responsive
   ============================== */
@media (max-width: 359px) {
  .apps-grid-4x2 {
    grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  }
  .apps-grid-4x2 .app-icon-wrap {
    width: 50px;
    height: 50px;
  }
  .apps-grid-4x2 .app-title {
    font-size: 0.66rem;
  }
  .apps-h3-page {
    flex: 0 0 92%;
  }
  .multi-banner {
    flex: 0 0 80%;
  }
}

@media (min-width: 480px) {
  .apps-grid-4x2 {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 10px 6px;
  }
  .apps-grid-4x2 .app-icon-wrap {
    width: 62px;
    height: 62px;
  }
  .apps-h3-page {
    flex: 0 0 80%;
  }
  .multi-banner {
    height: 125px;
  }
}

@media (min-width: 600px) {
  .apps-h3-page {
    flex: 0 0 55%;
  }
  .multi-banner {
    flex: 0 0 44%;
    height: 135px;
  }
}

@media (min-width: 900px) {
  .apps-h3-page {
    flex: 0 0 38%;
  }
  .multi-banner {
    flex: 0 0 30%;
    height: 145px;
  }
}





/* ==============================
   Views Badge — نمایش تعداد بازدید
   در همه حالت‌ها به جز grid4x2
   ============================== */

/* badge کوچک بازدید */
.views-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.68rem;
  color: var(--on-surface-2);
  white-space: nowrap;
}

.views-badge .fa {
  font-size: 0.63rem;
  opacity: 0.65;
}

/* بازدید در کارت swipe (زیر تایتل) */
.app-views {
  font-size: 0.7rem;
  color: var(--on-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin-top: 2px;
}

/* بازدید در horizontal-3 */
.apps-h3-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

/* ==============================
   کارت "مشاهده همه" در horizontal-3
   وقتی آیتم‌ها بیشتر از MAX_SWIPE_ITEMS باشند
   ============================== */
.apps-h3-page-more {
  justify-content: center;
  align-items: center;
}

.h3-see-all-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
  min-height: 130px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 2px dashed var(--border);
  transition: all var(--transition);
  width: 100%;
}

.h3-see-all-btn:hover {
  background: var(--surface-3);
  border-color: var(--primary);
}

.h3-see-all-btn small {
  font-size: 0.72rem;
  color: var(--on-surface-2);
  font-weight: 400;
}

/* ==============================
   کارت "مشاهده همه" در swipe
   ============================== */
.app-card-more {
  background: var(--surface) !important;
  border: 2px dashed var(--border) !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--on-surface);
  transition: all var(--transition);
}

.app-card-more:hover {
  border-color: var(--primary) !important;
  background: var(--surface-3) !important;
}


