/* =========================================================================
   1. إخفاء عناصر WooCommerce الافتراضية للمنتج 4492 (Aufkleber V2)
   ========================================================================= */
.postid-4492 .woocommerce-product-gallery,
.postid-4492 .summary.entry-summary,
.postid-4492 form.cart:not(.platten-custom-cart),
.postid-4492 .product_meta,
.postid-4492 .woocommerce-product-details__short-description,
.postid-4492 p.price,
.postid-4492 span.price,
.postid-4492 .wcppec-checkout-buttons {
  display: none !important;
}

/* =========================================================================
   2. التقسيم الرئيسي للشاشة (كمبيوتر)
   ========================================================================= */
.aufkleber-configurator-v2 {
  display: flex;
  flex-wrap: wrap;
  gap: 30px;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto 40px auto;
  box-sizing: border-box;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
}

.aufkleber-sticky-preview-column {
  flex: 0 0 calc(60% - 15px);
  width: calc(60% - 15px);
  position: -webkit-sticky;
  position: sticky;
  top: 192px;
  height: fit-content;
  display: flex;
  flex-direction: column;
}

.aufkleber-scroll-options-column {
  flex: 0 0 calc(40% - 15px);
  width: calc(40% - 15px);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}
label,
legend {
  font-size: 13px;
  font-style: normal;
  font-weight: bold;
  line-height: 14px;
}

/* =========================================================================
   3. منطقة المعاينة والمعرض (Canvas & Gallery)
   ========================================================================= */
.canvas-container-wrapper {
  background-color: #f1f1f1;
  border: 1px solid #861e38;
  border-radius: 8px;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  position: relative;
  min-height: 400px;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}

.pv2-live-badge {
  position: absolute;
  top: 15px;
  left: 15px;
  background-color: rgba(134, 30, 56, 0.9);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 5px 10px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 15;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  pointer-events: none;
}

.live-dot {
  width: 6px;
  height: 6px;
  background-color: #ff4d4d;
  border-radius: 50%;
  animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 77, 77, 0.7);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(255, 77, 77, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 77, 77, 0);
  }
}

.pv2-canvas-overlay-hints {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 5px;
  padding: 8px 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  pointer-events: none;
  z-index: 15;
  width: max-content;
}

.hint-pc {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  font-weight: 600;
  color: #1d1d1f;
}

.hint-pc span.spacer {
  color: #cccccc;
  font-weight: 300;
  margin: 0 2px;
}

.pv2-hidden-pc {
  display: none;
}

.platten-product-gallery {
  display: flex;
  gap: 10px;
  margin-top: 15px;
  overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-width: thin;
}

.gallery-thumb {
  flex: 0 0 auto;
  width: 75px;
  height: 75px;
  border: 2px solid #ddd;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: #fff;
  transition:
    border-color 0.2s,
    transform 0.2s;
}

.gallery-thumb:hover,
.gallery-thumb.active {
  border-color: #861e38;
  transform: translateY(-2px);
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* =========================================================================
   4. الأزرار المرئية للملصقات والمقاسات (النسخة المدمجة - Compact)
   ========================================================================= */
.visual-select-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(85px, 1fr));
  gap: 8px;
}

/* إخفاء بصري آمن يحافظ على إمكانية الوصول (Accessibility) والتنقل بلوحة المفاتيح */
.visual-select-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
}

/* إضافة تأثير بصري عند التركيز (Focus) بلوحة المفاتيح لتجربة مستخدم أفضل */
.visual-select-option input[type="radio"]:focus + label {
  border-color: #861e38;
  box-shadow: 0 0 0 2px rgba(134, 30, 56, 0.3);
}

.visual-select-option label {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 8px 4px;
  background-color: #ffffff;
  border: 2px solid #dddddd;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease-in-out;
  height: 100%;
  min-height: 35px;
}

.visual-select-option label:hover {
  border-color: #7c7c7c;
  background-color: #ababab;
  transform: translateY(-1px);
}

.visual-select-option input[type="radio"]:checked + label {
  background-color: #861e38;
  border-color: #861e38;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(134, 30, 56, 0.25);
  transform: translateY(0);
}

.visual-select-option .tile-title {
  font-weight: bold;
  font-size: 11px;
}

.visual-select-option .tile-desc {
  font-size: 9px;
  opacity: 0.8;
  margin-top: 2px;
}

.visual-select-option input[type="radio"]:checked + label .tile-desc {
  color: #fff;
}

/* --- تنسيقات المقاسات القياسية والكميات المدمجة --- */
.standard-sizes-wrapper {
  margin-top: 15px;
  margin-bottom: 10px;
}

.standard-sizes-label {
  display: block;
  margin-bottom: 8px;
  color: #333;
  font-size: 13px;
  font-style: normal;
  font-weight: bold;
  line-height: 14px;
}

.standard-sizes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
}

.size-option label {
  padding: 6px 8px;
  flex-direction: row;
  justify-content: flex-start;
  gap: 8px;
  border-width: 1px;
}

.size-text-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.size-icon {
  width: 18px;
  height: 18px;
  color: #888;
  transition: color 0.2s ease-in-out;
  flex-shrink: 0;
}

.size-title {
  font-weight: bold;
  display: block;
  margin-bottom: 1px;
  font-size: 11px;
  color: #333;
  transition: color 0.2s ease-in-out;
}

.size-desc {
  font-size: 9px;
  color: #777;
  transition: color 0.2s ease-in-out;
}

.size-option input[type="radio"]:checked + label .size-icon,
.size-option input[type="radio"]:checked + label .size-title,
.size-option input[type="radio"]:checked + label .size-desc {
  color: #ffffff;
}

/* عناصر الإدخال والرفع */
.pv2-options-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.pv2-config-group {
  background-color: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}
.pv2-group-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #861e38;
  padding: 0;
  margin: 0;
  border-bottom: 1px solid #eee;
  padding-bottom: 10px;
}
.pv2-input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}
.pv2-input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.pv2-input-group label {
  font-size: 13px;
  color: #666;
  font-weight: 600;
}
.pv2-input-group input {
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 16px;
  outline: none;
}
.pv2-input-group input:focus {
  border-color: #861e38;
}

.pv2-upload-container {
  border: 2px dashed #ddd;
  border-radius: 10px;
  padding: 30px 20px;
  text-align: center;
  background-color: #fcfcfc;
  cursor: pointer;
}
.pv2-upload-container:hover {
  border-color: #861e38;
  background-color: #fff9fa;
}
#printDataInfo {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}

/* =========================================================================
   5. بنر السعر وصندوق الملخص
   ========================================================================= */
.v2-sticky-banner {
  background-color: #f9f9f9;
  border: 1px solid #861e38;
  border-radius: 8px;
  padding: 10px 15px;
  margin-bottom: 20px;
  position: sticky;
  top: 192px;
  z-index: 100000; /* 🚨 تم رفع الطبقة إلى مئة ألف لتغطي جميع الأزرار 🚨 */
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
  transition: all 0.4s ease;
}

.v2-sticky-banner.hidden-sticky {
  opacity: 0;
  visibility: hidden;
  transform: translateY(15px);
  pointer-events: none;
}

.v2-sticky-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.v2-price-label {
  font-size: 16px;
  font-weight: 700;
  color: #333;
}
.v2-sticky-right {
  text-align: right;
}
.v2-gross-price {
  font-size: 28px;
  font-weight: 700;
  color: #861e38;
  line-height: 1;
  display: block;
  margin-bottom: 5px;
}
.v2-tax-details {
  font-size: 13px;
  color: #555;
}
.v2-unit-details {
  font-size: 14px;
  color: #cc0000;
  font-weight: bold;
  margin-top: 5px;
}
.v2-shipping-text {
  color: #28a745;
  font-weight: 700;
  font-size: 14px;
  margin-top: 5px;
}

/* الملخص (Zusammenfassung) */
.pv2-summary-box {
  border: 1px solid #861e38;
  border-radius: 10px;
  padding: 25px;
  background: #fff;
  margin-top: 30px;
}
.pv2-summary-title {
  font-size: 25px;
  font-weight: 700;
  margin-bottom: 25px;
  color: #861e38;
}
.pv2-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 15px;
  color: #666;
}
.pv2-summary-row span:last-child {
  color: #333;
  font-weight: 600;
  text-align: right;
}
.pv2-summary-price-area {
  margin-top: 25px;
  padding-top: 15px;
}
.pv2-main-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.pv2-main-price-row span:first-child {
  font-size: 18px;
  font-weight: 700;
  color: #333;
}
.pv2-price-val {
  font-size: 28px;
  font-weight: 700;
  color: #861e38;
}
.pv2-price-sub-info {
  text-align: right;
  font-size: 14px;
  color: #555;
}
.text-success-bold {
  color: #28a745;
  font-weight: 700;
  font-size: 15px;
  display: block;
}
.pv2-shipping-note {
  color: #999;
  font-size: 14px;
  display: block;
  margin-top: -22px;
}
.pv2-cart-btn {
  display: block;
  width: 100%;
  background-color: #861e38;
  color: #fff;
  border: none;
  padding: 15px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.3s;
  margin-top: 20px;
}
.pv2-cart-btn:hover {
  background-color: #601528;
}

/* =========================================================================
   6. Lightbox (المعرض المنبثق)
   ========================================================================= */
#gallery-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.95);
  z-index: 9999999 !important;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}
.close-lightbox {
  position: absolute;
  top: 20px;
  right: 30px;
  color: white;
  font-size: 45px;
  cursor: pointer;
  z-index: 10000000 !important;
  transition: color 0.3s ease;
  line-height: 1;
}
.close-lightbox:hover {
  color: #861e38;
}
.lightbox-main-wrapper {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 20px;
  box-sizing: border-box;
  height: calc(100vh - 120px);
  min-height: 0;
}
#lightbox-main-img {
  width: 100%;
  height: 100%;
  max-width: 90vw; /* يضمن عدم خروج الصورة عن عرض الشاشة */
  max-height: 70vh; /* يضمن ترك مساحة للمصغرات في الأسفل */
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  display: block; /* يمنع وجود أي مسافات غريبة في الأسفل */
}
#lightbox-thumbs-container {
  width: 100%;
  height: 120px;
  min-height: 120px;
  background: rgba(20, 20, 20, 0.98);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  padding: 10px 20px;
  box-sizing: border-box;
  overflow-x: auto;
  border-top: 1px solid #333;
  flex-shrink: 0;
  margin-bottom: 30px;
  border-bottom: 1px solid #333;
}
.lightbox-thumb {
  width: 80px;
  height: 80px;
  border-radius: 6px;
  cursor: pointer;
  overflow: hidden;
  opacity: 0.5;
  transition: all 0.3s ease;
  border: 2px solid transparent;
  flex-shrink: 0;
  background: #fff;
}
.lightbox-thumb:hover,
.lightbox-thumb.active {
  opacity: 1;
  border-color: #861e38;
  transform: translateY(-3px);
}
.lightbox-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* رسائل فحص الجودة */
.pv2-quality-info {
  font-size: 13px;
  margin-top: 5px;
  padding: 8px 10px !important;
  border-radius: 6px;
  line-height: 1.4;
  display: block;
}
.quality-green {
  background-color: #e8f5e9 !important;
  color: #2e7d32 !important;
  border: 1px solid #c8e6c9 !important;
}
.quality-yellow {
  background-color: #fff3e0 !important;
  color: #d35400 !important;
  border: 1px solid #ffe0b2 !important;
}
.quality-red {
  background-color: #fce8e8 !important;
  color: #c00 !important;
  border: 1px solid #f5c2c2 !important;
}
.pv2-dpi-warning {
  display: block;
  margin-top: 3px;
}

/* =========================================================================
   7. الأكواد الموحدة لشاشات الجوال (Floating Widget & Fullscreen)
   ========================================================================= */
@media (max-width: 900px) {
  /* 🚨 حل المساحة البيضاء الجانبية بشكل نهائي (منع 100vw واستخدام 100%) 🚨 */
  body,
  html {
    max-width: 100%;
    /* تم إزالة overflow-x: hidden هنا لأنه يعطل عمل position: sticky */
  }

  /* يتم تطبيق إخفاء الفائض العرضي على حاوية الموقع فقط لمنع التمرير الجانبي */
  #page,
  .site-content {
    overflow-x: hidden !important;
  }

  .page-container,
  .configurator-container {
    overflow-x: hidden !important;
    max-width: 100% !important;
  }

  .aufkleber-configurator-v2 {
    flex-direction: column !important;
    gap: 15px;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  .aufkleber-sticky-preview-column,
  .aufkleber-scroll-options-column {
    width: 100% !important;
    max-width: 100% !important;
    flex: none !important;
    box-sizing: border-box !important;
  }

  .aufkleber-sticky-preview-column {
    position: relative !important;
    margin: 0 0 15px 0 !important;
    top: 0;
    z-index: 10;
    height: auto !important;
  }

  /* 🚨 الكود الجديد لتوسيط وإعطاء مساحة للمعاينة في الجوال 🚨 */
  .aufkleber-sticky-preview-column:not(.is-minimized):not(.is-fullscreen)
    .canvas-container-wrapper {
    height: 350px !important; /* ارتفاع مريح للجوال */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
  }

  .aufkleber-sticky-preview-column:not(.is-minimized):not(.is-fullscreen)
    #three-container,
  .aufkleber-sticky-preview-column:not(.is-minimized):not(.is-fullscreen)
    #konva-container {
    height: 100% !important;
    width: 100% !important;
  }

  /* 🚨 نقل المعاينة العائمة إلى اليسار بالقوة لتجاوز مشكلة الكاش 🚨 */
  .aufkleber-sticky-preview-column.is-minimized {
    position: fixed !important;
    width: 140px !important;
    height: 175px !important;
    max-height: 175px !important;
    overflow: hidden !important;
    z-index: 999999 !important;
    background: #fff !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3) !important;
    border: 2px solid #861e38 !important;
    border-radius: 8px !important;
    margin: 0 !important;
    transition: none !important;
    touch-action: none;
    left: 20px !important;
    right: auto !important;
    bottom: 20px !important;
    top: auto !important;
  }

  .is-minimized .canvas-container-wrapper {
    height: 140px !important;
    min-height: 140px !important;
    border: none !important;
    border-radius: 6px 6px 0 0 !important;
  }
  .is-minimized #konva-container,
  .is-minimized #three-container {
    height: 140px !important;
    width: 100% !important;
    pointer-events: none;
  }
  .is-minimized .pv2-live-badge,
  .is-minimized .platten-product-gallery,
  .is-minimized .pv2-canvas-overlay-hints {
    display: none !important;
  }

  .is-minimized .pv2-hidden-pc {
    display: block !important;
    width: 100% !important;
    height: 35px !important;
    background-color: #333 !important;
    color: #fff !important;
    font-size: 11px !important;
    font-weight: bold !important;
    border: none !important;
    border-radius: 0 0 6px 6px !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 35px !important;
    position: relative !important;
  }

  .aufkleber-sticky-preview-column.is-minimized #view-mode-single,
  .aufkleber-sticky-preview-column.is-minimized #view-mode-bogen,
  .aufkleber-sticky-preview-column.is-minimized #view-mode-roll {
    font-size: 10px !important;
    padding: 4px 6px !important;
  }

  .aufkleber-sticky-preview-column.is-minimized
    .canvas-container-wrapper
    > div[style*="top: 15px"] {
    top: 5px !important;
    right: 5px !important;
  }

  .aufkleber-sticky-preview-column.is-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100dvh !important;
    z-index: 1000000 !important;
    background: #fff !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 15px !important;
    box-sizing: border-box !important;
  }
  .aufkleber-sticky-preview-column.is-fullscreen .canvas-container-wrapper {
    width: 100% !important;
    max-width: 700px !important;
    height: calc(100% - 50px) !important;
    max-height: calc(100% - 50px) !important;
    border-radius: 8px 8px 0 0 !important;
  }
  .aufkleber-sticky-preview-column.is-fullscreen #konva-container,
  .aufkleber-sticky-preview-column.is-fullscreen #three-container {
    height: 100% !important;
    pointer-events: auto;
  }
  .aufkleber-sticky-preview-column.is-fullscreen .pv2-hidden-pc {
    height: 50px !important;
    width: 100% !important;
    max-width: 700px !important;
    margin: 0 auto !important;
    border-radius: 0 0 8px 8px !important;
    display: block !important;
    position: static !important;
    font-size: 14px !important;
  }
  .aufkleber-sticky-preview-column.is-fullscreen .platten-product-gallery {
    display: none !important;
  }

  /* بانر السعر اللاصق للجوال */
  .v2-sticky-banner {
    position: relative !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 12px 15px !important; /* تقليل الحشوة قليلاً ليطابق الصورة */
    top: auto;
    border: 1px solid #861e38 !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
    margin-bottom: 20px;
    background-color: #ffffff !important;
    z-index: 1000 !important;
    transition:
      opacity 0.3s ease,
      visibility 0.3s ease !important;
  }

  .v2-sticky-banner.is-stuck {
    position: fixed !important;
    top: 80px !important; /* 🚨 المسافة الدقيقة 82px كما طلبت 🚨 */
    left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
    background-color: #ffffff !important;
    z-index: 100000 !important; /* 🚨 تم رفع الطبقة هنا أيضاً لتطابق الكمبيوتر 🚨 */
  }

  /* الإخفاء الناعم (Fadeout) */
  .v2-sticky-banner.hidden-sticky {
    opacity: 0 !important;
    visibility: hidden !important;
    transform: none !important; /* إزالة الحركة العمودية للحفاظ على نعومة الاختفاء */
  }

  .v2-sticky-content {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
  .v2-gross-price {
    font-size: 24px !important;
    margin-bottom: 0;
    line-height: 1;
  }
  .v2-tax-details,
  .v2-unit-details,
  .v2-shipping-text {
    font-size: 11px !important;
    margin-top: 2px !important;
    line-height: 1.1;
  }

  /* Lightbox Responsive */
  #lightbox-thumbs-container {
    justify-content: flex-start;
    padding: 10px;
    height: 140px;
    min-height: 100px;
    margin-bottom: 50px;
    border-bottom: 1px solid #333;
  }
  .lightbox-thumb {
    width: 120px;
    height: 120px;
  }
  .close-lightbox {
    top: 20px;
    right: 20px;
    font-size: 30px;
  }
  .lightbox-main-wrapper {
    padding: 10px;
    padding-top: 50px;
    height: calc(100vh - 100px);
  }

  /* 🚨 السر هنا أيضاً: إجبار حقول الأبعاد على الالتفاف لكي لا تكسر عرض الشاشة 🚨 */
  #dimensions-inputs {
    flex-wrap: wrap !important;
  }
  #dimensions-inputs > div {
    min-width: 120px !important;
  }
}

/* =========================================================================
   تنسيق العناوين وعلامات الاستفهام (Apple-Style Info Tooltip)
   ========================================================================= */
fieldset.section-fieldset {
  margin-top: 25px;
  padding: 5px 25px 20px 25px;
  border: 1px solid #861e38;
  border-radius: 8px;
  background-color: #ffffff;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}

fieldset.section-fieldset legend.fieldset-legend-inline {
  padding: 0 15px;
  background-color: #ffffff;
  font-size: 16px;
  font-weight: bold;
  color: #861e38;
  border-radius: 4px;
}

.fieldset-legend-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  width: 100%;
}

.info-tooltip-wrapper {
  position: relative;
  display: inline-block;
}

.info-icon {
  width: 22px;
  height: 22px;
  background-color: #f5f5f7;
  color: #861e38;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid #d2d2d7;
  position: relative;
  z-index: 1; /* 🚨 إبقاء الأيقونة نفسها في طبقة منخفضة 🚨 */
}

.info-icon:hover,
.info-tooltip-wrapper.active-mobile .info-icon {
  background-color: #861e38;
  color: #ffffff;
  border-color: #861e38;
}

.info-popup {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: calc(100% + 12px);
  left: auto;
  right: -12px;
  width: 280px;
  max-width: 90vw;
  background: #ffffff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  border: 1px solid #eaeaea;

  /* للكمبيوتر: حركة من الأسفل للأعلى */
  transform: translate(0, 10px) scale(0.95);
  transition: all 0.3s ease;

  font-size: 13px;
  color: #1d1d1f;
  line-height: 1.5;
  pointer-events: none;
  font-weight: normal;
  z-index: 9999999 !important;
}

.info-tooltip-wrapper:hover .info-popup,
.info-tooltip-wrapper.active-mobile .info-popup {
  visibility: visible;
  opacity: 1;
  transform: translate(0, 0) scale(1);
  pointer-events: auto;
}

.info-popup::after,
.info-popup::before {
  content: "";
  position: absolute;
  top: 100%;
  left: auto;
  right: 18px; /* الموضع الأساسي للكمبيوتر */
  border-style: solid;
}

.info-popup::after {
  border-width: 8px;
  border-color: #ffffff transparent transparent transparent;
  margin-top: -1px;
}
.info-popup::before {
  border-width: 9px;
  border-color: #eaeaea transparent transparent transparent;
}

.info-popup h4 {
  color: #861e38;
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 15px;
  border-bottom: 1px solid #f0f0f0;
  padding-bottom: 8px;
}

/* 📱 🚨 العودة للنظام الذكي في الجوال مع حركة من اليسار 🚨 📱 */
@media (max-width: 900px) {
  .info-popup {
    /* 🚨 توسيط مطلق (50% من الشاشة) 🚨 */
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;

    /* سحب الصندوق للخلف بمقدار نصف عرضه ونصف طوله ليكون في المنتصف تماماً */
    transform: translate(-50%, -50%) scale(1) !important;

    width: 90vw !important; /* يأخذ 90% من عرض الشاشة */
    max-width: 350px !important;
    margin: 0 !important;
    z-index: 9999999 !important;
  }

  /* إخفاء السهم في الجوال (لأنه قد يشير لمكان خاطئ عند التوسيط المطلق) */
  .info-popup::after,
  .info-popup::before {
    display: none !important;
  }
}
/* =========================================================================
   صندوق معلومات المادة الثابت (Infobox Static)
   ========================================================================= */
.v2-static-infobox {
  background: #ffffff;
  border-radius: 8px;
  padding: 16px;
  margin-top: 15px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.06);
  border: 1px solid #eaeaea;
  border-left: 5px solid #861e38;
  font-size: 13px;
  color: #1d1d1f;
  line-height: 1.5;
  transition: all 0.3s ease;
}

@media (max-width: 900px) {
  .v2-static-infobox {
    padding: 12px;
    font-size: 12px;
  }
}
/* =========================================================================
   8. فئات مساعدة (Utility Classes) لتنظيف HTML بدون تكرار الكود
   ========================================================================= */

/* أزرار المعاينة العلوية (مُحسنة ومتجاوبة) */
.v2-view-modes-wrapper {
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 100;
  display: flex;
  gap: 8px;
  flex-direction: row;
}
.v2-btn-base {
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 8px 15px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: bold;
  color: #ffffff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}
.v2-btn-base:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}
.v2-btn-primary {
  background-color: #861e38;
  border-color: #861e38;
}
.v2-btn-dark {
  background-color: #333333;
}

/* جعل الأزرار عمودية (تحت بعضها) على شاشات الجوال */
@media (max-width: 900px) {
  .v2-view-modes-wrapper {
    flex-direction: column;
    top: 10px;
    right: 10px;
  }
  .v2-btn-base {
    padding: 6px 10px;
    font-size: 11px;
  }
  /* تعديل وضعها عندما تكون المعاينة مصغرة في الزاوية */
  .aufkleber-sticky-preview-column.is-minimized .v2-view-modes-wrapper {
    top: 5px !important;
    right: 5px !important;
    gap: 3px;
  }
}

/* العناوين ومنطقة المعاينة */
.v2-page-title {
  color: #861e38;
  margin-bottom: 3px;
  font-size: 28px;
  font-weight: bold;
  margin-top: 0;
}
.v2-page-subtitle {
  color: #666;
  font-size: 15px;
  margin-top: 0;
}
.v2-three-canvas {
  width: 100%;
  height: 400px;
  background-color: #e9ecef;
  border-radius: 8px;
  overflow: hidden;
  cursor: grab;
}
.v2-icon-middle {
  vertical-align: middle;
}

/* الأشكال والمدخلات (Inputs) */
.v2-shape-svg {
  width: 40px;
  height: 40px;
  margin-bottom: 10px;
}
.v2-bold-text {
  font-weight: bold;
}
.v2-flex-row-gap15 {
  display: flex;
  gap: 15px;
  margin-top: 15px;
}
.v2-flex-1 {
  flex: 1;
}
.v2-form-input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
}
.v2-qty-input {
  width: 100px;
  font-weight: bold;
  font-size: 1.1em;
  color: #861e38;
  margin-bottom: 20px;
}

/* منطقة الرفع والتنبيهات (Upload & Alerts) */
.v2-alert-box {
  margin-top: 15px;
  padding: 10px;
  background-color: #fdf5f7;
  border-left: 4px solid #861e38;
  color: #555;
  font-size: 0.9em;
}
.v2-up-icon {
  font-size: 30px;
  color: #861e38;
  display: block;
  margin-bottom: 10px;
}
.v2-up-title {
  font-weight: bold;
  color: #333;
  font-size: 1.1em;
}
.v2-up-desc {
  color: #666;
  display: block;
  margin-top: 5px;
}
.v2-progress-bg {
  background: #e0e0e0;
  border-radius: 4px;
  height: 8px;
  width: 100%;
  overflow: hidden;
}
.v2-progress-fill {
  background: #861e38;
  height: 100%;
  transition: width 0.3s;
}
.v2-progress-status {
  color: #555;
  display: block;
  margin-top: 5px;
  font-weight: bold;
  font-size: 12px;
}
.v2-mt-15 {
  margin-top: 15px;
}
.v2-list-reset {
  list-style: none;
  padding: 0;
  margin: 0;
}
/* =========================================================================
   9. Tooltips لأزرار المعاينة والمواد (PC: أسفل | Mobile: يسار)
   ========================================================================= */
.v2-btn-base,
.v2-tooltip {
  position: relative;
}

/* 🚨 السر هنا: رفع طبقة الزر بأكمله عند التمرير ليغطي أي عناصر تحته 🚨 */
.v2-tooltip:hover,
.v2-tooltip:active,
.v2-tooltip:focus {
  z-index: 90;
}

/* تصميم المربع النصي - الافتراضي (أسفل الزر للكمبيوتر) */
.v2-tooltip::after {
  content: attr(data-info);
  position: absolute;
  top: calc(100% + 5px); /* التموضع للأسفل */
  left: 50%;
  transform: translateX(-50%);
  background-color: #861e38;
  color: #ffffff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: normal;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease,
    top 0.2s ease;
  z-index: 105;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* تصميم السهم الموجه للأعلى (لأن المربع النصي أصبح بالأسفل) */
.v2-tooltip::before {
  content: "";
  position: absolute;
  top: calc(100% - 1px);
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent #861e38 transparent; /* السهم يشير للأعلى */
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease,
    top 0.2s ease;
  z-index: 105;
}

/* تأثير الظهور للكمبيوتر فقط (عند تمرير الماوس) */
@media (hover: hover) and (min-width: 901px) {
  .v2-tooltip:hover::after {
    opacity: 1;
    visibility: visible;
    top: calc(100% + 12px);
  }
  .v2-tooltip:hover::before {
    opacity: 1;
    visibility: visible;
    top: calc(100% + 6px);
  }
}

/* تخصيص التصميم للجوال فقط (المربع يظهر على اليسار) */
@media (max-width: 900px) {
  .v2-tooltip::after {
    top: 50%; /* توسيط عمودي */
    left: auto;
    right: calc(100% + 5px); /* دفع المربع ليكون على يسار الزر */
    transform: translateY(-50%); /* التوسيط الدقيق */
    transition:
      opacity 0.2s ease,
      visibility 0.2s ease,
      right 0.2s ease;
  }
  .v2-tooltip::before {
    top: 50%;
    left: auto;
    right: calc(100% - 1px); /* تموضع السهم بين المربع والزر */
    transform: translateY(-50%);
    border-color: transparent transparent transparent #861e38; /* السهم يشير لليمين */
    transition:
      opacity 0.2s ease,
      visibility 0.2s ease,
      right 0.2s ease;
  }

  /* تأثير الظهور للجوال (عند النقر أو التركيز) لأزرار المعاينة */
  .v2-tooltip:active::after,
  .v2-tooltip:focus::after {
    opacity: 1;
    visibility: visible;
    right: calc(100% + 12px);
  }
  .v2-tooltip:active::before,
  .v2-tooltip:focus::before {
    opacity: 1;
    visibility: visible;
    right: calc(100% + 6px);
  }
} /* 🚨🚨🚨 هذا هو القوس المفقود! يجب وضعه هنا لإغلاق قسم الميديا الخاص بالجوال 🚨🚨🚨 */

/* =========================================================================
   10. تعليمات الاستخدام (Hints) للكمبيوتر والجوال
   ========================================================================= */
.hint-mobile {
  display: none;
}

@media (max-width: 900px) {
  .hint-pc {
    display: none !important;
  }
  .hint-mobile {
    display: flex !important;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    font-weight: 600;
    color: #1d1d1f;
  }
  .hint-mobile span.spacer {
    color: #cccccc;
    font-weight: 300;
    margin: 0 2px;
  }
}

/* =========================================================================
   11. نظام Tooltips الخاص بالمواد فقط (مستقل تماماً عن المعاينة)
   ========================================================================= */
.mat-tooltip-label {
  position: relative;
}

.mat-tooltip-label::after {
  content: attr(data-info);
  position: absolute;
  background-color: #861e38;
  color: #ffffff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: normal;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  z-index: 90; /* 🚨 تم التخفيض 🚨 */
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.mat-tooltip-label::before {
  content: "";
  position: absolute;
  border-style: solid;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  z-index: 90; /* 🚨 تم التخفيض 🚨 */
}

/* رفع الطبقة عند التمرير أو النقر لتجنب التداخل */
.visual-select-option:focus-within .mat-tooltip-label,
.visual-select-option:hover .mat-tooltip-label,
.mat-tooltip-label:hover {
  z-index: 90; /* 🚨 تم التخفيض 🚨 */
}

/* 🚨 التأكد من عدم قص الصندوق في الكمبيوتر من قبل قوالب Elementor 🚨 */
.visual-select-option {
  overflow: visible !important;
}

/* 💻 تصميم الكمبيوتر: الظهور عند التمرير (Hover) 💻 */
@media (min-width: 901px) {
  .mat-tooltip-label::after {
    top: calc(100% + 5px);
    left: 50%;
    transform: translateX(-50%);
    transition:
      opacity 0.2s ease,
      visibility 0.2s ease,
      top 0.2s ease;
    display: block !important; /* ضمان عدم إخفائه كعنصر مضمن */
  }
  .mat-tooltip-label::before {
    top: calc(100% - 1px);
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-color: transparent transparent #861e38 transparent;
    transition:
      opacity 0.2s ease,
      visibility 0.2s ease,
      top 0.2s ease;
    display: block !important;
  }

  /* إجبار الظهور بأولوية قصوى لتخطي أي أكواد أخرى */
  .visual-select-option:hover .mat-tooltip-label::after,
  .mat-tooltip-label:hover::after {
    opacity: 1 !important;
    visibility: visible !important;
    top: calc(100% + 12px) !important;
  }
  .visual-select-option:hover .mat-tooltip-label::before,
  .mat-tooltip-label:hover::before {
    opacity: 1 !important;
    visibility: visible !important;
    top: calc(100% + 6px) !important;
  }
}

/* 📱 تصميم الجوال: يفتح للأسفل ويبقى مفتوحاً عند النقر 📱 */
@media (max-width: 900px) {
  .mat-tooltip-label::after {
    top: calc(100% + 5px);
    left: 50%;
    transform: translateX(-50%);
    transition:
      opacity 0.2s ease,
      visibility 0.2s ease,
      top 0.2s ease;
  }
  .mat-tooltip-label::before {
    top: calc(100% - 1px);
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-color: transparent transparent #861e38 transparent;
    transition:
      opacity 0.2s ease,
      visibility 0.2s ease,
      top 0.2s ease;
  }

  /* سيبقى الصندوق مفتوحاً طالما أن الزر تم النقر عليه ومفعل */
  .visual-select-option:focus-within .mat-tooltip-label::after,
  .mat-tooltip-label:active::after {
    opacity: 1;
    visibility: visible;
    top: calc(100% + 12px);
  }
  .visual-select-option:focus-within .mat-tooltip-label::before,
  .mat-tooltip-label:active::before {
    opacity: 1;
    visibility: visible;
    top: calc(100% + 6px);
  }
}
