/* ============================================================
   iTOOL — Product Listing CSS
   For WooCommerce shop / category / tag archives
   Class prefix: .aitl-
   Theme: navy (#1e2a78) + green (#22c55e) + orange (#f97316)
   RTL / Persian (local Dana font)
   ============================================================ */

:root {
  --aitl-bg: #f5f5f5;
  --aitl-surface: #ffffff;
  --aitl-ink: #111111;
  --aitl-muted: #6b7280;
  --aitl-muted-2: #9ca3af;
  --aitl-line: rgba(0,0,0,0.06);
  --aitl-primary: #1e2a78;       /* iTOOL navy */
  --aitl-primary-2: #2a3a8c;
  --aitl-accent: #22c55e;        /* iTOOL green */
  --aitl-accent-2: #15803d;
  --aitl-danger: #b91c1c;
  --aitl-radius: 20px;
  --aitl-radius-sm: 14px;
  --aitl-shadow-1: 0 1px 2px rgba(16,24,40,.04);
  --aitl-shadow-2: 0 18px 40px -14px rgba(16,24,40,.16), 0 4px 10px -4px rgba(16,24,40,.06);
  --aitl-font: var(--itoll-font-family);
}

body.post-type-archive-product #header,
body.tax-product_cat #header,
body.tax-product_tag #header,
body.post-type-archive-product .ct-header,
body.tax-product_cat .ct-header,
body.tax-product_tag .ct-header,
body.post-type-archive-product #footer,
body.tax-product_cat #footer,
body.tax-product_tag #footer,
body.post-type-archive-product .ct-footer,
body.tax-product_cat .ct-footer,
body.tax-product_tag .ct-footer {
  display: none;
}

/* Scoped reset so we don't fight the parent theme */
.aitl-page-head,
.aitl-shop,
.aitl-shop * {
  box-sizing: border-box;
}

.aitl-page-head,
.aitl-shop {
  font-family: var(--aitl-font);
  color: var(--aitl-ink);
  direction: rtl;
}

/* ============================================
   BREADCRUMB BAR — نوار سفید چسبیده به هدر
   ============================================ */
.aitl-crumbs-bar {
  background: #fff;
  border-bottom: 1px solid var(--aitl-line);
  width: 100%;
}
.aitl-crumbs-bar__inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 13px 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--aitl-muted);
  font-weight: 500;
  direction: rtl;
}
.aitl-crumbs-bar__inner a {
  color: var(--aitl-muted);
  text-decoration: none;
  transition: color .2s;
}
.aitl-crumbs-bar__inner a:hover { color: var(--aitl-primary); }
.aitl-crumbs-bar__inner .sep { color: var(--aitl-muted-2); font-size: 12px; }
.aitl-crumbs-bar__current { color: var(--aitl-ink); font-weight: 600; }

/* ============================================
   PAGE HEADER (category title)
   ============================================ */
.aitl-page-head {
  background: linear-gradient(180deg, #eef1f7 0%, #f5f5f5 100%);
  padding: 32px 24px;
  text-align: center;
  border-bottom: 1px solid var(--aitl-line);
}
.aitl-page-head h1 {
  margin: 0;
  font-size: clamp(22px, 2.5vw, 32px);
  font-weight: 800;
  color: var(--aitl-ink);
  letter-spacing: 0;
}

/* ============================================
   LISTING WRAPPER + TOOLBAR
   ============================================ */
.aitl-shop {
  max-width: 860px;
  margin: 0 auto;
  padding: 36px 24px 56px;
  background: var(--aitl-bg);
  box-shadow: 0 0 0 100vmax var(--aitl-bg);
  clip-path: inset(0 -100vmax);
}

.aitl-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
  direction: rtl;
}

.aitl-toolbar__count {
  font-size: 14px;
  color: var(--aitl-muted);
  font-weight: 500;
}

.aitl-toolbar__count .woocommerce-result-count {
  display: block !important;
  margin: 0;
  color: inherit;
  font-size: inherit;
}
.aitl-toolbar__count strong {
  color: var(--aitl-ink);
  font-weight: 700;
}

.aitl-toolbar__sort { flex-shrink: 0; }
.aitl-sort { position: relative; }
.aitl-sort select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--aitl-surface);
  border: 1px solid var(--aitl-line);
  border-radius: 12px;
  padding: 12px 16px 12px 40px;
  min-width: 260px;
  height: 46px;
  font-family: var(--aitl-font);
  font-size: 14px;
  font-weight: 500;
  color: var(--aitl-ink);
  cursor: pointer;
  direction: rtl;
  white-space: nowrap;
  transition: border-color .2s, box-shadow .2s;
  box-shadow: var(--aitl-shadow-1);
}
.aitl-sort select:focus {
  outline: none;
  border-color: var(--aitl-primary);
  box-shadow: 0 0 0 3px rgba(30,42,120,0.12);
}
.aitl-sort::after {
  content: "";
  position: absolute;
  left: 16px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--aitl-muted);
  border-bottom: 2px solid var(--aitl-muted);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}

/* ============================================
   PRODUCT GRID
   ============================================ */
.aitl-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ============================================
   PRODUCT CARD
   ============================================ */
.aitl-product {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--aitl-surface);
  border-radius: var(--aitl-radius);
  border: 1px solid var(--aitl-line);
  box-shadow: var(--aitl-shadow-1);
  overflow: hidden;
  transition: transform .35s cubic-bezier(.22,1,.36,1), box-shadow .35s cubic-bezier(.22,1,.36,1), border-color .25s;
  list-style: none;
}
.aitl-product:hover {
  transform: translateY(-4px);
  box-shadow: var(--aitl-shadow-2);
  border-color: rgba(30,42,120,0.10);
}

/* --- Media --- */
.aitl-product__media {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  background:
    radial-gradient(circle at 30% 25%, rgba(34,197,94,0.05), rgba(34,197,94,0) 60%),
    linear-gradient(135deg, #fafbfc 0%, #f0f2f7 100%);
  padding: 22px;
  overflow: hidden;
  text-decoration: none;
}
.aitl-product__media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform .5s cubic-bezier(.22,1,.36,1);
  display: block;
}
.aitl-product:hover .aitl-product__media img {
  transform: scale(1.05);
}

/* Discount badge */
.aitl-product__discount {
  position: absolute;
  top: 12px;
  right: 12px;
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 10px;
  border-radius: 999px;
  box-shadow: 0 6px 14px -4px rgba(234,88,12,0.45);
  letter-spacing: 0.02em;
  z-index: 2;
  font-feature-settings: "tnum";
}

/* Wishlist/heart icon (appears on hover) */
.aitl-product__fav {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--aitl-line);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .25s, transform .25s, background .2s, color .2s;
  color: var(--aitl-muted);
  z-index: 2;
}
.aitl-product:hover .aitl-product__fav {
  opacity: 1;
  transform: translateY(0);
}
.aitl-product__fav:hover {
  background: var(--aitl-accent);
  color: #fff;
  border-color: var(--aitl-accent);
}
.aitl-product__fav svg { width: 16px; height: 16px; }

/* --- Body --- */
.aitl-product__body {
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.aitl-product__cat {
  font-size: 11px;
  color: var(--aitl-accent-2);
  background: rgba(34,197,94,0.10);
  padding: 3px 9px;
  border-radius: 999px;
  width: fit-content;
  font-weight: 600;
}

.aitl-product__title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--aitl-ink);
  margin: 0;
  line-height: 1.55;
  min-height: calc(1.55em * 2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-decoration: none;
  transition: color .2s;
}
.aitl-product__title:hover { color: var(--aitl-primary); }

/* --- Price --- */
.aitl-product__price {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 6px;
}
.aitl-product__price-now {
  font-size: 17px;
  font-weight: 800;
  color: var(--aitl-ink);
  letter-spacing: 0;
  font-feature-settings: "tnum";
}
.aitl-product__price-now small {
  font-size: 11px;
  font-weight: 600;
  color: var(--aitl-muted);
  margin-right: 4px;
}
.aitl-product__price-old {
  font-size: 13px;
  color: var(--aitl-muted-2);
  text-decoration: line-through;
  font-weight: 500;
  font-feature-settings: "tnum";
}

/* --- CTA --- */
.aitl-product .aitl-product__cta,
.aitl-product .aitl-product__cta.button,
.aitl-product .aitl-product__cta.add_to_cart_button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 18px 18px;
  padding: 12px 16px;
  background: #1e2a78 !important;
  color: #fff !important;
  border: 0 !important;
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background .25s ease, transform .15s ease, box-shadow .25s ease;
  box-shadow: 0 4px 10px -3px rgba(30,42,120,0.35);
}
.aitl-product .aitl-product__cta:hover,
.aitl-product .aitl-product__cta.button:hover,
.aitl-product .aitl-product__cta.add_to_cart_button:hover {
  background: #24338f !important;
  color: #fff !important;
  box-shadow: 0 8px 18px -4px rgba(30,42,120,0.45);
}
.aitl-product .aitl-product__cta:active { transform: translateY(1px); }
.aitl-product .aitl-product__cta svg { width: 16px; height: 16px; }

/* "Added" success state (WooCommerce adds .added class via JS) */
.aitl-product .aitl-product__cta.loading {
  opacity: 0.7;
  pointer-events: none;
}
.aitl-product .aitl-product__cta.added {
  background: #22c55e !important;
  box-shadow: 0 8px 18px -4px rgba(34,197,94,0.40);
}

/* ============================================
   OUT OF STOCK STATE
   ============================================ */
.aitl-product--oos .aitl-product__media {
  filter: grayscale(0.95) brightness(0.97);
  opacity: 0.85;
}
.aitl-product--oos .aitl-product__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(245,245,245,0.35);
  pointer-events: none;
}
.aitl-product--oos .aitl-product__title,
.aitl-product--oos .aitl-product__price-now,
.aitl-product--oos .aitl-product__price-old {
  color: var(--aitl-muted-2) !important;
}
.aitl-product--oos .aitl-product__cat {
  background: rgba(0,0,0,0.06);
  color: var(--aitl-muted);
}
.aitl-product--oos:hover {
  transform: none;
  box-shadow: var(--aitl-shadow-1);
  border-color: var(--aitl-line);
}
.aitl-product--oos:hover .aitl-product__media img {
  transform: none;
}

/* OOS badge */
.aitl-product__oos-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(17,17,17,0.86);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.aitl-product__oos-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ef4444;
}

/* Disabled / "notify me" CTA */
.aitl-product .aitl-product__cta--oos {
  background: #e5e7eb !important;
  color: var(--aitl-muted) !important;
  box-shadow: none;
  cursor: not-allowed;
  pointer-events: auto;
}
.aitl-product .aitl-product__cta--oos:hover {
  background: #e5e7eb !important;
  color: var(--aitl-muted) !important;
  box-shadow: none;
}

/* ============================================
   PAGINATION
   ============================================ */
.aitl-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 44px;
  flex-wrap: wrap;
}
.aitl-pagination a,
.aitl-pagination span {
  min-width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--aitl-surface);
  border: 1px solid var(--aitl-line);
  color: var(--aitl-ink);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  transition: background .2s, color .2s, border-color .2s, transform .15s;
  font-feature-settings: "tnum";
}
.aitl-pagination a:hover {
  border-color: var(--aitl-primary);
  color: var(--aitl-primary);
  transform: translateY(-1px);
}
.aitl-pagination .current {
  background: var(--aitl-primary);
  color: #fff;
  border-color: var(--aitl-primary);
  box-shadow: 0 6px 14px -4px rgba(30,42,120,0.4);
}
.aitl-pagination .next,
.aitl-pagination .prev {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.aitl-pagination .next svg,
.aitl-pagination .prev svg { width: 14px; height: 14px; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
  .aitl-grid { grid-template-columns: repeat(2, 1fr); gap: 20px; }
}

@media (max-width: 900px) {
  .aitl-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .aitl-shop { padding: 28px 16px 48px; }
  .aitl-page-head { padding: 40px 18px; }
}

/* ----- MOBILE: single-column horizontal cards ----- */
@media (max-width: 600px) {
  body.post-type-archive-product,
  body.tax-product_cat,
  body.tax-product_tag {
    background: var(--aitl-bg);
  }

  .aitl-page-head {
    padding: 26px 16px 18px;
    background: linear-gradient(180deg, #eef1f7 0%, #f5f5f5 100%);
  }
  .aitl-page-head .aitl-breadcrumb {
    margin-bottom: 8px;
    font-size: 11px;
    line-height: 1.8;
  }
  .aitl-page-head h1 {
    font-size: 24px;
    line-height: 1.35;
  }

  .aitl-shop {
    padding: 16px 12px 36px;
    max-width: 390px;
  }

  .aitl-toolbar {
    display: grid;
    grid-template-columns: 1fr 166px;
    gap: 12px;
    margin-bottom: 18px;
    align-items: center;
  }

  .aitl-toolbar__count {
    grid-column: 1;
    grid-row: 1;
    display: block !important;
    visibility: visible !important;
    font-size: 12px;
    text-align: right;
    white-space: nowrap;
  }

  .aitl-toolbar__sort {
    grid-column: 2;
    grid-row: 1;
  }

  .aitl-sort {
    width: 100%;
    max-width: none;
  }

  .aitl-sort select {
    min-width: 0;
    width: 100%;
    height: 44px;
    padding: 10px 12px 10px 34px;
    font-size: 12.5px;
    border-radius: 9px;
  }
  .aitl-sort::after {
    display: block;
    left: 12px;
    right: auto;
    width: 7px;
    height: 7px;
  }

  .aitl-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .aitl-product {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    grid-template-areas:
      "media body"
      "media cta";
    border-radius: 16px;
    min-height: 142px;
    box-shadow: 0 8px 18px rgba(17,24,39,.05);
  }

  .aitl-product:hover {
    transform: none;
    box-shadow: 0 8px 18px rgba(17,24,39,.05);
  }

  .aitl-product__media {
    grid-area: media;
    aspect-ratio: auto;
    height: 100%;
    min-height: 142px;
    padding: 16px 10px 12px;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .aitl-product__media img {
    width: 92px;
    height: 92px;
    max-width: 92px;
    max-height: 92px;
  }

  .aitl-product:hover .aitl-product__media img {
    transform: none;
  }

  .aitl-product__body {
    grid-area: body;
    padding: 14px 14px 2px 10px;
    gap: 7px;
    min-width: 0;
    align-items: flex-start;
    text-align: right;
  }

  .aitl-product__cat {
    font-size: 10px;
    padding: 2px 8px;
    line-height: 1.7;
  }

  .aitl-product__title {
    font-size: 13.5px;
    line-height: 1.55;
    min-height: 0;
    -webkit-line-clamp: 2;
    width: 100%;
    color: #111111;
  }

  .aitl-product__price {
    width: 100%;
    flex-direction: row;
    justify-content: flex-start;
    align-items: baseline;
    gap: 8px;
    padding-top: 2px;
    margin-top: 0;
  }

  .aitl-product__price-now {
    font-size: 14px;
    white-space: nowrap;
  }

  .aitl-product__price-now small { font-size: 10px; }

  .aitl-product__price-old {
    font-size: 11px;
    white-space: nowrap;
  }

  .aitl-product .aitl-product__cta,
  .aitl-product .aitl-product__cta.button,
  .aitl-product .aitl-product__cta.add_to_cart_button {
    grid-area: cta;
    margin: 7px 28px 18px 28px;
    min-height: 39px;
    padding: 8px 14px;
    font-size: 13.5px;
    line-height: 1.35;
    border-radius: 11px;
    align-self: end;
    box-shadow: 0 8px 14px rgba(30,42,120,.15);
    white-space: nowrap;
  }

  .aitl-product .aitl-product__cta svg {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
  }

  .aitl-product__discount,
  .aitl-product__oos-badge {
    font-size: 10px;
    line-height: 1.5;
    padding: 3px 8px 4px;
    top: 8px;
    right: 8px;
  }
  .aitl-product__fav { display: none; }

  .aitl-pagination {
    margin-top: 32px;
    gap: 8px;
  }
  .aitl-pagination a,
  .aitl-pagination span {
    min-width: 36px;
    height: 36px;
    font-size: 13px;
    padding: 0 12px;
    border-radius: 11px;
  }
}

@media (max-width: 360px) {
  .aitl-shop {
    padding-right: 10px;
    padding-left: 10px;
  }

  .aitl-toolbar {
    grid-template-columns: 1fr 146px;
  }

  .aitl-product {
    grid-template-columns: 104px minmax(0, 1fr);
  }

  .aitl-product__media img {
    width: 84px;
    height: 84px;
    max-width: 84px;
    max-height: 84px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .aitl-product, .aitl-product__media img, .aitl-product__cta, .aitl-product__fav {
    transition: none !important;
  }
  .aitl-product:hover { transform: none; }
}
