/* ============================================================
   1. تنسيقات الهيدر والشعار (Header & Logo)
   ============================================================ */
.header {
  padding: 5px 15px;
  /* مسافات ضيقة للموبايل */
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
  gap: 5px;
}

.logo span {
  font-size: 0.8rem;
}

.logo-img {
  height: 35px;
  width: auto;
  display: block;
  transform: scale(1.1);
  transform-origin: center;
}

.toolbar-section {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
  justify-content: space-around;
  align-items: center;
}

/* ============================================================
   2. حاوية التصميم (Main Layout Containers)
   ============================================================ */
.main-container {
  position: fixed;
  top: 55px;
  left: 0;
  width: 100%;
  margin: 0;
  padding: 10px;
  padding-top: 60px;
  height: calc(100vh - 150px);
  align-items: flex-start;
  display: flex;
  justify-content: center;
  overflow: hidden;
  z-index: 100;
}

.design-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}



.editor-container {
  position: fixed;
  top: 38%;
  left: 0;
  width: 100%;
  height: 65%;
  margin: 0;
  transform: translateY(-60%);
  background: transparent;
  border: none;
  z-index: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding-bottom: 0px;
  padding-top: 0px;
  box-shadow: none;
}

/* ============================================================
   3. منطقة العمل والصورة (Workspace & Image)
   ============================================================ */
.product-image {
  display: block;
  margin: auto;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  /* تحسينات الأداء */
  -webkit-user-drag: none;
  user-drag: none;
  user-select: none;
  pointer-events: none;
  filter: none;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.canvas-container,
canvas {
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ============================================================
   4. شريط الأدوات العائم (Floating Toolbar)
   ============================================================ */
.floating-toolbar {
  position: fixed;
  left: 0;
  bottom: 0px;
  top: auto;
  width: 100%;
  height: 70px;
  background: var(--bg-panel);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  align-items: center;
  padding: 0;
  padding-bottom: env(safe-area-inset-bottom, 5px);
  z-index: 9999;
  transform: none;
}

.toolbar-divider {
  display: none;
}

/* ============================================================
   تنسيق الشريط العائم (أزرار أكثر وضوحاً)
   ============================================================ */


/* ============================================================
   5. شريط التعديل السفلي (The Dock)
   ============================================================ */
.text-edit-toolbar {
  position: fixed;
  width: 100%;
  max-width: none;
  bottom: 0;
  left: 0;
  border-radius: 20px 20px 0 0;
  background: transparent;
  box-shadow: none;
  border: none;
  transform: translateY(110%);
  transition: transform 0.3s cubic-bezier(0.19, 1, 0.22, 1);
  z-index: 10000;
}

.text-edit-toolbar.active {
  transform: translateY(0);
}

/* ============================================================
   تنسيق شريط الأدوات السفلي (Dock)
   ============================================================ */


/* ============================================================
   تنسيق أزرار الهيدر في الموبايل (Header Buttons Fix)
   (الدارك مود + التصفير)
   ============================================================ */
/* ============================================================
   📱 MOBILE BUTTONS & DOCK (مقاسات الموبايل فقط)
   ============================================================ */

/* 1. أزرار شريط الأدوات العائم */
.floating-toolbar .tool-btn {
  flex: 1;
  height: 50px;
  margin: 0 4px;
  border-radius: 12px;
  flex-direction: column;
  /* الأيقونة فوق النص */
}

.floating-toolbar .tool-btn i {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.floating-toolbar .btn-label {
  font-size: 0.7rem;
}

/* 2. أزرار الهيدر (صغيرة مربعة) */
.header-actions .tool-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 0;
  margin: 0;
  flex-direction: row;
  /* الأيقونة في الوسط */
}

.header-actions .tool-btn i {
  font-size: 1.2rem;
  margin: 0;
}

/* 3. شريط الدوك السفلي */
.dock-navigation {
  flex-direction: row;
  /* أفقي */
  padding: 10px 15px;
  padding-bottom: env(safe-area-inset-bottom, 15px);
  min-height: 75px;
  border-radius: 25px 25px 0 0;
  /* دوران من فوق بس */
  border-bottom: none;
  gap: 5px;
}

.dock-btn {
  flex: 1;
  flex-direction: column;
  padding: 6px 4px;
  border-radius: 12px;
}

.dock-btn span {
  font-size: 0.65rem;
}

.dock-btn i {
  font-size: 1.3rem;
}

/* الفاصل الرأسي */
.dock-navigation>div[style] {
  width: 1px;
  height: 25px;
  background: var(--border-color);
  margin: 0 5px;
}

.dock-btn.close {
  width: 45px;
  height: 45px;
  flex: 0 0 45px;
  margin-right: 5px;
}

.dock-btn.close i {
  font-size: 1.6rem;
}

/* زر السلة (Add to Cart) نتركه مميزاً كما هو */
.header-actions .btn-primary {
  height: 36px;
  padding: 0 15px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  font-size: 0.8rem;
}

/* ============================================================
   6. القوائم الجانبية السفلية (Sidebars as Bottom Sheets)
   ============================================================ */
/* ============================================================
   📱 MOBILE PANELS (Bottom Sheets)
   ============================================================ */

/* 1. القوائم تظهر من الأسفل */
.sidebar-panel,
.toolbar-group {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  top: auto;
  /* تأكيد إلغاء الـ Top */
  width: 100%;
  height: auto;
  max-height: 60vh;
  border-radius: 25px 25px 0 0;
  /* تدوير من فوق بس */

  /* الحالة المخفية: تحت الشاشة */
  transform: translateY(110%);
  opacity: 1;
}

/* الحالة النشطة: تطلع لفوق */
.sidebar-panel.active,
.toolbar-group.active-tab {
  transform: translateY(0);
}

/* 2. مجموعة الألوان (فوق الزر العائم) */
.color-switcher-group {
  position: fixed;
  bottom: 161px;
  right: 15px;
  flex-direction: column-reverse;
  /* عكس الترتيب */
  border-radius: 50px;
  padding: 6px;
  gap: 8px;
}

.color-btn {
  width: 30px;
  height: 30px;
  margin: 2px;
}

/* 3. معرض الصور (View Gallery) */
.view-gallery {
  position: fixed;
  bottom: 161px;
  left: 44px;
  /* مكان محدد */
  transform: translateX(-50%);
  flex-direction: column;
  border-radius: 50px;
  gap: 8px;
  padding: 6px;
}

.view-thumb {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  /* دائري في الموبايل */
}

/* إخفاء الليبل في الموبايل */
.thumb-label {
  display: none;
}

/* ============================================================
   7. أدوات التحكم (يمين الشاشة)
   ============================================================ */

/* ============================================================
   🚫 إلغاء حاوية اليمين في الموبايل (Ghost Container)
   عشان العناصر اللي جواها تتحرك بحرية بدون خلفية
   ============================================================ */
.right-sidebar-controls {
  /* إلغاء التموضع: عشان متكونش كتلة فوق التيشرت */
  position: static;
  transform: none;

  /* إخفاء الشكل: لا لون ولا حدود ولا ظل */
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  margin: 0;

  /* مهم جداً: جعل الحاوية "شبح" لا تعترض اللمس */
  pointer-events: none;

  /* إلغاء الحجم */
  width: auto;
  height: auto;
  display: block;
}

/* 🔥 إعادة تفعيل اللمس للأزرار اللي جواها 🔥 */
/* لأننا عملنا pointer-events: none للأب، لازم نرجعه للأبناء */
.right-sidebar-controls>* {
  pointer-events: auto;
}



/* ============================================================
   8. الأزرار العائمة (Save, Flip, Exit)
   ============================================================ */
/* ============================================================
   📱 MOBILE SAVE BUTTON (عائم - كبسولة)
   ============================================================ */
#saveBtn {
  position: fixed;
  bottom: 85px;
  left: 3px;
  right: auto;
  top: auto;
  z-index: 1000;

  /* الشكل: كبسولة كبيرة للمس */
  width: auto;
  padding: 14px 24px;
  border-radius: 50px;

  /* ظل عشان يفصل عن الخلفية */
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

#saveBtn span {
  font-size: 0.9rem;
}

#saveBtn i {
  margin: 0;
  font-size: 1.2rem;
}

#exit-store-btn {
  position: absolute;
  top: 53px;
  right: 15px;
  padding: 10px;
  border-radius: 50%;
  z-index: 1000;
  background: #fff;
  border: 1px solid #ddd;
}

#exit-store-btn span {
  display: none;
}

.flip-toggle-btn {
  position: absolute;
  top: -12px;
  right: 8px;
  width: 35px;
  height: 35px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: flex;
  align-items: center;
}

.flip-toggle-btn span {
  display: none;
}

/* ============================================================
   9. 3D Flip Scene
   ============================================================ */
.flip-scene {
  width: 100% !important;
  height: calc(100vh - 160px) !important;
  margin: 0 !important; 
  padding: 0 !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  overflow: visible !important; 
}



.flip-card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* .card-face.active-face {
  height: calc(100vh - 64px - 90px);
} */

.card-face.active-face {
  height: 100% !important; /* خليها نفس ارتفاع الكارت الأصلي */
  width: 100% !important;
}

.flip-card.is-flipped {
  transform: rotateY(180deg);
}

.card-back {
  transform: rotateY(180deg);
}

/* ============================================================
   10. Joystick & Patterns & Extras
   ============================================================ */
.pattern-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}



.pattern-item img {
  width: 100%;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: 0.2s;
}

.pattern-item img:hover {
  border-color: var(--primary-color);
  transform: scale(1.05);
}



/* الطباعة والتحميل */
.printable-wrapper {
  position: absolute;
  z-index: 10;
}

.saving-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  z-index: 2000000000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
}

.saving-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* أزرار الإغلاق الدائرية */
#closeTextEditorBtn,
#closeImageEditorBtn,
#closePatternEditorBtn {
  width: 45px;
  height: 45px;
  flex: 0 0 45px;
  border-radius: 50%;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-color);
  color: white;
}

@media (max-width: 400px) {

  /* 1. تصغير الهيدر */
  .header {
    padding: 5px 10px;
  }

  .header-container {
    gap: 5px;
  }

  .logo {
    font-size: 1rem;
  }

  .logo span {
    display: none;
  }

  /* إخفاء اسم الموقع فقط */

  /* 2. ضبط الحاوية */
  .main-container {
    top: 50px;
    padding: 5px;
  }

  /* 3. شريط الأدوات السفلي */
  .floating-toolbar {
    height: 60px;
  }

  .floating-toolbar .tool-btn i {
    font-size: 1.1rem;
  }

  .floating-toolbar .btn-label {
    font-size: 8px;
  }

  .pattern-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  /* 4. تعديل الأزرار العائمة */

  /* زر القلب (Flip) */
  .flip-toggle-btn {
    top: 46px;
    right: 5px;
    padding: 4px 8px;
    font-size: 0.7rem;
  }

  /* زر الحفظ (الإصلاح هنا: إظهار النص) 🔥 */
  #saveBtn {
    bottom: 80px;
    /* تعديل بسيط للمكان */
    left: 10px;
    width: auto;
    /* العرض يتمدد حسب النص */
    min-width: auto;
    height: 40px;
    /* ارتفاع أقل شوية للموبايل الصغير */
    padding: 0 20px;
    /* حواف جانبية للنص */
    border-radius: 50px;
    /* شكل كبسولة */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
  }

  #saveBtn span {
    display: block;
    /* إجبار النص على الظهور */
    font-size: 0.8rem;
    /* تصغير الخط عشان المساحة */
    white-space: nowrap;
    /* منع نزول النص سطر جديد */
    line-height: 1;
  }

  #saveBtn i {
    font-size: 1rem;
    /* تصغير الأيقونة لتعادل النص */
    margin: 0;
  }

  .editor-container {
    /* width: auto  ; */
    /* max-width: 95%  ; */
    margin: 0 auto;

    /* أخذنا أحدث قيمة للرفع لفوق (-189px) */
    /* margin-top: 54px; */
    /* transform: scale(0.95)  ;  */

    background: transparent;
    box-shadow: none;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .color-switcher-group {
    position: fixed;
    bottom: 161px;
    /* فوق الأزرار العائمة */
    right: 15px;
    top: auto;
    flex-direction: column-reverse;
    gap: 8px;
    background: var(--bg-panel);
    padding: 6px;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    z-index: 995;
    /* display: block; */
  }

  .color-btn {
    width: 30px;
    height: 30px;
    margin: 5px;
  }

  /* معرض الصور */
  .view-gallery {
    position: fixed;
    bottom: 161px;
    /* left: 50%  ; */
    left: 44px;
    transform: translateX(-50%);
    flex-direction: row;
    gap: 12px;
    backdrop-filter: blur(5px);
    padding: 6px;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 990;
    display: flex;
    flex-direction: column;
  }

  .view-thumb {
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }

  .floating-note-btn {
    bottom: 80px;
    right: 15px;
    height: 40px;
    padding: 5px 12px;
    border-radius: 50px;
  }
}

/* ============================================================
   11. النواقص (Sliders, Color Pickers, Compact Inputs)
   [تمت إضافته من الكود القديم]
   ============================================================ */


/* خلفية إعدادات التأثيرات */
.effect-config {
  background: #f8fafc;
  border-radius: 12px;
  padding: 15px;
  border: 1px solid #e2e8f0;
  margin-top: 10px;
  animation: fadeIn 0.3s ease;
}






.full-span {
  grid-column: span 2;
}






.floating-note-btn {
  position: fixed;
  z-index: 999;
  bottom: 80px;
  right: 3px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 18px;
  min-width: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  width: auto;
  height: 50px;
  transform: none;
}

.floating-note-btn .icon-wrapper {
  width: 32px;
  height: 32px;
  background: #eff6ff;
  color: #2563eb;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  transition: background 0.3s ease;
}

.floating-note-btn .btn-text {
  font-family: "Cairo", sans-serif;
  font-weight: 700;
  color: #475569;
  font-size: 14px;
  display: block;
  letter-spacing: 0.5px;
}

.note-indicator {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 12px;
  height: 12px;
  background: #10b981;
  border: 2px solid #fff;
  border-radius: 50%;
  display: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.floating-note-btn:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(37, 99, 235, 0.15);
  border-color: #2563eb;
}

.floating-note-btn:hover .icon-wrapper {
  background: #2563eb;
  color: #ffffff;
}

.floating-note-btn.has-note {
  border-color: #10b981;
  background: #f0fdf4;
}

.floating-note-btn.has-note .icon-wrapper {
  background: #10b981;
  color: white;
}

.floating-note-btn.has-note .btn-text {
  color: #047857;
}

.floating-note-btn.has-note .note-indicator {
  display: block;
}

.note-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 10000000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: 0.3s;
}

.note-overlay.active {
  opacity: 1;
  visibility: visible;
}

.note-bubble {
  background: #fff;
  width: 90%;
  max-width: 400px;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  transform: scale(0.9);
  transition: 0.3s;
}

.note-overlay.active .note-bubble {
  transform: scale(1);
}

.note-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 15px;
}

.note-body textarea {
  width: 100%;
  height: 100px;
  padding: 10px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  resize: none;
}

.save-note-btn {
  width: 100%;
  padding: 12px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 15px;
  display: flex;
  justify-content: center;
  gap: 5px;
}

.close-bubble {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
}


/* ============================================================
   📱 MOBILE JOYSTICK (القابلية للطي)
   ============================================================ */

.floating-joystick {
  padding-bottom: 18px;
}



/* 1. حالة الانكماش (لما يكون مقفول) */
.floating-joystick.collapsed-mobile .d-pad-wrapper {
  max-height: 0;
  opacity: 0;
}

.floating-joystick.collapsed-mobile .joystick-actions {
  border-bottom: none;
  border-radius: 0 0 12px 12px;
}

/* 2. زر التوسيع (السهم الصغير تحت) */
.mobile-expand-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 20px;

  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 4px rgba(0, 0, 0, 0.05);

  color: var(--text-light);
  font-size: 1.2rem;
  z-index: 10;
  transition: 0.3s;
}

/* قلب السهم لما يفتح */
.floating-joystick:not(.collapsed-mobile) .mobile-expand-btn i {
  transform: rotate(180deg);
}

/* //////////////////////// */

.ai-processing-options {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--border-color);
}

.section-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 10px;
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 8px;
  border-radius: 8px;
  transition: 0.2s;
}

.ai-checkbox:hover {
  background: #f1f5f9;
}

.ai-checkbox input {
  cursor: pointer;
  width: 18px;
  height: 18px;
  accent-color: var(--primary-color);
}

/* ============================================================
   🔴 تنسيقات لوحة الطبقات (Layers Panel)
   اضف هذا الكود في css_global.css
   ============================================================ */



/* /////////////////////////// */


/* ============================================================
   🎨 تنسيقات المحتوى الداخلي للقوائم (Tools Internal Styling)
   ضع هذا الكود في css_global.css
   ============================================================ */

/* 1. رأس القائمة الفرعية (العنوان + زر الإغلاق) */
.sub-tool-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f1f5f9;
}

.sub-tool-title {
  font-weight: 700;
  color: #1e293b;
  font-size: 0.95rem;
}

.sub-tool-close {
  background: var(--primary-color);
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
  transition: transform 0.2s;
}

.sub-tool-close:hover {
  transform: scale(1.1);
}




