
/* =========================================
   ZARIF — PREMIUM STOREFRONT DESIGN
   STEP 5A

   Works alongside existing style.css.
   Does not change checkout or inventory.
========================================= */

/* ---------- Design tokens ---------- */

:root {
  --zarif-primary: #1769d2;
  --zarif-primary-dark: #104fa5;
  --zarif-ink: #101820;
  --zarif-muted: #64748b;
  --zarif-line: #e6ebf2;
  --zarif-surface: #f7f9fc;
  --zarif-radius: 16px;
  --zarif-card-shadow:
    0 8px 25px rgba(16, 38, 74, 0.055);
  --zarif-hover-shadow:
    0 20px 45px rgba(16, 38, 74, 0.13);
}

/* ---------- General improvements ---------- */

html {
  scroll-padding-top: 110px;
}

body {
  overflow-x: clip;
}

button,
input,
select,
textarea {
  font: inherit;
}

button:disabled {
  cursor: not-allowed;
}

:where(
  button,
  a,
  input,
  select,
  textarea
):focus-visible {
  outline: 3px solid var(--zarif-primary);
  outline-offset: 3px;
}

/* ---------- Main shop sections ---------- */

#products {
  scroll-margin-top: 110px;
}

#products .section__heading {
  gap: 18px;
  align-items: center;
}

#product-count {
  color: var(--zarif-muted);
  font-size: 0.9rem;
}

#products .filters {
  padding: 18px;
  border: 1px solid var(--zarif-line);
  border-radius: var(--zarif-radius);
  background: var(--zarif-surface);
}

#products .filters select,
#products .filters input,
.zarif-catalog-filters select {
  min-height: 44px;
  border-radius: 10px;
}

/* ---------- Product grid ---------- */

#product-grid {
  display: grid;
  grid-template-columns:
    repeat(auto-fill, minmax(220px, 1fr));
  gap: 22px;
  align-items: stretch;
}

/* ---------- Premium product cards ---------- */

#product-grid .card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;

  padding: 0;
  overflow: hidden;

  text-align: start;
  background: #fff;

  border: 1px solid var(--zarif-line);
  border-radius: 18px;

  box-shadow: var(--zarif-card-shadow);

  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    border-color 0.22s ease;
}

#product-grid .card:hover {
  border-color: #c8d9ee;
  box-shadow: var(--zarif-hover-shadow);
  transform: translateY(-4px);
}

#product-grid .card:focus-visible {
  outline: 3px solid var(--zarif-primary);
  outline-offset: 3px;
}

/* ---------- Product photographs ---------- */

#product-grid .thumb {
  position: relative;

  width: 100%;
  aspect-ratio: 4 / 5;

  display: flex;
  align-items: center;
  justify-content: center;

  overflow: hidden;

  background:
    linear-gradient(
      145deg,
      #ffffff,
      #f0f4f9
    );
}

#product-grid .thumb img {
  display: block;

  width: 100%;
  height: 100%;

  object-fit: contain;
  object-position: center;

  padding: 12px;

  transition: transform 0.35s ease;
}

#product-grid .card:hover .thumb img {
  transform: scale(1.045);
}

/* ---------- Sale and stock badges ---------- */

#product-grid .badge {
  z-index: 1;

  max-width: calc(100% - 20px);
  padding: 5px 11px;

  border-radius: 999px;

  font-size: 0.72rem;
  font-weight: 750;
  line-height: 1.4;
  letter-spacing: 0;

  box-shadow:
    0 3px 9px rgba(0, 0, 0, 0.08);
}

/* ---------- Product information ---------- */

#product-grid .card__body {
  display: flex;
  flex-direction: column;
  gap: 7px;

  flex: 1;
  min-width: 0;

  padding: 16px 16px 18px;
}

#product-grid .card__brand {
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0.035em;
  color: var(--zarif-muted);
}

#product-grid .card__name {
  display: -webkit-box;
  overflow: hidden;

  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;

  line-height: 1.55;
  font-size: 0.98rem;
  font-weight: 750;

  min-height: 3.1em;

  color: var(--zarif-ink);
}

#product-grid .price {
  color: var(--zarif-primary);
  font-size: 1.08rem;
  font-weight: 850;
  line-height: 1.5;
}

/* ---------- Product dialog ---------- */

#product-dialog {
  width: min(1000px, 96vw);
  max-height: min(94dvh, 900px);

  overflow-x: hidden;

  border-radius: 20px;
  background: #fff;

  box-shadow:
    0 25px 80px rgba(0, 0, 0, 0.22);
}

#product-dialog .detail {
  display: grid;
  grid-template-columns:
    minmax(0, 1.05fr)
    minmax(0, 0.95fr);
  align-items: start;
}

/* Important: product gallery needs a vertical
   layout, rather than the original flex row. */

#product-dialog .detail__media {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;

  width: 100%;
  min-width: 0;
  min-height: 360px;

  padding: 18px;

  background: #f7f9fc;
}

/* Existing main picture fallback */

#product-dialog .detail__media > img {
  width: 100%;
  height: auto;
  max-height: 500px;

  object-fit: contain;
  margin: auto;
}

/* ---------- Gallery main photograph ---------- */

#product-dialog .detail__media .zg-stage {
  display: grid;
  place-items: center;

  width: 100%;
  min-width: 0;
  min-height: 300px;

  aspect-ratio: 4 / 5;

  overflow: hidden;
  border-radius: 14px;

  background: #fff;
}

#product-dialog .detail__media .zg-stage img {
  display: block;

  width: 100%;
  height: 100%;
  max-height: 520px;

  object-fit: contain;
  object-position: center;

  padding: 12px;
}

/* ---------- Gallery thumbnails ---------- */

#product-dialog .detail__media .zg-thumbs {
  display: flex;
  flex-direction: row;
  gap: 10px;

  width: 100%;
  max-width: 100%;

  overflow-x: auto;
  overflow-y: hidden;

  padding: 12px 2px 6px;

  scrollbar-width: thin;
  scroll-snap-type: x proximity;
}

#product-dialog .detail__media .zg-thumb {
  flex: 0 0 70px;

  width: 70px;
  height: 70px;

  display: grid;
  place-items: center;

  padding: 4px;

  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 11px;

  scroll-snap-align: start;

  transition:
    border-color 0.18s ease,
    background 0.18s ease;
}

#product-dialog
.detail__media
.zg-thumb[aria-pressed="true"] {
  border-color: var(--zarif-primary);
  background: #eff6ff;
}

#product-dialog .detail__media .zg-thumb:hover {
  border-color: var(--zarif-primary);
}

#product-dialog .detail__media .zg-thumb img {
  width: 100%;
  height: 100%;
  max-height: none;

  padding: 0;
  object-fit: contain;
}

/* ---------- Product information panel ---------- */

#product-dialog .detail__info {
  display: flex;
  flex-direction: column;
  align-items: stretch;

  min-width: 0;
  padding: 28px;

  gap: 14px;
}

#product-dialog .detail__name {
  font-size: clamp(
    1.45rem,
    2.4vw,
    2rem
  );
  line-height: 1.4;
  font-weight: 850;
  overflow-wrap: anywhere;
}

#product-dialog .price {
  font-size: 1.35rem;
  font-weight: 850;
}

/* ---------- Color and size selectors ---------- */

#product-dialog .zarif-variant-picker {
  width: 100%;
  margin-block: 6px;
}

#product-dialog .sizes {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

#product-dialog button.size {
  min-width: 48px;
  min-height: 46px;

  border-radius: 10px;
  font-weight: 750;
}

#product-dialog button.size.on {
  background: var(--zarif-primary);
  border-color: var(--zarif-primary);
  color: #fff;
}

#product-dialog button.size:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---------- Shopping buttons ---------- */

#product-dialog .btn {
  min-height: 50px;
  border-radius: 11px;
  font-weight: 750;
}

#product-dialog .btn--blue {
  background: var(--zarif-primary);
  color: #fff;
}

#product-dialog .btn--blue:hover {
  background: var(--zarif-primary-dark);
}

/* ---------- Tablet ---------- */

@media (max-width: 900px) {
  #product-grid {
    grid-template-columns:
      repeat(3, minmax(0, 1fr));
    gap: 14px;
  }

  #product-dialog .detail__info {
    padding: 20px;
  }

  #product-dialog .detail__media {
    padding: 12px;
  }
}

/* ---------- Smartphone ---------- */

@media (max-width: 700px) {
  #product-grid {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  #product-grid .card {
    border-radius: 13px;
  }

  #product-grid .thumb {
    aspect-ratio: 4 / 5;
  }

  #product-grid .thumb img {
    padding: 7px;
  }

  #product-grid .card__body {
    padding: 10px 10px 13px;
    gap: 5px;
  }

  #product-grid .card__name {
    font-size: 0.86rem;
  }

  #product-grid .card__brand {
    font-size: 0.7rem;
  }

  #product-grid .price {
    font-size: 0.92rem;
  }

  #product-dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: 96dvh;

    border-radius: 16px 16px 0 0;
  }

  #product-dialog .detail {
    grid-template-columns: minmax(0, 1fr);
  }

  #product-dialog .detail__media {
    min-height: 0;
    padding: 12px;
  }

  #product-dialog .detail__media .zg-stage {
    min-height: 210px;
    aspect-ratio: 5 / 4;
  }

  #product-dialog .detail__media .zg-stage img {
    max-height: 36dvh;
    padding: 8px;
  }

  #product-dialog .detail__media .zg-thumb {
    flex-basis: 60px;
    width: 60px;
    height: 60px;
  }

  #product-dialog .detail__info {
    padding: 17px;
    gap: 11px;
  }

  #product-dialog .detail__name {
    font-size: 1.35rem;
  }

  #product-dialog .detail__media > img {
    max-height: 35dvh;
  }
}

/* ---------- Small smartphones ---------- */

@media (max-width: 360px) {
  #product-grid {
    gap: 7px;
  }

  #product-grid .card__body {
    padding: 8px;
  }

  #product-grid .card__name {
    font-size: 0.81rem;
  }

  #product-dialog .detail__info {
    padding: 12px;
  }
}

/* ---------- Accessibility ---------- */

@media (hover: none) {
  #product-grid .card:hover {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #product-grid .card,
  #product-grid .thumb img,
  #product-dialog .zg-thumb {
    transition: none !important;
  }

  #product-grid .card:hover {
    transform: none;
  }
}

/* =========================================
   ZARIF — SEO PRODUCT LINKS
   STEP 7C
========================================= */

#product-grid a.card {
  display: flex;
  flex-direction: column;

  color: inherit;
  text-decoration: none;

  cursor: pointer;
}

#product-grid a.card:visited {
  color: inherit;
}

#product-grid a.card:focus-visible {
  outline: 3px solid #1769d2;
  outline-offset: 3px;
}

/* ===========================================
   ZARIF FIX 5C
   PRODUCT DIALOG NOT VISIBLE ON MOBILE
   =========================================== */

/* Override conflicting dialog positioning */
#product-dialog[open] {
  position: fixed !important;

  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;

  inset: 0 !important;
  margin: auto !important;

  display: block !important;

  width: min(1000px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);

  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);

  overflow-x: hidden;
  overflow-y: auto;

  background: #ffffff;
  color: #111111;

  border-radius: 18px;
  box-sizing: border-box;

  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;

  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.3);
}

/* Phones */
@media (max-width: 700px) {
  #product-dialog[open] {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);

    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);

    border-radius: 14px;
  }

  #product-dialog .detail {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  #product-dialog .detail__media,
  #product-dialog .detail__info {
    min-width: 0;
    width: 100%;
  }
}

/* END OF ZARIF FIX 5C */

/* ==========================================
   ZARIF FIX 6B
   PREVENT QUICK-LINK BAR LAYOUT SHIFT
   ========================================== */

#zarif-utility {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;

  overflow-x: auto;
  white-space: nowrap;
}

#zarif-utility .utility__link {
  flex-shrink: 0;
}

/* END OF FIX 6B */

/* ZARIF — Stable brand image dimensions */

.brand-tile img {
  display: block;
  width: 100%;
  height: 3.2rem;
  object-fit: contain;
}

.card__logo {
  display: inline-block;
  width: 6rem;
  height: 1.3rem;
  max-width: 100%;
  object-fit: contain;
}

.brand-chip__logo {
  display: inline-block;
  width: 1.6rem;
  height: 1.2rem;
  object-fit: contain;
}

/* ==========================================
   ZARIF — DISCREET ADMIN ACCESS
   ========================================== */

.zarif-management-access {
  display: flex;
  justify-content: center;
  align-items: center;

  margin-top: 28px;
  padding: 8px 0;
}

.zarif-management-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;

  padding: 10px 14px;

  color: inherit;
  opacity: 0.48;

  font-size: 11px;
  font-weight: 400;
  text-decoration: none;

  border-radius: 8px;

  transition:
    opacity 0.2s ease,
    background-color 0.2s ease;
}

.zarif-management-link:hover,
.zarif-management-link:focus-visible {
  opacity: 1;
  background: rgba(128,128,128,0.12);
}

.zarif-management-link:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.zarif-management-link svg {
  flex-shrink: 0;
}

/* END ADMIN ACCESS */


/* =========================================
   ZARIF — COMPACT LEFT-ALIGNED FOOTER
========================================= */

footer .footer__nav {
  display: flex !important;
  flex-direction: column !important;

  align-items: flex-start !important;
  justify-content: flex-start !important;

  gap: 5px !important;

  width: 100%;
  margin: 12px 0 !important;

  padding: 0 0 0 24px !important;

  direction: ltr;
}

footer .footer__nav > a {
  display: block !important;

  margin: 0 !important;
  padding: 3px 0 !important;

  min-height: 0 !important;

  color: #ffffff;
  font-size: 15px;
  line-height: 1.5 !important;
  text-align: left !important;
  text-decoration: none;
  unicode-bidi: plaintext;
}

footer .footer__nav > a:hover {
  color: #d7e7ff;
  text-decoration: underline;
}

@media (max-width: 700px) {
  footer .footer__nav {
    padding-left: 16px !important;
  }
}

/* END FOOTER FIX */

/* Mobile layout */
@media (max-width: 700px) {
  footer .footer__nav {
    padding-left: 16px;
    padding-right: 0;
    gap: 10px !important;
  }
}

/* END ZARIF FOOTER FIX */

/* ==========================================
   ZARIF — CHECKOUT CUSTOMER POLICIES
========================================== */

.zarif-checkout-policies {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;

  width: 100%;
  margin: 16px 0;
  padding: 14px;

  background: #f5f8fd;
  border: 1px solid #e0e7f1;
  border-radius: 12px;
}

.zarif-checkout-policies a {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-height: 44px;
  padding: 8px 12px;

  color: #174a87;
  background: #ffffff;
  border: 1px solid #d7e3f2;
  border-radius: 8px;

  font-size: 12px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;

  transition:
    background-color .2s ease,
    border-color .2s ease;
}

.zarif-checkout-policies a:hover {
  background: #e9f2ff;
  border-color: #8db6e8;
}

.zarif-checkout-policies a:focus-visible {
  outline: 2px solid #174a87;
  outline-offset: 3px;
}

@media (max-width: 600px) {
  .zarif-checkout-policies {
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
  }

  .zarif-checkout-policies a {
    width: 100%;
  }
}

/* END CHECKOUT CUSTOMER POLICIES */
