/* إعدادات عامة */
* {
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: #333;
  font-display: swap; /* تحسين تحميل الخطوط */
}

/* تحسينات للنصوص العربية */
.rtl {
  direction: rtl;
  text-align: right;
}

/* تأثيرات الانتقال */
.transition-all {
  transition: transform 0.2s ease, opacity 0.2s ease;
  will-change: transform, opacity;
}

/* تحسينات للصور */
.photo-card img {
  transition: transform 0.2s ease;
  will-change: transform;
}

.photo-card:hover img {
  transform: scale(1.02);
}

/* تحسينات للأزرار */
.btn {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* تحسينات للنافذة المنبثقة */
.modal-overlay {
  backdrop-filter: blur(4px);
}

/* تحسينات للبحث */
#searchInput:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* تحسينات للتصنيفات */
.category-btn {
  transition: all 0.2s ease;
}

.category-btn:hover {
  transform: translateY(-1px);
}

.category-btn.active {
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

/* تحسينات للشبكة */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  contain: layout style;
}

/* تحسينات للاستجابة */
@media (max-width: 768px) {
  .photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.5rem;
  }

  .container {
    padding: 0 0.5rem;
  }

  /* تقليل الحركات على الجوال */
  .transition-all,
  .photo-card img,
  .btn {
    transition: none;
  }
}

/* تحسينات للتحميل */
.loading {
  opacity: 0.7;
  pointer-events: none;
}

.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* تنسيق الإشعارات المحسن */
.custom-notification {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif !important;
  direction: rtl;
  text-align: right;
}

.custom-notification i {
  margin-left: 8px;
  margin-right: 0;
}

/* تحسينات للإشعارات القديمة (للتوافق مع الكود القديم) */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  padding: 16px 20px;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  font-size: 14px;
  max-width: 350px;
  min-width: 250px;
  transform: translateX(100%);
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  word-wrap: break-word;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  direction: rtl;
  text-align: right;
}

.notification.show {
  transform: translateX(0);
  opacity: 1;
}

.notification.success {
  background: #10b981;
}

.notification.error {
  background: #ef4444;
}

.notification.warning {
  background: #f59e0b;
}

.notification.info {
  background: #3b82f6;
}

.notification i {
  font-size: 16px;
  flex-shrink: 0;
  margin-left: 8px;
  margin-right: 0;
}

/* تحسينات للإشعارات على الجوال */
@media (max-width: 768px) {
  .notification,
  .custom-notification {
    right: 10px;
    left: 10px;
    max-width: none;
    min-width: auto;
    top: 10px;
  }
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* تحسينات للنصوص */
.line-clamp-1 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.line-clamp-2 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* تحسينات للظلال */
.shadow-hover {
  transition: box-shadow 0.3s ease;
}

.shadow-hover:hover {
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* تحسينات للألوان */
:root {
  --primary-color: #3b82f6;
  --secondary-color: #64748b;
  --success-color: #10b981;
  --error-color: #ef4444;
  --warning-color: #f59e0b;
}

/* تحسينات للوضع الداكن */
@media (prefers-color-scheme: dark) {
  .dark-mode {
    background-color: #1f2937;
    color: #f9fafb;
  }

  .dark-mode .bg-white {
    background-color: #374151;
  }

  .dark-mode .text-gray-600 {
    color: #d1d5db;
  }

  .dark-mode .border-gray-300 {
    border-color: #4b5563;
  }
}

/* تحسينات للطباعة */
@media print {
  .no-print {
    display: none !important;
  }

  .photo-card {
    break-inside: avoid;
    margin-bottom: 1rem;
  }
}

/* تحسينات لإمكانية الوصول */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* تحسينات للتركيز */
.focus-visible:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* تحسينات للحركة المخفضة */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* تحسينات الأداء */
.photo-item {
  contain: layout style paint;
}

img {
  content-visibility: auto;
  contain-intrinsic-size: 300px 200px;
}

/* تحسينات إضافية للأزرار */
.action-btn {
  position: relative;
  overflow: hidden;
}

.action-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.action-btn:hover::before {
  left: 100%;
}

/* تحسينات للمشاركة */
.share-buttons {
  gap: 8px;
}

.share-btn {
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.share-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* تحسينات للتفاعل مع اللمس */
@media (hover: none) and (pointer: coarse) {
  .action-btn:hover,
  .share-btn:hover,
  .btn:hover {
    transform: none;
    box-shadow: none;
  }

  .action-btn:active,
  .share-btn:active,
  .btn:active {
    transform: scale(0.95);
  }
}
