/* =========================================================
   IONTMAX Theme — Provizni system — Critical CSS
   Purpose: prevent Affiliate layout flash before module JS adds
   .ipp-affiliate-shell. Strictly scoped through :has(Affiliate marker).
   ========================================================= */

:where(
  .content-wrapper-in:has(#formAffiliateLogin[action*="/action/Affiliate/"]),
  .content-wrapper-in:has(form.forgotten-password-form[action*="/action/Affiliate/"]),
  .content-wrapper-in:has(form.registration-form[action*="/action/Affiliate/"]),
  .content-wrapper-in:has(form.form-registration-affilate[action*="/action/Affiliate/"]),
  .content-wrapper-in:has(#affiliateIntroduction),
  .content-wrapper-in:has(#affiliateMyAccount),
  .content-wrapper-in:has(#affiliateOrders),
  .content-wrapper-in:has(#affiliateBanners),
  .content-wrapper-in:has(#affiliateLinks),
  .content-wrapper-in:has(#affiliateCoupons)
) {
  box-sizing: border-box;
  width: 100%;
  min-height: 60vh;
  min-height: 60svh;
}

/* Keep the title visually stable until JS normalizes its real text. */
:where(
  .content-wrapper-in:not(.ipp-affiliate-shell):has(#formAffiliateLogin[action*="/action/Affiliate/"]),
  .content-wrapper-in:not(.ipp-affiliate-shell):has(form.forgotten-password-form[action*="/action/Affiliate/"]),
  .content-wrapper-in:not(.ipp-affiliate-shell):has(form.registration-form[action*="/action/Affiliate/"]),
  .content-wrapper-in:not(.ipp-affiliate-shell):has(form.form-registration-affilate[action*="/action/Affiliate/"]),
  .content-wrapper-in:not(.ipp-affiliate-shell):has(#affiliateIntroduction)
) .content-inner > h1 {
  font-size: 0 !important;
  line-height: 1 !important;
}

:where(
  .content-wrapper-in:not(.ipp-affiliate-shell):has(#formAffiliateLogin[action*="/action/Affiliate/"]),
  .content-wrapper-in:not(.ipp-affiliate-shell):has(form.forgotten-password-form[action*="/action/Affiliate/"]),
  .content-wrapper-in:not(.ipp-affiliate-shell):has(form.registration-form[action*="/action/Affiliate/"]),
  .content-wrapper-in:not(.ipp-affiliate-shell):has(form.form-registration-affilate[action*="/action/Affiliate/"]),
  .content-wrapper-in:not(.ipp-affiliate-shell):has(#affiliateIntroduction)
) .content-inner > h1::after {
  content: "Affiliate centrum";
  display: block;
  color: #151617;
  font-size: clamp(30px, 3vw, 42px);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

/* Dashboard skeleton before JS class arrives. */
.content-wrapper-in:not(.ipp-affiliate-shell):has(#affiliateIntroduction) {
  display: grid !important;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr) !important;
  gap: clamp(28px, 4vw, 64px) !important;
  align-items: start !important;
}

.content-wrapper-in:not(.ipp-affiliate-shell):has(#affiliateIntroduction) > aside.sidebar,
.content-wrapper-in:not(.ipp-affiliate-shell):has(#affiliateIntroduction) > main#content {
  float: none !important;
  width: auto !important;
  min-width: 0 !important;
}

.content-wrapper-in:not(.ipp-affiliate-shell):has(#affiliateIntroduction) #affiliateIntroduction > .row {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  width: 100% !important;
  margin: 0 !important;
  gap: 20px !important;
}

.content-wrapper-in:not(.ipp-affiliate-shell):has(#affiliateIntroduction) #affiliateIntroduction > .row::before,
.content-wrapper-in:not(.ipp-affiliate-shell):has(#affiliateIntroduction) #affiliateIntroduction > .row::after {
  display: none !important;
  content: none !important;
}

.content-wrapper-in:not(.ipp-affiliate-shell):has(#affiliateIntroduction) #affiliateIntroduction > .row > [class*="col-"] {
  float: none !important;
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  margin: 0 !important;
}

/* Phone control must never flash as a full list before common CSS loads. */
:where(
  .content-wrapper-in:has(form.registration-form[action*="/action/Affiliate/"]),
  .content-wrapper-in:has(form.form-registration-affilate[action*="/action/Affiliate/"])
) .phone-combined-input {
  position: relative !important;
  display: flex !important;
  align-items: stretch !important;
  gap: 8px !important;
  width: 100% !important;
  overflow: visible !important;
}

:where(
  .content-wrapper-in:has(form.registration-form[action*="/action/Affiliate/"]),
  .content-wrapper-in:has(form.form-registration-affilate[action*="/action/Affiliate/"])
) .phone-combined-input > select.js-phone-code,
:where(
  .content-wrapper-in:has(form.registration-form[action*="/action/Affiliate/"]),
  .content-wrapper-in:has(form.form-registration-affilate[action*="/action/Affiliate/"])
) .phone-combined-input > select[name="phoneCode"] {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

:where(
  .content-wrapper-in:has(form.registration-form[action*="/action/Affiliate/"]),
  .content-wrapper-in:has(form.form-registration-affilate[action*="/action/Affiliate/"])
) .phone-combined-input .country-flags {
  position: relative !important;
  flex: 0 0 124px !important;
  width: 124px !important;
  min-width: 124px !important;
  height: 50px !important;
  min-height: 50px !important;
  overflow: visible !important;
  border: 0 !important;
  background: transparent !important;
}

:where(
  .content-wrapper-in:has(form.registration-form[action*="/action/Affiliate/"]),
  .content-wrapper-in:has(form.form-registration-affilate[action*="/action/Affiliate/"])
) .phone-combined-input .country-flags-inner {
  position: absolute !important;
  inset: 0 auto auto 0 !important;
  z-index: 40 !important;
  width: 124px !important;
  min-width: 124px !important;
  height: 50px !important;
  max-height: 50px !important;
  overflow: hidden !important;
  border: 1px solid #d9dcdf !important;
  border-radius: 10px !important;
  background: #fff !important;
}

:where(
  .content-wrapper-in:has(form.registration-form[action*="/action/Affiliate/"]),
  .content-wrapper-in:has(form.form-registration-affilate[action*="/action/Affiliate/"])
) .phone-combined-input .country-flags:not(.active) .country-flag {
  display: none !important;
}

:where(
  .content-wrapper-in:has(form.registration-form[action*="/action/Affiliate/"]),
  .content-wrapper-in:has(form.form-registration-affilate[action*="/action/Affiliate/"])
) .phone-combined-input .country-flags:not(.active) .country-flag.selected {
  display: flex !important;
}

@media (max-width: 767px) {
  .content-wrapper-in:not(.ipp-affiliate-shell):has(#affiliateIntroduction) {
    display: block !important;
  }

  .content-wrapper-in:not(.ipp-affiliate-shell):has(#affiliateIntroduction) #affiliateIntroduction > .row {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
}

/* V3 — keep Affiliate tables visually stable before common CSS arrives. */
.content-wrapper-in:has(#affiliateIntroduction) #affiliateIntroduction table.table,
.content-wrapper-in:has(#affiliateLinks) #affiliateLinks table.table {
  border-color: #e4e6e8 !important;
  box-shadow: none !important;
}

.content-wrapper-in:has(#affiliateIntroduction) #affiliateIntroduction table.table thead,
.content-wrapper-in:has(#affiliateLinks) #affiliateLinks table.table thead {
  background: #f6f7f8 !important;
}

.content-wrapper-in:has(#affiliateIntroduction) #affiliateIntroduction table.table th,
.content-wrapper-in:has(#affiliateIntroduction) #affiliateIntroduction table.table td,
.content-wrapper-in:has(#affiliateLinks) #affiliateLinks table.table th,
.content-wrapper-in:has(#affiliateLinks) #affiliateLinks table.table td {
  border-right: 0 !important;
  border-left: 0 !important;
  border-color: #e4e6e8 !important;
}
