/* ==========================================================================
   Maniro — Catalog Page
   Page header, filter/sort toolbar, product grid, pagination, empty state.
   Structured so the grid section can later be driven entirely by Django
   ({% for %} / {{ }}) with zero changes to this stylesheet.
   ========================================================================== */

/* ---------- Page header ---------- */
.catalog-hero {
  position: relative;
  overflow: hidden;
  padding-block: 64px 72px;
  background: var(--color-bg-subtle);
  border-bottom: 1px solid var(--color-border);
}

/* Soft ambient wash + faint blueprint grid across the whole header,
   restrained so it reads as engineering/industrial rather than retail */
.catalog-hero::before {
  content: "";
  position: absolute;
  inset: -30% -10% auto -10%;
  height: 520px;
  background: radial-gradient(
    55% 100% at 50% 0%,
    var(--color-sky-tint) 0%,
    transparent 72%
  );
  pointer-events: none;
  z-index: 0;
}

.catalog-hero-inner {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  align-items: center;
  gap: 56px;
}

.catalog-hero-content {
  text-align: start;
}

.catalog-hero .breadcrumb {
  display: block;
  text-align: start;
  margin: 0 0 22px;
  font-size: 13px;
  letter-spacing: 0.01em;
}

.catalog-hero .breadcrumb a {
  color: var(--color-text-muted);
  transition: color 0.2s var(--ease);
}

.catalog-hero .breadcrumb a:hover {
  color: var(--color-sky-dark);
}

[data-theme="dark"] .catalog-hero .breadcrumb a:hover {
  color: var(--color-sky);
}

.catalog-hero .breadcrumb-sep {
  margin-inline: 8px;
  color: var(--color-border);
}

.catalog-hero .breadcrumb-current {
  color: var(--color-text);
  font-weight: 600;
}

.catalog-hero-title {
  margin: 0 0 16px;
  font-size: clamp(32px, 4.4vw, 48px);
  line-height: 1.22;
  font-weight: 800;
  letter-spacing: normal;
  color: var(--color-text);
}

.catalog-hero-text {
  max-width: 480px;
  font-size: 16.5px;
  line-height: 1.85;
  color: var(--color-text-muted);
}

/* ---------- Visual placeholder: engineering illustration frame ---------- */
.catalog-hero-visual {
  position: relative;
}

.catalog-hero-frame {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* Technical corner brackets — viewfinder / blueprint framing cue */
.catalog-hero-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid var(--color-sky-dark);
  opacity: 0.55;
  z-index: 2;
}

[data-theme="dark"] .catalog-hero-corner {
  border-color: var(--color-sky);
}

.catalog-hero-corner--tl {
  top: 14px;
  inset-inline-start: 14px;
  border-width: 2px 0 0 2px;
}

.catalog-hero-corner--tr {
  top: 14px;
  inset-inline-end: 14px;
  border-width: 2px 2px 0 0;
}

.catalog-hero-corner--bl {
  bottom: 14px;
  inset-inline-start: 14px;
  border-width: 0 0 2px 2px;
}

.catalog-hero-corner--br {
  bottom: 14px;
  inset-inline-end: 14px;
  border-width: 0 2px 2px 0;
}

.catalog-hero-illustration {
  display: block;
  width: 100%;
  height: 100%;
  color: var(--color-text);
}

.catalog-hero-illustration .equip-grid {
  fill: var(--color-text);
  opacity: 0.06;
}

[data-theme="dark"] .catalog-hero-illustration .equip-grid {
  opacity: 0.09;
}

.catalog-hero-illustration .equip-line {
  stroke: currentColor;
  stroke-opacity: 0.82;
}

.catalog-hero-illustration .equip-node {
  fill: var(--color-sky-dark);
}

[data-theme="dark"] .catalog-hero-illustration .equip-node {
  fill: var(--color-sky);
}

.catalog-hero-illustration .equip-cable {
  stroke: currentColor;
  stroke-opacity: 0.35;
  fill: none;
}

.catalog-hero-illustration .equip-insulator ellipse {
  fill: none;
  stroke: currentColor;
  stroke-opacity: 0.75;
  stroke-width: 1.6;
}

.catalog-hero-illustration .equip-dim line {
  stroke: var(--color-sky-dark);
  stroke-opacity: 0.5;
}

[data-theme="dark"] .catalog-hero-illustration .equip-dim line {
  stroke: var(--color-sky);
}

/* ---------- Toolbar: search + category + product type + sort ----------
   Presentational only for now — no filtering logic is wired up here.
   Field ids/names are named to map directly onto future Django GET
   params (q, category, type, sort) once this panel is connected. */
.catalog-toolbar {
  padding-block: 32px;
  background: var(--color-bg-subtle);
  border-bottom: 1px solid var(--color-border);
}

.catalog-toolbar-inner {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.filter-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 24px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

/* ---- Row 1: search ---- */
.filter-panel-row--search {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.filter-search {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.filter-search-icon {
  position: absolute;
  top: 50%;
  inset-inline-start: 16px;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--color-text-muted);
  pointer-events: none;
}

.filter-search-input {
  width: 100%;
  height: 48px;
  padding-inline: 46px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg-subtle);
  color: var(--color-text);
  font-family: inherit;
  font-size: 14.5px;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}

.filter-search-input::placeholder {
  color: var(--color-text-muted);
}

.filter-search-input:hover {
  border-color: var(--color-sky);
  background: var(--color-surface);
}

.filter-search-input:focus-visible,
.filter-search-input:focus {
  outline: none;
  border-color: var(--color-sky);
  background: var(--color-surface);
  box-shadow: 0 0 0 3px var(--color-sky-tint);
}

.filter-search-submit {
  flex-shrink: 0;
  height: 48px;
  padding-inline: 26px;
  border: 1px solid var(--color-sky);
  border-radius: var(--radius-sm);
  background: var(--color-sky);
  color: #ffffff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease),
    transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.filter-search-submit:hover,
.filter-search-submit:focus-visible {
  background: var(--color-sky-dark);
  border-color: var(--color-sky-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ---- Row 2: category / product type / sort + reset ---- */
.filter-panel-row--fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(170px, 1fr)) auto;
  align-items: end;
  gap: 14px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.filter-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--color-text-muted);
}

.filter-label-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--color-sky-dark);
}

[data-theme="dark"] .filter-label-icon {
  color: var(--color-sky);
}

.filter-select-shell {
  position: relative;
}

.filter-select {
  width: 100%;
  height: 44px;
  padding-inline: 14px 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg-subtle);
  color: var(--color-text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
  /* Custom chevron, mirrored for RTL */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235b6b7c' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 14px center;
  appearance: none;
}

.filter-select:hover {
  border-color: var(--color-sky);
  background: var(--color-surface);
}

.filter-select:focus-visible,
.filter-select:focus {
  outline: none;
  border-color: var(--color-sky);
  background: var(--color-surface);
  box-shadow: 0 0 0 3px var(--color-sky-tint);
}

[data-theme="dark"] .filter-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2393a1b0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.filter-reset {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding-inline: 18px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease),
    background-color 0.2s var(--ease);
}

.filter-reset svg {
  transition: transform 0.4s var(--ease);
}

.filter-reset:hover,
.filter-reset:focus-visible {
  border-color: var(--color-sky);
  color: var(--color-text);
  background: var(--color-bg-subtle);
}

.filter-reset:hover svg {
  transform: rotate(-135deg);
}

.catalog-results-count {
  padding-inline: 4px;
  font-size: 13px;
  color: var(--color-text-muted);
}

/* ---------- Product grid ----------
   Component-driven card: image, name, code, category, short description,
   and a single "مشاهده مشخصات" action — no price / cart / commerce UI.
   Built so the whole block can be swapped 1:1 with the Django loop in
   catalog/item-template.html without touching this stylesheet. */
.catalog-section {
  padding-block: 56px 96px;
  background: var(--color-bg);
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
}

.catalog-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s var(--ease), border-color 0.3s var(--ease),
    box-shadow 0.35s var(--ease);
}

.catalog-card:hover,
.catalog-card:focus-within {
  transform: translateY(-6px);
  border-color: var(--color-sky);
  box-shadow: var(--shadow-lg);
}

/* ---- Media: image / placeholder icon, clipped for the hover zoom ---- */
.catalog-card-media {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  background: var(--color-bg-subtle);
  border-bottom: 1px solid var(--color-border);
  overflow: hidden;
}

.catalog-card-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s var(--ease);
}

.catalog-card-media .catalog-placeholder-icon {
  width: 34%;
  height: 34%;
  color: var(--color-text-muted);
  opacity: 0.55;
  transition: transform 0.5s var(--ease);
}

/* Professional hover: media scales up gently inside its clipped frame */
.catalog-card:hover .catalog-card-image,
.catalog-card:focus-within .catalog-card-image {
  transform: scale(1.08);
}

.catalog-card:hover .catalog-card-media .catalog-placeholder-icon,
.catalog-card:focus-within .catalog-card-media .catalog-placeholder-icon {
  transform: scale(1.06);
}

/* Category badge, floated over the media */
.catalog-card-tag {
  position: absolute;
  top: 12px;
  inset-inline-start: 12px;
  z-index: 1;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--color-bg) 82%, transparent);
  backdrop-filter: blur(6px);
  color: var(--color-sky-dark);
  font-size: 11.5px;
  font-weight: 700;
}

[data-theme="dark"] .catalog-card-tag {
  color: var(--color-sky);
}

/* ---- Body ---- */
.catalog-card-body {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  padding: 20px 22px 22px;
}

.catalog-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 6px;
}

.catalog-card-title {
  margin: 0;
  font-size: 16.5px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: normal;
  color: var(--color-text);
}

/* Product code — small chip, replaces the old price block */
.catalog-card-code {
  flex-shrink: 0;
  margin-top: 2px;
  padding: 3px 9px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  direction: ltr;
}

.catalog-card-text {
  margin: 0 0 20px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--color-text-muted);
  flex-grow: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- Action: single "مشاهده مشخصات" button, no commerce info ---- */
.catalog-card-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.catalog-card-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 44px;
  border: 1.5px solid var(--color-sky);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-sky-dark);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease),
    gap 0.25s var(--ease);
}

[data-theme="dark"] .catalog-card-btn {
  color: var(--color-sky);
}

.catalog-card-btn:hover,
.catalog-card-btn:focus-visible {
  background: var(--color-sky);
  color: #ffffff;
  gap: 12px;
}

.catalog-card-btn svg {
  flex-shrink: 0;
  transform: scaleX(-1);
  transition: transform 0.25s var(--ease);
}

.catalog-card-btn:hover svg,
.catalog-card-btn:focus-visible svg {
  transform: translateX(-3px) scaleX(-1);
}

/* ---------- Empty state (shown when a filter/search yields no items;
   in Django this maps to the {% empty %} branch of the {% for %} loop) ---------- */
.catalog-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-block: 72px;
  color: var(--color-text-muted);
}

.catalog-empty.is-visible {
  display: flex;
}

.catalog-empty-icon {
  width: 44px;
  height: 44px;
  margin-bottom: 18px;
  opacity: 0.5;
}

.catalog-empty-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
}

.catalog-empty-text {
  margin: 0;
  font-size: 14px;
  max-width: 360px;
}

/* ---------- Pagination ---------- */
.catalog-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 56px;
}

.catalog-page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding-inline: 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 13.5px;
  font-weight: 600;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease),
    background-color 0.2s var(--ease);
}

.catalog-page-link:hover {
  border-color: var(--color-sky);
  color: var(--color-text);
  background: var(--color-sky-tint);
}

.catalog-page-link.is-active {
  border-color: var(--color-sky);
  background: var(--color-sky);
  color: #ffffff;
}

.catalog-page-link[aria-disabled="true"] {
  opacity: 0.4;
  pointer-events: none;
}

.catalog-page-link svg {
  transition: transform 0.2s var(--ease);
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .catalog-hero {
    padding-block: 40px 48px;
  }

  .catalog-hero-inner {
    grid-template-columns: 1fr;
    gap: 36px;
  }

  .catalog-hero-content {
    text-align: center;
  }

  .catalog-hero .breadcrumb {
    text-align: center;
  }

  .catalog-hero-text {
    margin-inline: auto;
  }

  .catalog-hero-frame {
    aspect-ratio: 16 / 10;
  }

  .catalog-section {
    padding-block: 40px 64px;
  }

  .catalog-toolbar-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-panel {
    padding: 18px 16px;
  }

  .filter-panel-row--fields {
    grid-template-columns: 1fr;
  }

  .filter-reset {
    width: 100%;
  }

  .catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
  }

  .catalog-card-body {
    padding: 18px 18px 18px;
  }

  .catalog-card-heading {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .catalog-grid {
    grid-template-columns: 1fr;
  }

  .filter-panel-row--search {
    flex-direction: column;
  }

  .filter-search-submit {
    width: 100%;
  }
}
