/* تعريف المتغيرات للألوان والتأثيرات */
:root {
  --primary-color: #4F46E5;
  --primary-dark: #3730A3;
  --primary-light: #E0E7FF;
  --secondary-color: #9333EA;
  --success-color: #10B981;
  --danger-color: #EF4444;
  --warning-color: #F59E0B;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;
  --text-color: #111827;
  --border-radius: 1.25rem;
  --box-shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1), 0 5px 15px rgba(0, 0, 0, 0.05);
}

/* وضع الداكن */
.dark-mode {
  --primary-color: #818CF8;
  --primary-dark: #3730A3;
  --primary-light: #E0E7FF;
  --secondary-color: #C084FC;
  --gray-50: #111827;
  --gray-100: #1F2937;
  --gray-200: #374151;
  --gray-700: #9CA3AF;
  --gray-800: #6B7280;
  --gray-900: #030712;
  --text-color: #E5E7EB;
}

/* تنسيق الجسم الرئيسي */
body {
  font-family: 'Cairo', sans-serif;
  background: linear-gradient(135deg, var(--gray-50), var(--gray-100));
  color: var(--text-color);
  transition: background 0.3s ease, color 0.3s ease;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/ biod حاوية الأدوات */
.tools-container {
  background: linear-gradient(135deg, var(--primary-light), var(--gray-50));
  padding: clamp(0.75rem, 2vw, 1.5rem); /* تحسين الحشوة للشاشات المختلفة */
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow-lg);
  transition: all 0.3s ease;
}

/* رأس الأكورديون */
.accordion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: clamp(0.5rem, 1.5vw, 1rem); /* تحسين الحشوة */
  border-radius: var(--border-radius);
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

.accordion-header:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

/* محتوى الأكورديون */
.accordion-content {
  padding: clamp(0.75rem, 2vw, 1.5rem); /* تحسين الحشوة */
  background: var(--gray-50);
  border-radius: var(--border-radius);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

/* زر الأداة */
.tool-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--gray-50);
  color: var(--text-color);
  padding: clamp(0.5rem, 1.5vw, 1rem) clamp(1rem, 2vw, 1.5rem); /* تحسين الحشوة */
  border-radius: var(--border-radius);
  width: 100%;
  text-align: right;
  transition: all 0.3s ease;
  box-shadow: var(--box-shadow-lg);
  border: 1px solid var(--gray-200);
}

.tool-btn:hover {
  background: linear-gradient(135deg, var(--primary-light), var(--gray-50));
  transform: translateY(-5px) scale(1.03);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.tool-btn:active {
  transform: translateY(0);
  box-shadow: var(--box-shadow-lg);
}

/* القائمة المنسدلة */
.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow-lg);
  padding: 1.5rem;
  margin-top: 0.75rem;
  width: min(280px, 90vw); /* تحسين العرض على الشاشات الصغيرة */
  z-index: 1000;
  transition: all 0.3s ease;
}

/* قائمة الطبقات */
.layers-list {
  max-height: 320px;
  overflow-y: auto;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  padding: 1rem;
}

/* عنصر قائمة الطبقات */
.layers-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: var(--gray-100);
  border-radius: 0.75rem;
  transition: all 0.3s ease;
}

.layers-list-item:hover {
  background: var(--primary-light);
  transform: scale(1.03);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* حاوية المحرر */
.editor-container {
  min-height: calc(100vh - 140px);
  padding: clamp(1rem, 3vw, 2rem); /* تحسين الحشوة */
}

/* حاوية المحرر الداخلية */
#editor-container {
  min-height: clamp(500px, 70vh, 700px); /* تحسين الارتفاع */
  border-radius: var(--border-radius);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

/* قماش Fabric.js */
#fabric-canvas {
  width: 100%;
  height: auto;
  background-color: #fff;
  border-radius: var(--border-radius);
  transition: transform 0.3s ease, opacity 0.5s ease;
  opacity: 0;
}

#fabric-canvas.loaded {
  opacity: 1;
}

#fabric-canvas:hover {
  transform: scale(1.02);
}

/* الإشعارات */
.notification {
  max-width: min(400px, 90vw); /* تحسين العرض */
  transition: all 0.3s ease;
  border-radius: 1rem;
}

/* أيقونة الإشعار */
.notification-icon {
  font-size: 2rem;
  transition: transform 0.3s ease;
}

.notification-icon:hover {
  transform: rotate(15deg) scale(1.1);
}

/* عنوان الإشعار */
.notification-title {
  color: var(--text-color);
}

/* رسالة الإشعار */
.notification-message {
  color: var(--gray-700);
}

/* المؤشر */
.loader {
  border-top-color: var(--primary-color);
  animation: spin 0.8s linear infinite;
}

/* الرسوم المتحركة */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.animate-fadeIn {
  animation: fadeIn 1s ease-in-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fadeInUp {
  animation: fadeInUp 1s ease-in-out;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-bounceIn {
  animation: bounceIn 1s ease-in-out;
}
@keyframes bounceIn {
  0% { opacity: 0; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.05); }
  70% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.animate-slideDown {
  animation: slideDown 0.8s ease-in-out;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-100%); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-pulse-short {
  animation: pulseShort 0.5s ease-in-out infinite;
}
@keyframes pulseShort {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* الوضع الداكن */
.dark-mode .tools-container,
.dark-mode .accordion-content,
.dark-mode .tool-btn,
.dark-mode .dropdown-menu,
.dark-mode .layers-list {
  background: var(--gray-100);
  border-color: var(--gray-700);
}

/* الاستجابة للشاشات */
@media (max-width: 1200px) {
  .accordion {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1024px) {
  .accordion {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .accordion {
    grid-template-columns: 1fr;
  }
  .editor-container {
    padding: 1rem;
  }
  #editor-container {
    min-height: 500px;
  }
  .notification {
    bottom: 1rem;
    right: 1rem;
    max-width: 90%;
  }
}

@media (max-width: 600px) { /* إضافة حجم متوسط */
  .tools-container {
    padding: 0.5rem;
  }
  .accordion-header {
    font-size: 0.9rem;
  }
  .tool-btn {
    font-size: 0.875rem;
  }
}

@media (max-width: 480px) {
  .tools-container {
    padding: 0.75rem;
  }
  .accordion-header {
    padding: 0.5rem;
  }
  .accordion-content {
    padding: 0.75rem;
  }
  .tool-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
}