/**
 * =========================================================================
 * BESCHRIFTUNG V2 - DESIGN SYSTEM (Bordeaux: #861e38)
 * =========================================================================
 * Komplettes Split-Screen Layout, identisch zu Aufkleber V2.
 */

/* ==========================================================================
   1. WooCommerce & Astra Theme Fix (Nur für Beschriftung V2 ID: 4507)
   ========================================================================== */

/* 🔴 السر لعمل الـ Sticky: يجب إزالة أي overflow: hidden من الحاويات الأب في قالب Astra */
.post-4507,
.post-4507 .site-content,
.post-4507 .ast-container,
.post-4507 .site-primary,
.post-4507 .entry-content {
  overflow: visible !important;
  clip-path: none !important;
}

/* إجبار منطقة الملخص (الجهة اليمنى التي وضعنا فيها الكونفيجراتور) على أخذ 100% من الشاشة */
.post-4507 .summary.entry-summary {
  width: 100% !important;
  max-width: 100% !important;
  float: none !important;
  clear: both !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* 🔴 إخفاء التصنيفات (Category) ورسائل الـ PayPal وكل العناصر غير المرغوبة */
.post-4507 .summary.entry-summary .product_title,
.post-4507 .summary.entry-summary .price,
.post-4507 .summary.entry-summary .woocommerce-product-rating,
.post-4507 .summary.entry-summary .woocommerce-product-details__short-description,
.post-4507 .product_meta,
.post-4507 .single-product-category, /* 🔴 إخفاء التصنيف الخاص بقالب Astra نهائياً */
.post-4507 .woocommerce-breadcrumb,
.post-4507 form.cart:not(#bv2-config-form),
.post-4507 [id^="zoid-paypal-message-"],
.post-4507 .paypal-messages {
  display: none !important;
}

/* 🔴 إخفاء معرض ووكومرس الافتراضي كلياً لتجنب التكرار وتعارض القالب */
.post-4507 .woocommerce-product-gallery {
  display: none !important;
}

/* 🔴 تصميم شريط الصور المصغرة تحت المعاينة */
.bv2-custom-thumbs-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 5px 0 10px 0;
}
.bv2-custom-thumbs-row::-webkit-scrollbar {
  height: 6px;
}
.bv2-custom-thumbs-row::-webkit-scrollbar-thumb {
  background: #861e38;
  border-radius: 3px;
}
.bv2-thumb-img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.3s ease;
  flex-shrink: 0;
}
.bv2-thumb-img:hover {
  border-color: #861e38;
  transform: translateY(-2px);
}

/* 🔴 تصميم النافذة المنبثقة (Lightbox) */
.bv2-lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.92);
  z-index: 999999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.bv2-lightbox-close {
  position: absolute;
  top: 20px;
  right: 30px;
  color: white;
  font-size: 45px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
  transition: color 0.3s;
  z-index: 2;
}
.bv2-lightbox-close:hover {
  color: #861e38;
}
.bv2-lightbox-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  width: 100%;
  max-height: calc(100vh - 120px);
}
.bv2-lightbox-content img {
  max-width: 90%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 5px 25px rgba(0, 0, 0, 0.5);
}
.bv2-lightbox-thumbs {
  height: 100px;
  display: flex;
  gap: 15px;
  padding: 15px;
  overflow-x: auto;
  width: 100%;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
}
@media (max-width: 992px) {
  .bv2-lightbox-thumbs {
    justify-content: flex-start;
  }
}
.bv2-lightbox-thumbs img {
  width: 70px;
  height: 70px;
  object-fit: cover;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 4px;
  opacity: 0.5;
  transition: all 0.3s;
}
.bv2-lightbox-thumbs img:hover,
.bv2-lightbox-thumbs img.active {
  opacity: 1;
  border-color: #861e38;
}

/* ضمان بقاء قسم الوصف (Description) في الأسفل بعيداً عن الكونفيجراتور */
.post-4507 .woocommerce-tabs {
  clear: both !important;
  width: 100% !important;
  margin-top: 50px !important;
}

/* ==========================================================================
   2. Basis-Layout (Split-Screen)
   ========================================================================== */
.bv2-split-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 30px;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto 40px auto;
  box-sizing: border-box;
  align-items: flex-start;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
}

/* Linke Seite: Vorschau */
.bv2-preview-column {
  flex: 1 1 45%;
  max-width: 60%; /* منع التمدد الزائد */
  min-width: 320px;
  position: -webkit-sticky;
  position: sticky;
  top: 192px; /* Bleibt beim Scrollen im Bild */
  z-index: 10;
}

/* Rechte Seite: Formular */
.bv2-form-column {
  flex: 1 1 50%;
  max-width: 40%; /* منع التمدد الزائد */
  min-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* 🔴 تصميم زر وضع الشاشة الكاملة (للموبايل فقط) */
.bv2-fullscreen-btn {
  display: none; /* مخفي افتراضياً */
  width: 100%;
  background: #3a3a3a; /* لون رمادي داكن كما في الصورة */
  color: #fff;
  border: none;
  padding: 10px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  text-align: center;
  border-radius: 0 0 6px 6px;
}
.bv2-fullscreen-btn:hover {
  background: #222;
}

/* Responsive: Auf Handys untereinander */
@media (max-width: 992px) {
  .bv2-split-layout {
    flex-direction: column;
  }

  /* الوضع العادي للموبايل في الأعلى */
  .bv2-preview-column {
    flex: 1 1 100%;
    max-width: 100%;
    position: relative;
    top: 0;
    margin-bottom: 20px;
    z-index: 90;
  }
  .bv2-form-column {
    flex: 1 1 100%;
    max-width: 100%;
  }
  .bv2-canvas-container {
    height: auto;
    aspect-ratio: 4 / 3;
    min-height: 250px;
    touch-action: none; /* 🔴 ضروري جداً لدعم اللمس وسحب الشاشة 2D/3D */
  }

  /* 🔴 وضع الصورة المصغرة العائمة (PiP Mode) أسفل اليسار */
  .bv2-preview-sticky-wrapper.bv2-is-pip {
    position: fixed !important;
    top: auto !important;
    bottom: 20px !important;
    left: 15px !important;
    width: 160px !important;
    height: auto !important;
    margin: 0 !important;
    z-index: 999999 !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    background: #fff;
    border: 2px solid #861e38;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* لمنع ظهور أي زوائد */
  }

  /* 🔴 وضع الشاشة الكاملة (Fullscreen Mode) - Force Override */
  .bv2-preview-sticky-wrapper.bv2-is-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    min-width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    min-height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    z-index: 999999999 !important; /* طبقة عليا مطلقة */
    background: #f8f8f8 !important;
    border: none !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    /* 🔴 السر لكسر أي حاوية مخفية في ووكومرس أو قالب Astra */
    transform: translateZ(0) !important;
  }

  /* تحديد طول ثابت للكانفاس في وضع المربع الصغير */
  .bv2-preview-sticky-wrapper.bv2-is-pip .bv2-canvas-container {
    height: 180px !important;
    flex: none !important;
    min-height: unset;
  }

  /* مساحة الكانفاس تتمدد لتأخذ كامل الشاشة في وضع الفول سكرين */
  .bv2-preview-sticky-wrapper.bv2-is-fullscreen .bv2-canvas-container {
    flex: 1 !important;
    height: auto !important;
    min-height: unset;
  }

  /* إظهار الزر وتعديل تصميمه في الشاشة الكاملة */
  .bv2-preview-sticky-wrapper.bv2-is-pip .bv2-fullscreen-btn,
  .bv2-preview-sticky-wrapper.bv2-is-fullscreen .bv2-fullscreen-btn {
    display: block !important;
    flex: 0 0 auto;
  }
  .bv2-preview-sticky-wrapper.bv2-is-fullscreen .bv2-fullscreen-btn {
    background: #861e38;
    padding: 15px;
    font-size: 16px;
    border-radius: 0;
  }

  /* 🔴 إخفاء الأزرار والتعليمات والصور في وضع PiP المربع الصغير */
  .bv2-preview-sticky-wrapper.bv2-is-pip .bv2-preview-header,
  .bv2-preview-sticky-wrapper.bv2-is-pip .bv2-preview-instructions,
  .bv2-preview-sticky-wrapper.bv2-is-pip .bv2-custom-gallery-container,
  .bv2-preview-sticky-wrapper.bv2-is-fullscreen .bv2-custom-gallery-container {
    display: none !important;
  }

  /* 🔴 إظهار الأزرار والتعليمات في وضع الشاشة الكاملة فقط */
  .bv2-preview-sticky-wrapper.bv2-is-fullscreen .bv2-preview-header {
    display: flex !important;
    position: relative;
    background: #f8f8f8;
    width: 100%;
    box-sizing: border-box;
  }
  .bv2-preview-sticky-wrapper.bv2-is-fullscreen .bv2-preview-instructions {
    display: block !important;
    width: 100%;
    box-sizing: border-box;
  }
}
/* 1. افتراضياً: إخفاء تعليمات الموبايل وإظهار تعليمات الـ Desktop */
.bv2-instruction-mobile {
  display: none !important;
}

.bv2-instruction-desktop {
  display: block !important;
}

/* 2. عند الموبايل (أقل من 992px): نعكس العملية */
@media (max-width: 992px) {
  .bv2-instruction-desktop {
    display: none !important;
  }
  .bv2-instruction-mobile {
    display: block !important;
  }
}
/* ==========================================================================
   3. Sticky Preis-Banner
   ========================================================================== */
.bv2-sticky-price-banner {
  position: -webkit-sticky;
  position: sticky;
  top: 192px;
  background: #f7f7f7;
  border: 1px solid #861e38;
  border-radius: 8px;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  z-index: 9;
  margin-bottom: 10px;
  transition: all 0.3s ease;
}
/* عند التفعيل في الموبايل */
@media (max-width: 992px) {
  .bv2-sticky-price-banner.is-stuck {
    position: fixed !important; /* فرض التثبيت */
    left: 0 !important;
    width: 100% !important;
    border: 0 !important;
    border-radius: 0 !important;
    z-index: 89 !important; /* أعلى من أي شيء آخر */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
    padding: 3px 15px !important;
    transition: all 0.3s ease;
  }

  /* 🔴 كلاس الإخفاء الناعم (Fade Out) عندما يظهر السعر السفلي */
  .bv2-sticky-price-banner.banner-fade-out {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
}

.bv2-banner-title {
  font-size: 1.1em;
  font-weight: 600;
  color: #333;
}

.bv2-banner-right {
  text-align: right;
}

.bv2-price-gross {
  font-size: 1.8em;
  font-weight: 700;
  color: #861e38;
  line-height: 1;
}

.bv2-price-net-tax {
  font-size: 0.85em;
  color: #666;
  margin-top: 4px;
}

/* ==========================================================================
   4. Karten / Sektionen (Step Cards)
   ========================================================================== */
.bv2-step-card {
  background-color: #ffffff;
  border: 1px solid #861e38;
  border-radius: 8px;
  overflow: hidden;
}

.bv2-step-header {
  background-color: #ffffff;
  padding: 15px 20px;
  font-size: 1.1em;
  font-weight: 700;
  color: #861e38;
  border-bottom: 1px dashed #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bv2-step-content {
  padding: 20px;
}

.bv2-main-title {
  font-size: 2em;
  color: #333;
  margin: 0;
}

.bv2-subtitle {
  color: #666;
  margin: 5px 0 20px 0;
}

/* ==========================================================================
   5. Formular-Elemente (Radio Buttons)
   ========================================================================== */
.bv2-input-label {
  display: block;
  font-weight: 600;
  color: #444;
  margin-bottom: 10px;
}

.bv2-mt-15 {
  margin-top: 15px;
}

/* Radio-Tabs Grid */
.bv2-radio-group-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.bv2-radio-tab {
  display: block;
  position: relative;
  cursor: pointer;
  margin: 0;
}

.bv2-radio-tab input[type="radio"] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.bv2-radio-tab span {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 15px 10px;
  background-color: #fff;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-weight: 600;
  color: #555;
  text-align: center;
  transition: all 0.2s ease;
  height: 100%;
}

.bv2-radio-tab:hover span {
  border-color: #aaa;
}

.bv2-radio-tab input[type="radio"]:checked ~ span {
  border-color: #861e38;
  background-color: #fdf5f7;
  color: #861e38;
  box-shadow: 0 2px 8px rgba(134, 30, 56, 0.1);
}

/* Text Inputs */
.bv2-text-input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1em;
  transition: border-color 0.2s;
}

.bv2-text-input:focus {
  border-color: #861e38;
  outline: none;
}

/* ==========================================================================
   6. Farbauswahl (Color Grid)
   ========================================================================== */
.bv2-color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid #eee;
  border-radius: 6px;
  background: #fafafa;
}

.bv2-color-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 5px;
  transition: all 0.2s;
  background: #fff;
}

.bv2-color-swatch {
  width: 100%;
  height: 35px;
  border-radius: 4px;
  border: 1px solid #ddd;
  margin-bottom: 5px;
  position: relative;
}

.bv2-color-name {
  font-size: 10px;
  text-align: center;
  color: #444;
  line-height: 1.1;
}

.bv2-color-option:hover {
  border-color: #ccc;
}

.bv2-color-option.selected {
  border-color: #861e38;
  background-color: #fdf5f7;
}

.bv2-color-option.selected .bv2-color-swatch::after {
  content: "✔";
  color: white;
  font-size: 16px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

/* ==========================================================================
   7. Toggle Switches
   ========================================================================== */
.bv2-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #eee;
}

.bv2-toggle-row:last-child {
  border-bottom: none;
}

.bv2-toggle-info {
  display: flex;
  flex-direction: column;
}

.bv2-toggle-title {
  font-weight: 600;
  color: #333;
}

.bv2-toggle-desc {
  font-size: 0.85em;
  color: #777;
}

.bv2-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
}

.bv2-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.bv2-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.4s;
  border-radius: 26px;
}

.bv2-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}

.bv2-switch input:checked + .bv2-slider {
  background-color: #861e38;
}

.bv2-switch input:checked + .bv2-slider:before {
  transform: translateX(24px);
}

/* ==========================================================================
   8. Upload Bereich
   ========================================================================== */
.bv2-upload-dropzone {
  border: 2px dashed #ccc;
  border-radius: 8px;
  padding: 30px;
  text-align: center;
  background-color: #fafafa;
  cursor: pointer;
  transition: all 0.2s;
}

.bv2-upload-dropzone:hover {
  border-color: #861e38;
  background-color: #fdf5f7;
}

.bv2-upload-icon {
  font-size: 2.5em;
  margin-bottom: 10px;
}

/* ==========================================================================
   9. Buttons & Zusammenfassung
   ========================================================================== */
.bv2-primary-btn {
  width: 100%;
  background-color: #861e38 !important;
  color: #fff !important;
  padding: 15px;
  font-size: 1.2em;
  font-weight: bold;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.bv2-primary-btn:hover {
  background-color: #6a172c !important;
}

.bv2-summary-card {
  background-color: #ffffff;
  border: 1px solid #861e38;
  border-radius: 8px;
  padding: 20px;
}

.bv2-summary-header {
  font-size: 1.2em;
  font-weight: bold;
  color: #333;
  border-bottom: 2px solid #861e38;
  padding-bottom: 10px;
  margin-bottom: 15px;
}

.bv2-final-price-area {
  margin: 20px 0;
  text-align: right;
}

.bv2-final-price-row {
  font-size: 1.4em;
  font-weight: bold;
  color: #333;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bv2-final-value {
  color: #861e38;
  font-size: 1.5em;
}

.bv2-cart-notice {
  text-align: center;
  font-size: 0.85em;
  color: #666;
  margin-top: 10px;
}

/* ==========================================================================
   10. Vorschau Bereich (Canvas)
   ========================================================================== */
.bv2-preview-sticky-wrapper {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

/* 🔴 إخفاء خلفية الهيدر وجعله يطفو فوق المعاينة بشفافية */
.bv2-preview-header {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  background: transparent; /* إزالة الخلفية الرمادية */
  border-bottom: none; /* إزالة الخط السفلي */
  z-index: 20; /* لضمان بقاء الأزرار فوق الكانفاس 2D و 3D */
  pointer-events: none; /* يسمح للماوس باختراق المساحة الفارغة لتحريك الغرفة */
}

/* 🔴 تفعيل النقر للأزرار والشارة فقط (حتى تعمل الأزرار ولا يتم تعطيلها) */
.bv2-preview-header > * {
  pointer-events: auto;
}

.bv2-live-badge {
  background: #861e38;
  color: white;
  font-size: 0.75em;
  font-weight: bold;
  padding: 4px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.bv2-view-btn {
  background: #333;
  border: 1px solid #ccc;
  padding: 5px 12px;
  font-size: 0.85em;
  cursor: pointer;
  border-radius: 4px;
}

.bv2-view-btn.active {
  background: #861e38;
  color: #fff;
  border-color: #333;
}

.bv2-canvas-container {
  width: 100%;
  height: 400px;
  background: #f0f0f0;
  position: relative;
  overflow: hidden; /* يمنع خروج العناصر 3D عن الإطار */
}

/* 🔴 تصميم شريط التعليمات */
.bv2-preview-instructions {
  background-color: #861e38;
  border: 1px solid #333;
  border-top: none;
  padding: 5px;
  text-align: center;
  font-size: 0.9em;
  font-weight: 600;
  color: #ffffff;
}
