.mad-root {
  --mad-bg: #f7f9fc;
  --mad-border: #e3e8ef;
  --mad-text: #172033;
  --mad-muted: #667085;
  width: 100%;
  margin: 14px 0 8px;
  color: var(--mad-text);
  font: inherit;
  direction: rtl;
}

.mad-root[hidden],
.mad-root [hidden] {
  display: none !important;
}

.mad-inline {
  display: grid;
  gap: 10px;
}

.mad-card {
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--mad-border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(16, 24, 40, .04);
  overflow: hidden;
}

.mad-card::before {
  position: absolute;
  inset: 0 0 0 auto;
  width: 3px;
  content: "";
  background: #3b82f6;
}

.mad-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #eff6ff;
  color: #2563eb;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
}

.mad-card-body {
  min-width: 0;
}

.mad-card h4 {
  margin: 2px 0 4px;
  color: var(--mad-text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.7;
}

.mad-card-scope {
  display: inline-flex;
  margin: 0 0 7px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  font-size: 10px;
  font-weight: 700;
}

.mad-card-content {
  color: #3d475a;
  font-size: 13px;
  line-height: 2;
  overflow-wrap: anywhere;
}

.mad-card-content > :first-child {
  margin-top: 0;
}

.mad-card-content > :last-child {
  margin-bottom: 0;
}

.mad-card-content img,
.mad-card-content video,
.mad-card-content iframe {
  max-width: 100%;
  height: auto;
  border-radius: 9px;
}

.mad-card-content table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.mad-card-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 8px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #2563eb;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.mad-card-toggle b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #eff6ff;
  font-size: 15px;
}

.mad-style-premium {
  border-color: #ddd6fe;
  background: linear-gradient(135deg, #fff 0%, #faf7ff 100%);
}
.mad-style-premium::before { background: linear-gradient(#7c3aed, #a855f7); }
.mad-style-premium .mad-card-icon { background: #f3e8ff; color: #7c3aed; }
.mad-style-premium .mad-card-scope { background: #f3e8ff; color: #6d28d9; }

.mad-style-warning {
  border-color: #fed7aa;
  background: linear-gradient(135deg, #fff 0%, #fffaf3 100%);
}
.mad-style-warning::before { background: #f97316; }
.mad-style-warning .mad-card-icon { background: #fff7ed; color: #ea580c; }

.mad-style-success {
  border-color: #bbf7d0;
  background: linear-gradient(135deg, #fff 0%, #f5fff8 100%);
}
.mad-style-success::before { background: #16a34a; }
.mad-style-success .mad-card-icon { background: #ecfdf3; color: #15803d; }

.mad-style-neutral::before { background: #64748b; }
.mad-style-neutral .mad-card-icon { background: #f1f5f9; color: #475569; }

.mad-open-button {
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  width: 100%;
  padding: 12px 13px;
  border: 1px solid #dbe4f0;
  border-radius: 11px;
  background: #fff;
  color: #1d4ed8;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  text-align: right;
  box-shadow: 0 3px 12px rgba(16, 24, 40, .04);
  cursor: pointer;
}

.mad-open-button:not([hidden]) { display: flex; }
.mad-open-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: #eff6ff;
  font-weight: 900;
}
.mad-open-arrow { margin-right: auto; font-size: 23px; line-height: 1; }

.mad-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
}

.mad-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .56);
  backdrop-filter: blur(2px);
}

.mad-dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(760px, calc(100% - 28px));
  max-height: min(82vh, 760px);
  transform: translate(-50%, -50%);
  overflow: hidden;
  border-radius: 18px;
  background: #f8fafc;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
}

.mad-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 16px 18px;
  border-bottom: 1px solid #e5eaf1;
  background: #fff;
}

.mad-dialog-kicker {
  display: block;
  margin-bottom: 2px;
  color: #64748b;
  font-size: 10px;
  font-weight: 700;
}

.mad-dialog-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 900;
}

.mad-close-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  color: #334155;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.mad-dialog-content {
  display: grid;
  gap: 11px;
  max-height: calc(min(82vh, 760px) - 73px);
  padding: 15px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

html.mad-modal-open,
html.mad-modal-open body {
  overflow: hidden !important;
}

@media (max-width: 767px) {
  .mad-root { margin: 10px 0 6px; }
  .mad-card {
    grid-template-columns: 31px minmax(0, 1fr);
    gap: 8px;
    padding: 11px 11px 11px 12px;
    border-radius: 10px;
  }
  .mad-card-icon {
    width: 29px;
    height: 29px;
    border-radius: 8px;
    font-size: 13px;
  }
  .mad-card h4 { font-size: 13px; line-height: 1.65; }
  .mad-card-content { font-size: 12px; line-height: 1.9; }
  .mad-open-button { padding: 10px 11px; font-size: 12px; }
  .mad-dialog {
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 88dvh;
    transform: none;
    border-radius: 18px 18px 0 0;
  }
  .mad-dialog-header { padding: 13px 14px; }
  .mad-dialog-header h3 { font-size: 15px; }
  .mad-dialog-content {
    max-height: calc(88dvh - 65px);
    padding: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mad-root *, .mad-root *::before, .mad-root *::after { scroll-behavior: auto !important; transition: none !important; }
}


.mad-root.mad-guides-only {
  height: 0;
  min-height: 0;
  margin: 0;
  overflow: visible;
}

.mad-has-group-guide > .control-label,
.mad-has-group-guide > .attribute_label,
.mad-has-group-guide > .form-control-label,
.mad-has-group-guide > label:first-child,
.mad-has-selector-help > .control-label,
.mad-has-selector-help > .attribute_label,
.mad-has-selector-help > .form-control-label,
.mad-has-selector-help > label:first-child {
  display: inline-flex !important;
  align-items: center;
  width: auto !important;
  vertical-align: middle;
}

.mad-group-guide-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  margin: 0 8px 7px 0;
  padding: 4px 9px;
  border: 1px solid #cfdcf1;
  border-radius: 999px;
  background: #f8fbff;
  color: #2459b8;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.4;
  vertical-align: middle;
  cursor: pointer;
  box-shadow: none;
}

.mad-group-guide-button:hover,
.mad-group-guide-button:focus {
  border-color: #8eafea;
  background: #eef5ff;
  color: #16489d;
  outline: none;
}

.mad-group-guide-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 19px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #2d63c8;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.mad-guide-style-premium { border-color: #d9c8f2; background: #faf7ff; color: #6d28d9; }
.mad-guide-style-premium .mad-group-guide-icon { background: #7c3aed; }
.mad-guide-style-warning { border-color: #fed7aa; background: #fffaf3; color: #c2410c; }
.mad-guide-style-warning .mad-group-guide-icon { background: #ea580c; }
.mad-guide-style-success { border-color: #bbf7d0; background: #f5fff8; color: #15803d; }
.mad-guide-style-success .mad-group-guide-icon { background: #16a34a; }
.mad-guide-style-neutral { border-color: #d8dee8; background: #f8fafc; color: #475569; }
.mad-guide-style-neutral .mad-group-guide-icon { background: #64748b; }

@media (max-width: 767px) {
  .mad-group-guide-button {
    min-height: 28px;
    margin: 0 6px 6px 0;
    padding: 4px 8px;
    font-size: 10px;
  }
  .mad-group-guide-icon { width: 17px; height: 17px; flex-basis: 17px; font-size: 10px; }
}


/* v2.6.5: one independent trigger for each selected attribute. */
.mad-selector-help-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  margin: 0 6px 5px 0;
  vertical-align: middle;
}
.mad-selector-help-actions .mad-group-guide-button {
  margin: 0;
}
.mad-choice-help-button {
  border-color: #c9d8f2;
  background: #f7faff;
  color: #1d4ed8;
}
.mad-choice-help-button:hover,
.mad-choice-help-button:focus {
  border-color: #86a9e7;
  background: #edf4ff;
  color: #163f91;
}
.mad-choice-help-icon {
  background: #2563eb;
  font-family: Arial, sans-serif;
  font-style: normal;
}
.mad-choice-help-fallback {
  margin-top: 0;
}
.mad-root.mad-modal-host-only {
  width: 0;
  height: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: visible;
}
.mad-root.mad-modal-host-only > .mad-inline,
.mad-root.mad-modal-host-only > .mad-open-button {
  display: none !important;
}
@media (max-width: 767px) {
  .mad-selector-help-actions {
    display: flex;
    width: 100%;
    margin: 5px 0 4px;
    gap: 5px;
  }
  .mad-selector-help-actions .mad-group-guide-button {
    flex: 1 1 auto;
    justify-content: center;
    max-width: 100%;
  }
}

/* Stable placement in ordinary Panda product pages and family-product pages. */
.product-variants + .mad-root,
.product-actions .mad-root,
#add-to-cart-or-refresh .mad-root {
  clear: both;
  align-self: stretch;
  max-width: 100%;
  min-width: 0;
}
.product-actions .mad-root .mad-inline,
#add-to-cart-or-refresh .mad-root .mad-inline {
  width: 100%;
}

/* v2.5.0: fallback placement for custom family/variant layouts. */
.mad-group-guides-fallback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  width: 100%;
  margin: 7px 0 10px;
  padding: 8px 10px 2px;
  border: 1px solid #e1e8f2;
  border-radius: 12px;
  background: #fbfdff;
}
.mad-group-guides-fallback .mad-group-guide-button {
  margin: 0 0 6px;
}
.mad-root.mad-guides-only.mad-has-guide-fallback {
  height: auto;
  min-height: 0;
  margin: 7px 0 10px;
  overflow: visible;
}
@media (max-width: 767px) {
  .mad-group-guides-fallback {
    gap: 5px;
    padding: 7px 8px 1px;
    border-radius: 10px;
  }
  .mad-group-guides-fallback .mad-group-guide-button {
    flex: 1 1 auto;
    justify-content: center;
    max-width: 100%;
  }
}

/* v2.6.3: preserve the last valid rules while a new combination is loading. */
.mad-root.mad-is-refreshing {
  opacity: .72;
  transition: opacity .16s ease;
}
.mad-root.mad-is-refreshing::before {
  content: 'در حال بروزرسانی…';
  display: block;
  width: max-content;
  max-width: 100%;
  margin: 0 0 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef4ff;
  color: #315f9e;
  font-size: 10px;
  line-height: 1.7;
}


/* v2.6.6: bind every help trigger to its own attribute-group heading. */
.mad-variant-heading-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  width: 100%;
  min-width: 0;
  margin: 0 0 7px;
}
.mad-variant-heading-row > .control-label,
.mad-variant-heading-row > .attribute_label,
.mad-variant-heading-row > .form-control-label,
.mad-variant-heading-row > .variant-label,
.mad-variant-heading-row > .product-variant-label,
.mad-variant-heading-row > legend,
.mad-variant-heading-row > h3,
.mad-variant-heading-row > h4,
.mad-variant-heading-row > h5 {
  flex: 1 1 170px;
  min-width: 0;
  margin: 0 !important;
}
.mad-variant-heading-row > .mad-selector-help-actions {
  flex: 0 1 auto;
  width: auto;
  max-width: 100%;
  margin: 0;
  margin-inline-start: auto;
}
.mad-variant-heading-row .mad-group-guide-button {
  max-width: 100%;
}

/* Exact scroll lock: the page stays on the same pixel while the modal is open. */
html.mad-modal-open {
  overflow: hidden !important;
  overscroll-behavior: none;
}
html.mad-modal-open body {
  overscroll-behavior: none;
}
.mad-backdrop {
  touch-action: none;
}
.mad-dialog,
.mad-dialog-content {
  touch-action: pan-y;
}

@media (max-width: 767px) {
  .mad-variant-heading-row {
    align-items: stretch;
    gap: 5px;
    margin-bottom: 6px;
  }
  .mad-variant-heading-row > .control-label,
  .mad-variant-heading-row > .attribute_label,
  .mad-variant-heading-row > .form-control-label,
  .mad-variant-heading-row > .variant-label,
  .mad-variant-heading-row > .product-variant-label,
  .mad-variant-heading-row > legend,
  .mad-variant-heading-row > h3,
  .mad-variant-heading-row > h4,
  .mad-variant-heading-row > h5 {
    flex-basis: 100%;
  }
  .mad-variant-heading-row > .mad-selector-help-actions {
    flex: 1 1 100%;
    width: 100%;
    margin: 0;
  }
}

/* v2.6.7: viewport portal for modal. The overlay is moved under body while open
   so Panda/family transformed containers cannot clip or blank it. */
.mad-modal[hidden] {
  display: none !important;
}
body > .mad-modal.mad-modal-portal {
  --mad-bg: #f7f9fc;
  --mad-border: #e3e8ef;
  --mad-text: #172033;
  --mad-muted: #667085;
  display: block;
  color: var(--mad-text);
  font: inherit;
  direction: rtl;
  isolation: isolate;
  contain: layout style;
}
body > .mad-modal.mad-modal-portal .mad-dialog {
  z-index: 1;
}
body > .mad-modal.mad-modal-portal .mad-backdrop {
  z-index: 0;
}

/* v2.6.9 — compact Method A cards.
   Flat paint, no decorative pseudo-layer, no gradient and no card shadow. */
.mad-method-a-card {
  position: relative;
  display: block !important;
  width: 100% !important;
  min-width: 0;
  margin: 9px 0 !important;
  padding: 11px !important;
  border: 1px solid #dce6f4 !important;
  border-radius: 14px !important;
  background: #fff !important;
  box-sizing: border-box;
  overflow: visible;
}

.mad-method-a-card > .mad-variant-heading-row,
.mad-method-a-card .mad-method-a-card__header {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 7px;
  width: 100%;
  min-width: 0;
  margin: 0 0 8px !important;
}

.mad-method-a-card__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: #eef5ff;
  color: #2563eb;
  font: 800 13px/1 Arial, sans-serif;
}
.mad-method-a-card__icon::before { content: "i"; }
.mad-method-a-card__icon--warranty::before { content: "✓"; }
.mad-method-a-card__icon--country::before { content: "◎"; }
.mad-method-a-card__icon--color::before { content: "●"; }
.mad-method-a-card__icon--size::before { content: "↔"; }

.mad-method-a-card .mad-variant-heading-row > :is(
  .control-label,
  .attribute_label,
  .form-control-label,
  .variant-label,
  .product-variant-label,
  legend,
  h3,
  h4,
  h5
) {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0 !important;
  color: #172033 !important;
  font-size: 14px !important;
  font-weight: 800 !important;
  line-height: 1.5 !important;
}

.mad-method-a-card .mad-selector-help-actions--header {
  display: inline-flex !important;
  flex: 0 0 auto !important;
  width: auto !important;
  margin: 0 0 0 auto !important;
  padding: 0;
}

.mad-method-a-card .mad-group-guide-button--header {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px !important;
  width: 28px !important;
  min-width: 28px;
  max-width: 28px !important;
  height: 28px;
  min-height: 28px;
  margin: 0 !important;
  padding: 0 !important;
  border-color: #cfe0fb;
  border-radius: 50%;
  background: #f3f7ff;
  box-shadow: none !important;
}
.mad-method-a-card .mad-group-guide-button--header .mad-group-guide-icon {
  width: 19px;
  height: 19px;
  flex-basis: 19px;
  margin: 0;
  font-size: 11px;
}
.mad-method-a-card .mad-group-guide-button--header .mad-group-guide-label {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.mad-method-a-card .mad-selector-help-actions--footer {
  display: flex !important;
  align-items: center;
  width: 100% !important;
  max-width: none;
  margin: 7px 0 0 !important;
  padding: 6px 0 0;
  border-top: 1px solid #edf2f8;
}

.mad-method-a-card .mad-choice-help-button--footer {
  display: inline-flex !important;
  justify-content: center;
  width: min(100%, 360px) !important;
  min-height: 34px;
  margin: 0 0 0 auto !important;
  padding: 5px 10px;
  border-color: #c9daf5;
  background: #f8fbff;
  box-shadow: none !important;
  font-size: 10.5px;
  line-height: 1.35;
}

.mad-method-a-card select[name^="group["] {
  width: 100% !important;
  min-height: 40px;
  margin: 0 !important;
  padding-inline: 10px 34px !important;
  border: 1px solid #d6e0ee !important;
  border-radius: 10px !important;
  background-color: #fff !important;
  box-shadow: none !important;
  font-size: 12.5px;
}

.mad-method-a-card :is(ul, ol, .attribute_list, .input-container, [class*="attribute_list"]) {
  max-width: 100%;
}

.mad-method-a-card--radio :is(ul, ol, .attribute_list) {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 6px;
  margin: 0 !important;
  padding: 0 !important;
  list-style: none;
}
.mad-method-a-card--radio li {
  min-width: 0;
  margin: 0 !important;
  list-style: none;
}
.mad-method-a-card--color :is(.attribute_list, ul, [class*="color"]) {
  gap: 6px;
}

@media (max-width: 767px) {
  .mad-method-a-card {
    margin: 7px 0 !important;
    padding: 9px 10px !important;
    border-radius: 12px !important;
  }

  .mad-method-a-card > .mad-variant-heading-row,
  .mad-method-a-card .mad-method-a-card__header {
    gap: 6px;
    margin-bottom: 6px !important;
  }

  .mad-method-a-card__icon {
    flex-basis: 23px;
    width: 23px;
    height: 23px;
    border-radius: 7px;
    font-size: 11px;
  }

  .mad-method-a-card .mad-variant-heading-row > :is(
    .control-label,
    .attribute_label,
    .form-control-label,
    .variant-label,
    .product-variant-label,
    legend,
    h3,
    h4,
    h5
  ) {
    font-size: 13px !important;
    line-height: 1.4 !important;
  }

  .mad-method-a-card .mad-group-guide-button--header {
    flex-basis: 25px !important;
    width: 25px !important;
    min-width: 25px;
    max-width: 25px !important;
    height: 25px;
    min-height: 25px;
  }
  .mad-method-a-card .mad-group-guide-button--header .mad-group-guide-icon {
    width: 17px;
    height: 17px;
    flex-basis: 17px;
    font-size: 10px;
  }

  .mad-method-a-card .mad-selector-help-actions--footer {
    margin-top: 6px !important;
    padding-top: 5px;
  }

  .mad-method-a-card .mad-choice-help-button--footer {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 32px;
    margin: 0 !important;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 10px;
  }

  .mad-method-a-card select[name^="group["] {
    min-height: 37px;
    padding-inline: 9px 32px !important;
    border-radius: 9px !important;
    font-size: 12px;
  }

  .mad-method-a-card--radio :is(ul, ol, .attribute_list),
  .mad-method-a-card--color :is(.attribute_list, ul, [class*="color"]) {
    gap: 5px;
  }
}
