/**
 * 🖼️ عارض Portfolio المخصص
 * =========================
 * عارض صور متقدم يدعم Zoom و Pan و Scroll
 */

/* الخلفية المعتمة */
.portfolio-viewer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  display: flex;
  flex-direction: column;
}

.portfolio-viewer-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* شريط الأدوات العلوي */
.viewer-toolbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 10002;
}

.viewer-title {
  color: white;
  font-size: 1.1rem;
  font-weight: 500;
  text-align: center;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 20px;
}

.viewer-controls {
  display: flex;
  gap: 10px;
}

.viewer-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.viewer-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.1);
}

.viewer-btn.close-btn {
  background: rgba(255, 100, 100, 0.2);
}

.viewer-btn.close-btn:hover {
  background: rgba(255, 100, 100, 0.4);
}

/* حاوية الصورة */
.viewer-container {
  flex: 1;
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 70px 20px 100px;
  -webkit-overflow-scrolling: touch;
}

.viewer-image-wrapper {
  position: relative;
  display: flex;
  justify-content: center;
  transition: transform 0.2s ease;
}

.viewer-image {
  max-width: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  cursor: grab;
  transition: transform 0.3s ease;
}

.viewer-image.zoomed {
  cursor: zoom-out;
}

.viewer-image.grabbing {
  cursor: grabbing;
}

/* مستويات الزوم */
.viewer-image.zoom-1 {
  max-width: 100%;
}

.viewer-image.zoom-2 {
  max-width: 150%;
  width: 150%;
}

.viewer-image.zoom-3 {
  max-width: 200%;
  width: 200%;
}

.viewer-image.zoom-4 {
  max-width: 300%;
  width: 300%;
}

/* أزرار التنقل */
.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10001;
}

.viewer-nav.prev {
  left: 20px;
}

.viewer-nav.next {
  right: 20px;
}

.viewer-nav-btn {
  width: 50px;
  height: 50px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.viewer-nav-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.1);
}

/* شريط الزوم السفلي */
.viewer-zoom-bar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 10px 20px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 30px;
  backdrop-filter: blur(10px);
  z-index: 10002;
}

.zoom-level {
  color: white;
  font-size: 14px;
  min-width: 50px;
  text-align: center;
}

/* مؤشر التحميل */
.viewer-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 40px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }

  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* رقم الصورة */
.viewer-counter {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  z-index: 10001;
}

/* تحسينات للموبايل */
@media (max-width: 768px) {
  .viewer-toolbar {
    padding: 0 10px;
  }

  .viewer-title {
    font-size: 0.9rem;
  }

  .viewer-btn {
    width: 38px;
    height: 38px;
    font-size: 16px;
  }

  .viewer-nav-btn {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }

  .viewer-nav.prev {
    left: 10px;
  }

  .viewer-nav.next {
    right: 10px;
  }

  .viewer-container {
    padding: 60px 10px 120px;
  }

  .viewer-zoom-bar {
    padding: 8px 15px;
    gap: 10px;
  }
}

/* إخفاء الأزرار عند التمرير */
.viewer-container::-webkit-scrollbar {
  width: 8px;
}

.viewer-container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.viewer-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
}

.viewer-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}