/* 1️⃣ تعريف المتغيرات (Variables Definition) */
:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --bg-main: #f3f4f6;
  --bg-panel: #ffffff;
  --bg-input: #f8fafc;
  --text-main: #1f2937;
  --text-light: #64748b;
  --border-color: #e2e8f0;
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --radius: 6px;
  --water-mark: rgba(0, 0, 0, 0.02);
}

body.dark-theme {
  --bg-main: #0f172a;
  --bg-panel: #1e293b;
  --bg-input: #334155;
  --text-main: #f1f5f9;
  --text-light: #94a3b8;
  --border-color: #334155;
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* ============================================================
   🌍 UNIVERSAL BROWSER FIX (إصلاح شامل لكل المتصفحات)
   ضع هذا الكود في بداية ملف CSS تماماً
   ============================================================ */
*,
*::before,
*::after {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

.bx,
.fa,
.fas,
.far,
.fab,
i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-style: normal;
  line-height: 1;
  text-rendering: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@supports not (gap: 10px) {

  .header-actions>*,
  .toolbar-section>*,
  .dock-navigation>*,
  .compact-inputs>* {
    margin-left: 10px;
  }

  .header-actions>*:first-child,
  .toolbar-section>*:first-child,
  .dock-navigation>*:first-child,
  .compact-inputs>*:first-child {
    margin-left: 0;
  }
}

button,
.tool-btn,
.dock-btn {
  cursor: pointer;
  border: none;
  outline: none;
  font-family: inherit;
}

/* ============================================================
   🚫 إخفاء شريط السكرول نهائياً (Hidden Scrollbar Fix)
   يحل مشكلة الشريط القبيح على اليسار ويمنع اهتزاز التصميم
   ============================================================ */
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  /* لإخفاء السكرول بار */
  scrollbar-gutter: auto;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
}

/* ============================================================
   🚫 إلغاء الهالة الزرقاء عند اللمس (No Tap Highlight)
   ============================================================ */
* {
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

*:focus {
  outline: none;
}

/* 2️⃣ تطبيق المتغيرات على العناصر (General Usage) */
/* هذا الجزء يضمن تغير الألوان تلقائياً عند تفعيل الوضع الليلي */
.header,
.sidebar-panel,
.floating-toolbar,
/* .text-edit-toolbar, */
.dock-navigation,
/* .editor-container, */
.pattern-actions-header,
.right-sidebar-controls,
.color-switcher-group,
.view-gallery {
  background-color: var(--bg-panel) !important;
  border-color: var(--border-color) !important;
  color: var(--text-main) !important;
  transition:
    background-color 0.3s ease,
    border-color 0.3s ease,
    color 0.3s ease;
}

input[type="text"],
input[type="number"],
textarea,
select,
.toolbar-select,
.custom-select-trigger,
.btn-secondary,
.tool-btn,
.pattern-item,
.action-btn,
.view-thumb {
  background-color: var(--bg-input);
  color: var(--text-main);
  border-color: var(--border-color);
}

.view-thumb.active {
  border-color: var(--primary-color);
}

.custom-select-options,
.toolbar-group {
  background-color: var(--bg-panel);
  border-color: var(--border-color);
}

/* نصوص وعناوين */
h3,
label,
.sub-tool-title,
.custom-select-option {
  color: var(--text-main);
}

.upload-area i,
.upload-area p,
.dock-btn {
  color: var(--text-light);
}



.custom-select-option:hover,
.upload-area:hover {
  background-color: var(--border-color);
}

::-webkit-scrollbar {
  width: 0px;
  height: 0px;
  background: transparent;
}

* {
  scrollbar-width: none;
}

/* /////////////////////// */

/* =========================================
   2. الهيدر (Header)
   ========================================== */
.header {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.btn-primary,
.btn-secondary {
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: white;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: #f9fafb;
}

.full-width {
  width: 100%;
  justify-content: center;
  margin-top: 10px;
}





/* === Custom Select Dropdown Styles === */
/*.custom-select-hidden {*/
/*  display: none;*/
/*}*/

/*.custom-select-wrapper {*/
/*  position: relative;*/
/*  user-select: none;*/
/*  width: 100%;*/
/*}*/

/*.custom-select-trigger {*/
/*  position: relative;*/
/*  display: flex;*/
/*  align-items: center;*/
/*  justify-content: space-between;*/
/*  padding: 10px 15px;*/
/*  font-size: 0.9rem;*/
/*  font-weight: 500;*/
/*  color: #333;*/
/*  background: #f8fafc;*/
/*  border: 1px solid #e2e8f0;*/
/*  border-radius: 12px;*/
/*  cursor: pointer;*/
/*  transition: all 0.3s ease;*/
/*}*/

/*.custom-select-trigger:hover {*/
/*  border-color: var(--primary-color);*/
/*  background: #fff;*/
/*}*/

/*.custom-select-arrow {*/
/*  position: relative;*/
/*  height: 10px;*/
/*  width: 10px;*/
/*}*/

/*.custom-select-arrow::after {*/
/*  content: "";*/
/*  border-bottom: 2px solid #999;*/
/*  border-right: 2px solid #999;*/
/*  width: 8px;*/
/*  height: 8px;*/
/*  display: block;*/
/*  transform: rotate(45deg);*/
/*  transition: all 0.3s ease;*/
/*}*/

/*.custom-select-options {*/
/*  position: absolute;*/
/*  display: block;*/
/*  top: 100%;*/
/*  left: 0;*/
/*  right: 0;*/
/*  border: 1px solid #e2e8f0;*/
/*  border-radius: 12px;*/
/*  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);*/
/*  background: #fff;*/
/*  transition: all 0.3s ease;*/
/*  opacity: 0;*/
/*  visibility: hidden;*/
/*  pointer-events: none;*/
/*  transform: translateY(10px);*/
/*  z-index: 999;*/
/*  max-height: 200px;*/
/*  overflow-y: auto;*/
/*  margin-top: 5px;*/
/*}*/

/*.custom-select-option {*/
/*  position: relative;*/
/*  display: block;*/
/*  padding: 10px 15px;*/
/*  font-size: 0.9rem;*/
/*  color: #333;*/
/*  cursor: pointer;*/
/*  transition: all 0.2s ease;*/
/*}*/

/*.custom-select-option:hover {*/
/*  background-color: #f1f5f9;*/
/*  color: var(--primary-color);*/
/*  padding-right: 20px;*/
/*}*/

/*.custom-select-option.selected {*/
/*  background-color: var(--primary-color);*/
/*  color: #fff;*/
/*}*/

/*.custom-select-wrapper.open .custom-select-options {*/
/*  opacity: 1;*/
/*  visibility: visible;*/
/*  pointer-events: all;*/
/*  transform: translateY(0);*/
/*}*/

/*.custom-select-wrapper.open .custom-select-trigger {*/
/*  border-color: var(--primary-color);*/
/*}*/

/*.custom-select-wrapper.open .custom-select-arrow::after {*/
/*  transform: rotate(225deg);*/
/*  margin-top: 5px;*/
/*}*/


/* ============================================================
   🎨 إصلاح القوائم المنسدلة (Dropdown Fix) - نسخة محدثة
   ============================================================ */

.custom-select-hidden {
  display: none;
}

/* 1. الحاوية الرئيسية */
.custom-select-wrapper {
  position: relative;
  user-select: none;
  width: 100%;
}

/* 2. الزر الظاهر (Trigger) */
.custom-select-trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 15px;
  font-size: 0.9rem;
  font-weight: 500;
  
  /* 🔥 تحديث: استخدام المتغيرات لدعم الدارك مود */
  color: var(--text-main);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.custom-select-trigger:hover {
  border-color: var(--primary-color);
}

/* السهم الصغير */
.custom-select-arrow {
  position: relative;
  height: 10px;
  width: 10px;
}

.custom-select-arrow::after {
  content: "";
  border-bottom: 2px solid var(--text-light); /* لون متغير */
  border-right: 2px solid var(--text-light);
  width: 8px;
  height: 8px;
  display: block;
  transform: rotate(45deg);
  transition: all 0.3s ease;
}

/* 3. 🔥🔥 القائمة المنسدلة (الجزء المهم) 🔥🔥 */
.custom-select-options {
  position: absolute;
  display: block;
  top: 110%; /* مسافة بسيطة تحت الزر */
  left: 0;
  right: 0;
  
  border: 1px solid var(--border-color);
  border-radius: 12px;
  /* ظل قوي عشان تبرز */
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); 
  
  /* 🔥 تحديث: استخدام خلفية البانل للدارك مود */
  background: var(--bg-panel);
  
  transition: all 0.2s ease-in-out;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-10px);
  
  /* 🔥🔥 إصلاح الاختفاء: رقم عالي جداً ليعلو فوق السايد بار 🔥🔥 */
  z-index: 99999; 
  
  max-height: 250px; /* طول مناسب */
  overflow-y: auto;
  overflow-x: hidden;
  margin-top: 5px;
}

/* عناصر القائمة */
.custom-select-option {
  position: relative;
  display: block;
  padding: 12px 15px;
  font-size: 0.9rem;
  
  /* لون النص متغير */
  color: var(--text-main);
  
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 1px solid var(--border-color); /* فاصل خفيف */
}

.custom-select-option:last-child {
  border-bottom: none;
}

.custom-select-option:hover {
  background-color: var(--bg-input); /* لون الهوفر */
  color: var(--primary-color);
  padding-right: 20px; /* حركة جمالية */
}

.custom-select-option.selected {
  background-color: var(--primary-color);
  color: #fff;
}

/* عند الفتح */
.custom-select-wrapper.open .custom-select-options {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
  transform: translateY(0);
}

.custom-select-wrapper.open .custom-select-trigger {
  border-color: var(--primary-color);
}

.custom-select-wrapper.open .custom-select-arrow::after {
  transform: rotate(225deg);
  margin-top: 5px;
  border-color: var(--primary-color);
}

/* 🎨 4. تجميل شريط التمرير (Scrollbar) داخل القائمة */
.custom-select-options::-webkit-scrollbar {
  width: 5px;
}
.custom-select-options::-webkit-scrollbar-track {
  background: transparent; 
}
.custom-select-options::-webkit-scrollbar-thumb {
  background: var(--border-color); 
  border-radius: 10px;
}
.custom-select-options::-webkit-scrollbar-thumb:hover {
  background: var(--text-light); 
}







.custom-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.custom-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.custom-modal-box {
  background: rgba(255, 255, 255, 0.85);
  padding: 25px;
  border-radius: 20px;
  width: 320px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.5);
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.custom-modal-overlay.active .custom-modal-box {
  transform: scale(1);
}

.modal-icon i {
  font-size: 3rem;
  color: #f59e0b;
  margin-bottom: 10px;
}

.custom-modal-box h3 {
  margin: 0 0 10px 0;
  color: #1f2937;
  font-size: 1.1rem;
}

.custom-modal-box p {
  margin: 0 0 20px 0;
  color: #6b7280;
  font-size: 0.9rem;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.modal-btn {
  flex: 1;
  padding: 10px;
  border-radius: 12px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  transition: 0.2s;
}

.modal-btn.cancel {
  background: #e5e7eb;
  color: #374151;
}

.modal-btn.cancel:hover {
  background: #d1d5db;
}

.modal-btn.confirm {
  background: #ef4444;
  color: white;
}

.modal-btn.confirm:hover {
  background: #dc2626;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  75% {
    transform: translateX(5px);
  }
}

.shake-animation {
  animation: shake 0.3s ease-in-out;
  background-color: #fee2e2;
}

#app-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #ffffff;
  z-index: 2147483647;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition:
    opacity 0.5s ease-out,
    visibility 0.5s ease-out;
}

.loader-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #e2e8f0;
  border-top: 5px solid #2563eb;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

#app-loader p {
  font-family: "Segoe UI", sans-serif;
  color: #64748b;
  font-size: 0.9rem;
  font-weight: 600;
}

.loader-hidden {
  opacity: 0;
  visibility: hidden;
}

.quality-warning {
  background: #fffbeb;
  color: #b45309;
  padding: 10px;
  border-radius: 8px;
  margin: 10px 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: bold;
  border: 1px solid #fcd34d;
  animation: fadeIn 0.3s ease-in-out;
}

.quality-warning i {
  font-size: 1.2rem;
}

.logo-img {
  height: 45px;
  width: auto;
  display: block;
  transform: scale(1.5);
  transform-origin: center;
  transition:
    filter 0.3s ease,
    transform 0.3s ease;
}

body.product-is-dark {
  --water-mark: rgb(255 255 255 / 1%);
  /* أبيض خفيف */
}

/* body.dark-theme .main-container,
body.dark-theme .design-container {
  background-color: var(--bg-main)  ;
} */

/* شاشة التحميل في الوضع الليلي */
body.dark-theme #app-loader {
  background-color: #111827;
}

body.dark-theme #app-loader p {
  color: #9ca3af;
}

/* العناصر الشفافة والمجسمة */
body.dark-theme .editor-container,
body.dark-theme .flip-card,
body.dark-theme .card-face {
  background-color: transparent !important;
  background: none;
  border: none;
  box-shadow: none;
  filter: none;
}

body.dark-theme .editor-container i,
body.dark-theme .editor-container span {
  color: #f3f4f6;
}

body.dark-theme .logo-img {
  filter: invert(1) brightness(100);
}

/* النوافذ المنبثقة (Modals) */
body.dark-theme .custom-modal-box {
  background: rgba(31, 41, 55, 0.85);
  border-color: rgba(255, 255, 255, 0.1);
}

body.dark-theme .custom-modal-box h3 {
  color: #f3f4f6;
}

body.dark-theme .modal-btn.cancel {
  background: #374151;
  color: #fff;
}

/* زر الملاحظات العائم (Floating Note) */
body.dark-theme .floating-note-btn {
  background-color: #374151;
  border-color: #4b5563;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
}

body.dark-theme .floating-note-btn .icon-wrapper {
  background-color: #1f2937;
  color: #60a5fa;
}

body.dark-theme .floating-note-btn .btn-text {
  color: #f3f4f6;
}

/* الملاحظات النشطة */
body.dark-theme .floating-note-btn.has-note {
  background-color: #064e3b;
  border-color: #059669;
}

body.dark-theme .floating-note-btn.has-note .icon-wrapper {
  background-color: #059669;
  color: #ffffff;
}

body.dark-theme .floating-note-btn.has-note .btn-text {
  color: #a7f3d0;
}

/* نافذة الملاحظات */
body.dark-theme .note-bubble {
  background-color: #1f2937;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

body.dark-theme .note-header span,
body.dark-theme .close-bubble:hover {
  color: #f3f4f6;
}

body.dark-theme .close-bubble {
  color: #9ca3af;
}

body.dark-theme .note-body textarea {
  background-color: #374151;
  color: #f3f4f6;
  border-color: #4b5563;
}

body.dark-theme .note-body textarea:focus {
  border-color: #60a5fa;
}

body.dark-theme .save-note-btn {
  background-color: #2563eb;
  color: #ffffff;
}

body.dark-theme .save-note-btn:hover {
  background-color: #1d4ed8;
}

@keyframes superRainbow {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.flip-card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center center;
  outline: 1px solid transparent;
  will-change: transform;
  
  /* 🔥🔥 السطر السحري لمنع النطة (Force GPU Layer) 🔥🔥 */
  /* ده بيخلي المتصفح ماسك الكارت ومجهز له 3D علطول */
  transform: translateZ(0); 
  
  /* منع الانضغاط */
  flex: 0 0 auto;
  min-width: 100%;
}

/* ============================================================
   🎨 GLOBAL BUTTONS & TOOLS STYLING (توحيد الأزرار)
   ============================================================ */

/* 1. التنسيق الأساسي لكل الأزرار (أدوات + دوك) */
.tool-btn,
.dock-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  color: var(--text-light);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  /* منع تحديد النص داخل الزر */
  user-select: none;
  -webkit-user-select: none;
}

/* 2. النصوص والأيقونات داخل الأزرار */
.tool-btn span,
.dock-btn span,
.btn-label {
  font-weight: 700;
  letter-spacing: 0.5px;
  display: block;
}

.tool-btn i,
.dock-btn i {
  transition: transform 0.2s ease;
}

/* 3. حالات التفاعل (Hover & Active) */
/* الهوفر (للكمبيوتر فقط) */
@media (hover: hover) {

  .tool-btn:hover,
  .dock-btn:hover {
    background-color: var(--primary-color);
    color: #ffffff;
    transform: translateY(-2px);
  }
}

/* التفعيل (Active State) */
.tool-btn.active,
.dock-btn.active {
  color: var(--primary-color);
  background-color: rgba(37, 99, 235, 0.1);
  /* خلفية شفافة */
  font-weight: bold;
}

.tool-btn.active i,
.dock-btn.active i {
  transform: scale(1.1);
}

/* 4. تنسيق خاص لزر الحذف (أحمر) */
.tool-btn.delete-tool:hover,
.joy-action-btn.delete:hover {
  background-color: #fee2e2;
  color: #ef4444;
}

.tool-btn.delete-tool {
  color: #ef4444;
}

/* 5. زر الإغلاق الدائري (Close Button) */
.dock-btn.close {
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  padding: 0;
}

.dock-btn.close span {
  display: none;
}

/* 6. الأساسيات المشتركة لحاوية الدوك (Dock) */
.dock-navigation {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  box-shadow: 0 5px 25px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1001;
}


/* ============================================================
   🛒 MAIN ACTION BUTTON (زر الحفظ والإضافة للسلة)
   ============================================================ */
#saveBtn {
  background-color: var(--primary-color);
  color: #ffffff;
  border: none;
  cursor: pointer;

  /* Layout الداخلي للزر */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  font-weight: 700;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  /* لمنع تحديد النص */
  user-select: none;
  -webkit-user-select: none;
}

#saveBtn span {
  display: block;
  line-height: 1;
}

/* تأثير الهوفر للكمبيوتر */
@media (hover: hover) {
  #saveBtn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  }
}

/* حالة التحميل (عند الضغط) */
#saveBtn:disabled {
  opacity: 0.7;
  cursor: wait;
  transform: none;
}

#saveBtn.premium-active {
  background: linear-gradient(
    270deg,
    #ff0000,
    #ff9900,
    #ffee00,
    #00ff15,
    #00aaff,
    #aa00ff,
    #ff0099
  ) !important;
  background-size: 600% 600% !important;
  animation: superRainbow 2s ease infinite !important;
  border: 2px solid white !important;
  box-shadow: 0 0 15px rgba(0, 200, 255, 0.7) !important;
  color: white !important;
  font-weight: 900 !important;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
  transform: scale(1.05);
}

/* ============================================================
   🎨 GLOBAL PANELS & CONTROLS (القوائم وأدوات التحكم)
   ============================================================ */

/* 1. القوائم الجانبية (الشكل العام) */
.sidebar-panel,
.toolbar-group {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  /* الظل المشترك */
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  z-index: 10000;

  /* الحركة الناعمة */
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.3s ease;

  /* إخفاء افتراضي */
  visibility: visible;
  padding: 10px;
}

/* 2. رأس القائمة (Header) */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding: 10px 15px;
  min-height: 45px;
}

.panel-header h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.panel-close {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.4rem;
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 3. محتوى القائمة */
.panel-content {
  padding: 15px;
  overflow-y: auto;
  /* إخفاء السكرول بار */
  scrollbar-width: none;
}

/* 4. الحاوية العامة لأدوات اليمين (الألوان والعرض) */
.right-sidebar-controls,
.color-switcher-group,
.view-gallery {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 30px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
  z-index: 990;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

/* 5. صور العرض المصغرة (View Thumbs) */
.view-thumb {
  cursor: pointer;
  position: relative;
  overflow: hidden;
  background: var(--bg-input);
  border: 2px solid transparent;
  transition: all 0.2s ease;
}

.view-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 3px;
}

.view-thumb.active {
  border-color: var(--primary-color);
  background: var(--bg-panel);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
}

/* 6. أزرار الألوان */
.color-btn {
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.2s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* ============================================================
   🎨 ألوان أزرار المنتج (White & Black)
   ============================================================ */

/* الزر الأبيض */
.color-btn.white {
  background-color: #ffffff;
  /* حدود رصاصي فاتح عشان يبان لو الخلفية بيضاء */
  border: 1px solid #cbd5e1;
}

/* الزر الأسود */
.color-btn.black {
  background-color: #000000;
  /* حدود رصاصي غامق عشان يبان لو الخلفية سوداء */
  border: 1px solid #475569;
}



.color-btn:hover,
.view-thumb:hover {
  transform: scale(1.1);
}

.color-btn.active {
  border-color: var(--primary-color);
  transform: scale(1.2);
}





/* ============================================================
   🕹️ GLOBAL JOYSTICK (مع استعادة الأنيميشن)
   ============================================================ */

.floating-joystick {
  position: fixed;
  /* top: 30%; */
  left: 20px;
  z-index: 9999;
  width: 200px;

  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  border-radius: 12px;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;

  user-select: none;
  -webkit-user-select: none;
  touch-action: none;

  /* 🔥🔥 هنا التعديل: رجعنا الـ top والـ cubic-bezier عشان الحركة الناعمة 🔥🔥 */
  transition:
    opacity 0.2s,
    transform 0.2s,
    height 0.3s ease,
    top 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    /* الحركة الرأسية */
    left 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  /* الحركة الأفقية */
}

.floating-joystick.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

/* باقي الأجزاء كما هي... */
.joystick-handle {
  width: 100%;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: var(--text-light);
  font-size: 1.1rem;
  background: var(--bg-input);
  border-bottom: 1px solid var(--border-color);
  border-radius: 12px 12px 0 0;
}

.joystick-handle:active {
  cursor: grabbing;
  background: var(--primary-color);
  color: #fff;
}

.joystick-actions {
  display: flex;
  width: 100%;
  justify-content: center;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-panel);
  gap: 2px;
}

.joy-action-btn {
  width: 30px;
  height: 30px;
  border-radius: 4px;
  background: transparent;
  color: var(--text-main);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, transform 0.1s;
}

.joy-action-btn:active {
  background: var(--primary-color);
  color: white;
  transform: scale(0.9);
}

.joy-action-btn.status-active {
  background: var(--primary-color);
  color: white;
}

.joy-action-btn.status-disabled {
  opacity: 0.3;
  pointer-events: none;
}

/* 🔥🔥 استعادة أنيميشن فتح وقفل القائمة 🔥🔥 */
/* 🔥🔥 إصلاح أنيميشن الفتح والقفل 🔥🔥 */
.d-pad-wrapper {
  overflow: hidden;
  background: var(--bg-panel);
  border-radius: 0 0 12px 12px;
  width: 100%;

  /* 1. لازم نحدد ارتفاع رقمي (أكبر من المحتوى المتوقع) عشان الأنيميشن يشتغل */
  max-height: 150px;
  opacity: 1;

  /* 2. إضافة الشفافية والحجم لقائمة الأنيميشن */
  transition:
    max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.3s ease;
}

.d-pad-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 0;
}

.d-pad-row {
  display: flex;
}

.d-pad-btn {
  width: 36px;
  height: 30px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: -1px;
}

.d-pad-btn:active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  z-index: 5;
}

.d-pad-btn.up {
  border-radius: 6px 6px 0 0;
  height: 28px;
}

.d-pad-btn.down {
  border-radius: 0 0 6px 6px;
  height: 28px;
}

.d-pad-btn.left {
  border-radius: 6px 0 0 6px;
}

.d-pad-btn.right {
  border-radius: 0 6px 6px 0;
}

.d-pad-center {
  width: 36px;
  height: 30px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-left: none;
  border-right: none;
  margin: -1px;
}

@media (hover: hover) {
  .joy-action-btn:hover {
    background: var(--bg-input);
    color: var(--primary-color);
  }

  .joy-action-btn.delete:hover {
    background: #fee2e2;
    color: #ef4444;
  }
}

/* ============================================================
   🚀 DRAG FIX (إصلاح اللاج أثناء السحب)
   ============================================================ */
.floating-joystick.is-dragging {
  transition: none;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
  transform: scale(1.02);
  cursor: grabbing;
}


.layers-list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding: 5px 2px;
}

.layer-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 54px;
  padding: 0px 8px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  user-select: none;
}

.layer-item:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.layer-item.active {
  background: #eff6ff;
  border-color: #3b82f6;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.layer-item.active::before {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: #3b82f6;
  border-radius: 0 4px 4px 0;
}

/* 3. الجزء الأيمن (أيقونة + نص) */
.layer-content-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  /* مهم عشان النص الطويل */
}

/* صندوق الأيقونة (لإعطاء لون خلفية للأيقونة) */
.layer-icon-box {
  width: 32px;
  height: 32px;
  background: #f1f5f9;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  flex-shrink: 0;
}

.layer-item.active .layer-icon-box {
  background: #dbeafe;
  color: #2563eb;
}

.layer-icon-box i {
  font-size: 1.2rem;
}

/* النصوص */
.layer-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.layer-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-type {
  font-size: 0.65rem;
  color: #94a3b8;
  font-weight: 500;
}

/* 4. الجزء الأيسر (الأزرار) */
.layer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ستايل الأزرار العام */
.layer-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  /* مربع بحواف دائرية (Squircle) */
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 1.1rem;
}

/* أزرار التحريك (فضي/أزرق) */
.layer-btn.btn-move {
  background: #f8fafc;
  color: #64748b;
  border: 1px solid transparent;
}

.layer-btn.btn-move:hover {
  background: #e0f2fe;
  color: #0ea5e9;
  transform: translateY(-1px);
}

.layer-btn.btn-move:active {
  transform: scale(0.95);
}

/* زر الحذف (أحمر ناعم) */
.layer-btn.btn-delete {
  background: #fef2f2;
  color: #ef4444;
  border: 1px solid transparent;
}

.layer-btn.btn-delete:hover {
  background: #fee2e2;
  color: #dc2626;
  transform: translateY(-1px) rotate(5deg);
  /* حركة بسيطة عند الهوفر */
  box-shadow: 0 2px 5px rgba(239, 68, 68, 0.2);
}

/* حالة القائمة الفارغة */
.empty-layers {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  color: #cbd5e1;
  gap: 10px;
}

.empty-layers i {
  font-size: 3rem;
  opacity: 0.5;
}

.empty-layers p {
  font-size: 0.9rem;
  font-weight: 600;
}


/* ============================================================
   🎚️ GLOBAL CONTROLS (Input, Sliders, Toggles)
   ============================================================ */

/* 1. أشرطة السحب (Range Sliders) */
.slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 5px;
  background: var(--border-color);
  /* استخدام المتغير */
  outline: none;
  margin: 10px 0;
  cursor: pointer;
}

/* مقبض السحب (Thumb) */
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary-color);
  border: 3px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  cursor: grab;
  transition: transform 0.1s;
  margin-top: -7px;
  /* توسيط المقبض */
}

.slider::-webkit-slider-thumb:active {
  transform: scale(1.2);
  cursor: grabbing;
}

/* خط الكروم (Track) */
.slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  cursor: pointer;
  background: var(--border-color);
  border-radius: 5px;
}

/* 2. حقول الإدخال والقوائم (Inputs & Selects) */
.input-group input,
.input-group textarea,
.toolbar-select,
.custom-select-trigger {
  width: 100%;
  padding: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.input-group input:focus,
.input-group textarea:focus,
.toolbar-select:focus {
  border-color: var(--primary-color);
}

/* 3. منتقي الألوان (Color Pickers) */
.toolbar-color-picker {
  -webkit-appearance: none;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  border: 3px solid white;
}

.toolbar-color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}

.toolbar-color-picker::-webkit-color-swatch {
  border: none;
}

/* 4. زر التبديل (Toggle Switch) */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-round {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: .4s;
  border-radius: 34px;
}

.slider-round:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked+.slider-round {
  background-color: var(--primary-color);
}

input:checked+.slider-round:before {
  transform: translateX(18px);
}

/* 5. شبكة الأنماط والخامات (Pattern Grid) */
.texture-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 10px;
  padding: 5px;
}

.text-pattern-item {
  width: 45px;
  height: 45px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: 0.2s;
}

.text-pattern-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.text-pattern-item:hover {
  border-color: var(--primary-color);
  transform: scale(1.05);
}

/* 6. منطقة رفع الصور (Upload Area) */
.upload-area {
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: 0.2s;
  background: var(--bg-input);
}

.upload-area:hover {
  border-color: var(--primary-color);
  background: rgba(37, 99, 235, 0.05);
}

/* 7. العلامة المائية (Watermark) */
.watermark-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;

  font-family: Arial, sans-serif;
  font-weight: 900;
  font-size: 24px;
  color: var(--water-mark);
  /* مربوطة بمتغيرات الثيم */

  transform: rotate(-30deg) scale(1.5);
  line-height: 3;
  word-spacing: 40px;
  text-align: center;
  white-space: pre-wrap;
}

/* 8. تخطيط المدخلات الصغيرة (Compact Inputs) */
.compact-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 15px;
  align-items: end;
}

.compact-col-small {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.compact-inputs label {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-bottom: 4px;
}

/* ============================================================
   🟢 تكميلات هامة (INPUTS & UPLOAD & WATERMARK CONTENT)
   ============================================================ */

/* 1. تنسيق نصوص الإدخال (Labels) */
.input-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-main);
  /* تأكيد اللون */
}

/* 2. محتوى منطقة الرفع (الأيقونة والنص) */
.upload-area i {
  font-size: 2rem;
  color: var(--text-light);
  margin-bottom: 10px;
  display: block;
  /* لضمان إنها في سطر لوحدها */
}

.upload-area p {
  margin: 0;
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.9rem;
}

/* 3. 🔥🔥 محتوى العلامة المائية (النص نفسه) 🔥🔥 */
/* بدون الكود ده العلامة المائية هتكون فاضية */
.watermark-layer::after {
  content: "f.t.ae   f.t.ae   f.t.ae   f.t.ae   f.t.ae   f.t.ae   f.t.ae \A f.t.ae   f.t.ae   f.t.ae   f.t.ae   f.t.ae   f.t.ae   f.t.ae \A f.t.ae   f.t.ae   f.t.ae   f.t.ae   f.t.ae   f.t.ae   f.t.ae \A f.t.ae   f.t.ae   f.t.ae   f.t.ae   f.t.ae   f.t.ae   f.t.ae \A f.t.ae   f.t.ae   f.t.ae   f.t.ae   f.t.ae   f.t.ae   f.t.ae";
  white-space: pre;
  /* عشان يحترم النزول سطر \A */
}

/* ============================================================
   🎨 تنسيق زر "إلغاء الباترن" (المربع المتقطع)
   ============================================================ */
.text-pattern-item.remove-pattern {
  border: 1px dashed var(--text-light);
  /* استخدام المتغير */
  color: var(--text-light);
  background: transparent;
}

.text-pattern-item.remove-pattern i {
  font-size: 1.1rem;
  /* تكبير بسيط عشان تكون واضحة */
}

/* تأثير الهوفر */
.text-pattern-item.remove-pattern:hover {
  border-color: #ef4444;
  /* أحمر عند التحويم */
  color: #ef4444;
  background: #fef2f2;
}


#textInput {
    /* نفس تنسيقات الـ input القديمة بتاعتك */
    width: 100%;
    padding: 10px;
    border-radius: 8px; /* أو حسب تصميمك */
    border: 1px solid #ccc;
    
    /* تنسيقات خاصة بالـ textarea */
    resize: none; /* لمنع المستخدم من تغيير حجم المربع */
    height: 80px; /* ارتفاع مناسب لـ 3 سطور */
    overflow-y: auto; /* سكرول لو الكلام كتر اوي */
    font-family: inherit; /* عشان ياخد نفس الخط */
}
/*//////////////////////////////////////*/
/* ============================================================
   🚨 هام جداً للقوائم المخصصة: السماح بالخروج خارج الصناديق
   ============================================================ */

/* 1. إجبار شريط الأدوات الرئيسي والأقسام الداخلية على عدم قص المحتوى */
.text-edit-toolbar,
.image-edit-toolbar, 
.toolbar-group,
.compact-inputs,
.sub-tool-header {
    overflow: visible !important;
}

/* 2. التأكد من أن القائمة نفسها تظهر فوق الجميع */
.custom-select-wrapper {
    position: relative; /* نقطة ارتكاز */
    z-index: 10; /* مستوى متوسط */
}

.custom-select-options {
    /* تم تأكيدها سابقاً لكن نعيدها للأمان */
    position: absolute;
    z-index: 999999 !important; /* رقم فلكي */
}





