/* ===========================================================
   استایل سفارشی فروشگاه — بر پایه‌ی Bootstrap 5 RTL
   رنگ‌ها از متغیرهای پویای theme_settings تزریق می‌شوند.
   =========================================================== */

:root {
  --shop-radius: 12px;
  --shop-shadow: 0 6px 24px rgba(0, 0, 0, .05);
  --shop-shadow-hover: 0 12px 36px rgba(0, 0, 0, .12);
  --shop-transition: .22s ease;
}

body {
  font-family: 'Vazirmatn', -apple-system, "Segoe UI", sans-serif;
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  font-size: .9rem;
}

/* ---- Header ---- */
.topbar-promo {
  font-size: .8rem;
  letter-spacing: .03em;
}
.header-main .logo-img {
  height: 38px;
  width: auto;
  /* سقف عرض لوگو تا نام فروشگاه همیشه جا داشته باشد و به‌خاطر text-truncate بریده نشود */
  max-width: 130px;
  object-fit: contain;
}
.shop-name {
  color: var(--bs-primary);
}
.search-form .form-control {
  border-radius: 999px 0 0 999px;
  border-left: 0;
}
.search-form .btn {
  border-radius: 0 999px 999px 0;
}
.site-header .navbar .nav-link {
  color: #333;
  font-weight: 500;
}
.site-header .navbar .nav-link.active,
.site-header .navbar .nav-link:hover {
  color: var(--bs-primary);
}

/* ---- Hero/Slider ---- */
.hero-slider .carousel-item {
  min-height: 380px;
  border-radius: var(--shop-radius);
  overflow: hidden;
  position: relative;
}
.hero-slider .carousel-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}
.hero-slider .carousel-caption {
  right: 8%;
  left: 8%;
  text-align: right;
  bottom: 25%;
}
.hero-slider .carousel-caption h2 {
  font-size: 2rem;
  font-weight: 800;
  text-shadow: 0 2px 12px rgba(0,0,0,.4);
}
.hero-slider .carousel-caption p {
  font-size: 1.1rem;
}
.hero-slider .carousel-control-prev,
.hero-slider .carousel-control-next {
  width: 5%;
}

/* ---- Product card ---- */
.product-card {
  background: #fff;
  border: 1px solid #eee;
  border-radius: var(--shop-radius);
  overflow: hidden;
  transition: var(--shop-transition);
  height: 100%;
  display: flex;
  flex-direction: column;
}
.product-card:hover {
  box-shadow: var(--shop-shadow-hover);
  transform: translateY(-2px);
  border-color: var(--bs-primary);
}
.product-card .product-image {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #f5f5f5;
  overflow: hidden;
}
.product-card .product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--shop-transition);
}
.product-card:hover .product-image img {
  transform: scale(1.06);
}
.product-card .product-badges {
  position: absolute;
  top: 8px;
  inset-inline-start: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.product-card .badge-discount {
  background: #ef4444;
  color: #fff;
  font-size: .7rem;
  padding: 4px 8px;
  border-radius: 6px;
}
.product-card .badge-new {
  background: #22c55e;
  color: #fff;
  font-size: .7rem;
  padding: 4px 8px;
  border-radius: 6px;
}
.product-card .product-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}
.product-card .product-title {
  font-weight: 600;
  font-size: .9rem;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}
.product-card .product-title a {
  color: #1f2937;
}
.product-card .product-brand {
  font-size: .75rem;
  color: #6b7280;
  margin-bottom: 8px;
}
.product-card .product-price-row {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.product-card .price-final {
  font-weight: 800;
  font-size: 1rem;
  color: var(--bs-primary);
}
.product-card .price-original {
  font-size: .8rem;
  text-decoration: line-through;
  color: #9ca3af;
}
.product-card .btn-add-to-cart {
  background: var(--bs-primary);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: .8rem;
}
.product-card .btn-add-to-cart:hover {
  filter: brightness(.95);
}
.product-card .out-of-stock-tag {
  position: absolute;
  bottom: 8px;
  inset-inline-end: 8px;
  background: rgba(0,0,0,.5);
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: .7rem;
}

/* ---- Section heading ---- */
.section-heading {
  text-align: center;
  margin: 40px 0 25px;
}
.section-heading h2 {
  font-size: 1.5rem;
  font-weight: 800;
  position: relative;
  display: inline-block;
  padding-bottom: 10px;
}
.section-heading h2::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 50%;
  transform: translateX(50%);
  width: 50px;
  height: 3px;
  background: var(--bs-primary);
  border-radius: 2px;
}
.section-heading p {
  color: #6b7280;
  margin-top: 6px;
}

/* ---- Filters sidebar ---- */
.filter-widget {
  background: #fff;
  border: 1px solid #eee;
  border-radius: var(--shop-radius);
  padding: 16px;
  margin-bottom: 14px;
}
.filter-widget h6 {
  font-weight: 700;
  font-size: .9rem;
  margin-bottom: 12px;
  border-bottom: 1px solid #eee;
  padding-bottom: 8px;
}
.filter-widget .form-check {
  margin-bottom: 6px;
}
.filter-widget .form-check-label {
  font-size: .85rem;
  color: #4b5563;
  cursor: pointer;
}
.price-input-group input {
  width: 100%;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: .8rem;
}

/* ---- Pagination ---- */
.pagination .page-link {
  color: var(--bs-primary);
}
.pagination .page-item.active .page-link {
  background: var(--bs-primary);
  border-color: var(--bs-primary);
}

/* ---- Product detail ---- */
.product-detail .gallery-main {
  aspect-ratio: 1 / 1;
  background: #f5f5f5;
  border-radius: var(--shop-radius);
  overflow: hidden;
}
.product-detail .gallery-main img {
  width: 100%; height: 100%; object-fit: cover;
}
.product-detail .gallery-thumbs {
  display: flex; gap: 8px; margin-top: 8px;
}
.product-detail .gallery-thumb {
  width: 80px; height: 80px; border-radius: 8px; overflow: hidden;
  cursor: pointer; border: 2px solid transparent;
}
.product-detail .gallery-thumb.active {
  border-color: var(--bs-primary);
}
.product-detail .gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-detail .product-title {
  font-size: 1.5rem; font-weight: 800;
}
.product-detail .product-price {
  font-size: 1.4rem; font-weight: 800; color: var(--bs-primary);
}
.product-detail .product-price .original {
  font-size: 1rem; text-decoration: line-through; color: #9ca3af; margin-inline-end: 8px;
}
.product-detail .qty-input {
  width: 80px;
}
.product-detail .attribute-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  font-size: .9rem;
}

/* ---- Cart ---- */
.cart-item {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 12px;
  display: grid;
  grid-template-columns: 80px 1fr auto auto;
  gap: 12px;
  align-items: center;
}
.cart-item .ci-img {
  width: 80px; height: 80px; border-radius: 8px; overflow: hidden;
}
.cart-item .ci-img img { width: 100%; height: 100%; object-fit: cover; }

/* ---- Order tracking ---- */
.order-status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
}
.order-status-pending { background: #fef3c7; color: #92400e; }
.order-status-paid, .order-status-processing { background: #dbeafe; color: #1e40af; }
.order-status-shipped { background: #e0e7ff; color: #4338ca; }
.order-status-delivered { background: #dcfce7; color: #166534; }
.order-status-canceled, .order-status-rejected { background: #fee2e2; color: #991b1b; }

/* ---- Admin sidebar ---- */
.sidebar {
  min-height: calc(100vh - 50px);
  background: #fff;
  border-left: 1px solid #eee;
}
.sidebar-group {
  margin-bottom: 12px;
}
.sidebar-title {
  letter-spacing: .05em;
}
.sidebar .nav-link {
  color: #4b5563;
  border-radius: 8px;
  margin: 2px 8px;
  font-size: .85rem;
}
.sidebar .nav-link:hover {
  background: #f3f4f6;
}
.sidebar .nav-link.active {
  background: var(--bs-primary);
  color: #fff !important;
}

/* ---- Admin overlay menu (mobile) ---- */
.admin-nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1060;
  background: rgba(0, 0, 0, .45);
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease;
}
.admin-nav-backdrop.show {
  opacity: 1;
  visibility: visible;
}
.admin-nav-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1065;
  width: min(84vw, 320px);
  background: #fff;
  box-shadow: -6px 0 24px rgba(0, 0, 0, .18);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px calc(24px + env(safe-area-inset-bottom));
  transform: translateX(105%);
  transition: transform .22s ease;
}
.admin-nav-overlay.show {
  transform: translateX(0);
}
.admin-nav-overlay .nav-link {
  color: #4b5563;
  border-radius: 8px;
  margin: 2px 8px;
  font-size: .88rem;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.admin-nav-overlay .nav-link.active {
  background: var(--bs-primary);
  color: #fff !important;
}
.admin-nav-overlay .mobile-nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  margin-bottom: 8px;
  border-bottom: 2px solid var(--bs-primary);
  font-size: 1.02rem;
}

/* ---- Tables ---- */
.table > :not(caption) > * > * {
  padding: 10px 12px;
}
.table thead th {
  background: #f9fafb;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

/* ---- Bulk edit ---- */
.bulk-edit-table input.form-control-sm,
.bulk-edit-table select.form-select-sm {
  font-size: .8rem;
  padding: 4px 8px;
}

/* ---- Buttons ---- */
.btn-primary {
  --bs-btn-bg: var(--bs-primary);
  --bs-btn-border-color: var(--bs-primary);
  --bs-btn-hover-bg: var(--bs-primary);
  --bs-btn-hover-border-color: var(--bs-primary);
  filter: brightness(.95);
}
.btn-outline-primary {
  --bs-btn-color: var(--bs-primary);
  --bs-btn-border-color: var(--bs-primary);
  --bs-btn-hover-bg: var(--bs-primary);
  --bs-btn-hover-border-color: var(--bs-primary);
}

/* ---- Alerts ---- */
.alert {
  font-size: .9rem;
}

/* ---- Footer ---- */
.site-footer {
  margin-top: 50px;
}
.site-footer a:hover {
  color: #fff !important;
}

/* ---- Misc ---- */
.text-muted-2 {
  color: #9ca3af;
}
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: #9ca3af;
}
.empty-state .icon {
  font-size: 4rem;
  margin-bottom: 12px;
}

/* ---- Toast / quick notifications ---- */
.toast-container {
  position: fixed;
  top: 80px;
  z-index: 1080;
  width: 100%;
  pointer-events: none;
}

/* ---- Back to top ---- */
.back-to-top {
  position: fixed;
  inset-inline-end: 14px;
  bottom: 18px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: var(--bs-primary);
  color: #fff;
  font-size: 1.2rem;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
  z-index: 1040;
}
.back-to-top.show {
  display: flex;
}

/* ---- Rich content (توضیحات محصول) ---- */
.product-description {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.product-description img,
.product-description table {
  max-width: 100%;
}
.product-description table {
  display: block;
  overflow-x: auto;
}

/* ===========================================================
   موبایل‌فرست — بهینه‌سازی سایت برای صفحه‌نمایش کوچک
   =========================================================== */
body {
  overflow-x: hidden;
  -webkit-tap-highlight-color: rgba(0, 0, 0, .06);
}

@media (min-width: 992px) {
  /* فرم فیلتر در دسکتاپ همیشه نمایان است (در موبایل collapse می‌شود) */
  .filter-collapse {
    display: block !important;
  }
}

@media (max-width: 991.98px) {
  /* ---- هدر جمع‌وجور ---- */
  .header-main .row {
    gap: .5rem;
  }
  .header-main .logo-img {
    height: 30px;
    /* لوگو باید کوچک‌تر شود تا نام فروشگاه (که عنصر مهم‌تری است) جا داشته باشد؛
       بدون این محدودیت، text-truncate نام را به عرض صفر می‌فشرد. */
    flex: 0 1 auto;
    min-width: 22px;
    max-width: 22vw;
    object-fit: contain;
  }
  .header-main .shop-brand {
    flex: 1 1 auto;
    min-width: 0;
  }
  .header-main .shop-name {
    font-size: 1.05rem;
    flex: 0 1 auto;
    min-width: 3.5em;
  }
  .topbar-promo {
    font-size: .72rem;
    padding-top: .3rem !important;
    padding-bottom: .3rem !important;
  }
  .search-form .form-control {
    height: 42px;
    font-size: 16px; /* جلوگیری از زوم خودکار iOS */
  }
  .search-form .btn {
    height: 42px;
    min-width: 46px;
  }

  /* ---- اهداف لمسی مناسب (حداقل ۴۴ پیکسل) ---- */
  .btn:not(.btn-sm):not(.btn-close) {
    min-height: 44px;
  }
  .form-control,
  .form-select {
    font-size: 16px; /* جلوگیری از زوم خودکار iOS */
  }
  .form-check-label {
    display: inline-block;
    padding-block: 7px;
    font-size: .92rem;
  }
  .form-check-input {
    width: 1.25em;
    height: 1.25em;
    margin-top: .15em;
  }
  .pagination .page-link {
    min-width: 40px;
    text-align: center;
  }

  /* ---- دکمهٔ همبرگری در ردیف اول کنار لوگو ---- */
  .site-header .header-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    color: var(--bs-primary);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    order: -1;
  }
  .site-header .header-nav-toggle:active {
    background: #f3f4f6;
  }

  /* ---- منوی موبایل: اورلی تمام‌صفحه روی محتوا ---- */
  .nav-overlay-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1060;
    background: rgba(0, 0, 0, .45);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease;
  }
  .nav-overlay-backdrop.show {
    opacity: 1;
    visibility: visible;
  }
  .nav-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1065;
    width: min(84vw, 340px);
    max-width: 100%;
    background: #fff;
    box-shadow: -6px 0 24px rgba(0, 0, 0, .18);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 12px 14px calc(24px + env(safe-area-inset-bottom));
    transform: translateX(105%);
    transition: transform .22s ease;
  }
  .nav-overlay.show {
    transform: translateX(0);
  }
  body.nav-open {
    overflow: hidden;
  }
  .nav-overlay .nav-link {
    padding: .8rem .75rem;
    font-size: .98rem;
    color: #374151;
    border-radius: 10px;
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  .nav-overlay .nav-link.active,
  .nav-overlay .nav-link:hover {
    background: #f3f4f6;
    color: var(--bs-primary);
  }
  .nav-overlay .mobile-nav-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 10px;
    margin-bottom: 8px;
    border-bottom: 2px solid var(--bs-primary);
    font-size: 1.05rem;
  }
  .nav-overlay .mobile-nav-head .nav-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* ---- منوهای کشویی از لبه‌ی صفحه بیرون نزنند ---- */
  .dropdown-menu {
    max-width: calc(100vw - 24px);
  }

  /* ---- جدول‌ها: اسکریپ افقی به‌جای شکستن صفحه ---- */
  .table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ---- فوتر ---- */
  .site-footer.pt-5 {
    padding-top: 2rem !important;
  }
  .site-footer {
    padding-bottom: calc(.75rem + env(safe-area-inset-bottom));
  }
}

@media (max-width: 767.98px) {
  /* ---- کارت محصول ---- */
  .product-card .product-body {
    padding: 10px;
  }
  .product-card .product-title {
    font-size: .82rem;
    min-height: 2.4em;
  }
  .product-card .price-final {
    font-size: .92rem;
  }
  .product-card:hover {
    transform: none;
  }

  /* ---- هیرو/بنر ---- */
  .hero-slider .carousel-item {
    min-height: 240px;
  }
  .hero-slider .carousel-caption {
    bottom: 18%;
  }
  .hero-slider .carousel-caption h2 {
    font-size: 1.2rem;
  }

  /* ---- گالری محصول ---- */
  .product-detail .gallery-thumbs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
  }
  .product-detail .gallery-thumb {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
  }
  .product-detail .product-title {
    font-size: 1.2rem;
  }
  .product-detail .product-price {
    font-size: 1.2rem;
  }

  /* ---- سبد خرید ---- */
  .cart-item {
    grid-template-columns: 60px 1fr;
    grid-template-rows: auto auto auto;
  }
  .cart-item .ci-actions {
    grid-column: 1 / -1;
    text-align: left;
  }
  .cart-item form {
    grid-column: 1 / -1;
  }
  .cart-item form:nth-of-type(1) {
    justify-content: flex-start;
  }
  .cart-item form:nth-of-type(2) {
    display: flex;
    justify-content: flex-end;
  }

  /* ---- عنوان بخش‌ها ---- */
  .section-heading {
    margin: 28px 0 16px;
  }
  .section-heading h2 {
    font-size: 1.2rem;
  }
}

@media (max-width: 575.98px) {
  /* ---- هیرو/بنر کامپکت ---- */
  .hero-slider .carousel-item {
    min-height: 200px;
  }
  .hero-slider .carousel-caption {
    right: 5%;
    left: 5%;
    bottom: 10%;
    text-align: center;
  }
  .hero-slider .carousel-caption h2 {
    font-size: 1rem;
  }
  .hero-slider .carousel-caption p {
    font-size: .8rem;
    margin-bottom: .25rem;
  }
  .hero-slider .carousel-caption .btn {
    font-size: .85rem;
    padding: .4rem .9rem;
    margin-top: .5rem !important;
  }
  .hero-slider .carousel-control-prev,
  .hero-slider .carousel-control-next {
    width: 10%;
  }

  /* ---- کارت محصول کامپکت (۲ ستونه) ---- */
  .product-card .product-body {
    padding: 8px 10px 10px;
  }
  .product-card .product-title {
    font-size: .78rem;
    min-height: 2.3em;
  }
  .product-card .product-brand {
    font-size: .68rem;
    margin-bottom: 4px;
  }
  .product-card .price-final {
    font-size: .85rem;
  }
  .product-card .price-original {
    font-size: .7rem;
  }
  .product-card .btn-add-to-cart {
    padding: 8px 10px;
  }

  /* ---- عنوان بخش‌ها ---- */
  .section-heading {
    margin: 24px 0 14px;
  }
  .section-heading h2 {
    font-size: 1.1rem;
  }
  .section-heading p {
    font-size: .8rem;
  }

  /* ---- آیکون دسته‌بندی‌های صفحه اصلی ---- */
  .card .display-1 {
    font-size: 2.75rem;
  }

  /* ---- حالت خالی و صفحه‌بندی ---- */
  .empty-state {
    padding: 30px 12px;
  }
  .empty-state .icon {
    font-size: 3rem;
  }
  .pagination .page-link {
    min-width: 36px;
    padding: .4rem .5rem;
    font-size: .85rem;
  }

  /* ---- فاصله‌های عمومی ---- */
  main.py-4,
  main .container > .row {
    --bs-gutter-x: .75rem;
  }
}
