/* Video Gallery Styles */

.video-wrapper {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: var(--_radius);
  cursor: pointer;
  /* إزالة height: 480px لجعل السكشن يتكيف مع حجم الفيديو */
}

.gallery__video {
  width: 100% !important; /* إجبار العرض ليكون 100% */
  height: auto !important; /* تغيير من 100% إلى auto ليتكيف مع حجم الفيديو الطبيعي */
  display: block;
  border-radius: 20px; /* تغيير الحواف إلى 20px */
  cursor: pointer;
  transition: transform 0.3s var(--_animbezier);
  object-fit: cover; /* الحفاظ على نسب الفيديو */
}

/* إزالة التنسيق المكرر */
.video-wrapper .gallery__video {
  /* تم دمج التنسيق أعلاه */
}

/* عند التكبير، الفيديو يظهر بالحجم الأصلي */
.video-fullscreen-container video {
  width: auto; /* تغيير من 100% إلى auto للحفاظ على الحجم الأصلي */
  height: auto;
  max-width: 90vw; /* أقصى عرض */
  max-height: 90vh; /* أقصى ارتفاع */
  border-radius: 8px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

@media only screen and (min-width: 1200px) {
  .video-wrapper {
    transform: scale3d(1, 1, 1);
    transition: transform 0.3s var(--_animbezier);
  }
  
  .no-touch .video-wrapper:hover {
    transform: scale3d(1.02, 1.02, 1.02);
  }
  
  .no-touch .video-wrapper:hover .gallery__video {
    transform: scale(1.05);
  }
}

.video-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  opacity: 1;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.video-overlay i {
  font-size: 4rem;
  color: var(--t-per-bright-light);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.video-wrapper.playing .video-overlay {
  opacity: 0;
}

/* Video Controls */
.gallery__video::-webkit-media-controls {
  display: none !important;
}

.gallery__video::-webkit-media-controls-panel {
  display: none !important;
}

.gallery__video::-webkit-media-controls-play-button {
  display: none !important;
}

.gallery__video::-webkit-media-controls-start-playback-button {
  display: none !important;
}

.gallery__video::-webkit-media-controls-timeline {
  display: none !important;
}

.gallery__video::-webkit-media-controls-current-time-display {
  display: none !important;
}

.gallery__video::-webkit-media-controls-time-remaining-display {
  display: none !important;
}

.gallery__video::-webkit-media-controls-mute-button {
  display: none !important;
}

.gallery__video::-webkit-media-controls-volume-slider {
  display: none !important;
}

.gallery__video::-webkit-media-controls-fullscreen-button {
  display: none !important;
}

.gallery__video::-moz-media-controls {
  display: none !important;
}

.gallery__video::-ms-media-controls {
  display: none !important;
}

/* Fullscreen Button */
.video-fullscreen-btn {
  position: absolute;
  bottom: 1.5rem; /* زيادة المسافة من الأسفل */
  right: 1.5rem; /* زيادة المسافة من اليمين */
  z-index: 3;
  opacity: 1;
  transition: opacity 0.3s ease;
  pointer-events: auto;
  cursor: pointer;
}

.video-fullscreen-btn i {
  font-size: 2rem; /* زيادة حجم الأيقونة من 1.5rem إلى 2rem */
  color: var(--t-per-bright-light);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  background: rgba(0, 0, 0, 0.6); /* زيادة شفافية الخلفية */
  border-radius: 50%;
  padding: 0.7rem; /* زيادة padding لتناسب الحجم الأكبر */
  backdrop-filter: blur(4px);
  transition: all 0.3s ease;
}

.video-fullscreen-btn:hover i {
  background: rgba(0, 0, 0, 0.8);
  transform: scale(1.1);
}

.no-touch .video-wrapper:hover .video-fullscreen-btn {
  opacity: 1;
  pointer-events: auto;
}

.video-wrapper.playing .video-fullscreen-btn {
  opacity: 1;
  pointer-events: auto;
}

.divider-video .video-fullscreen-btn {
  opacity: 1;
  pointer-events: auto;
}

.gallery__item .video-fullscreen-btn {
  opacity: 1;
  pointer-events: auto;
}

/* Fullscreen Video Styles */
.video-fullscreen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
}

.video-fullscreen-overlay.active {
  display: flex;
}

.video-fullscreen-container {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-fullscreen-close {
  position: absolute;
  top: 3rem;
  right: 0;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 50%;
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.video-fullscreen-close:hover {
  background: rgba(0, 0, 0, 0.9);
  border-color: rgba(255, 255, 255, 0.6);
  transform: scale(1.1);
}

/* تنسيق خاص للفيديو الرئيسي */
.main-video-1 .main-video {
  width: 100% !important;
  border-radius: 20px !important;
  object-fit: cover;
}

/* على اللابتوب - فيديو عرضي */
@media only screen and (min-width: 768px) {
  .main-video-1 .main-video {
    height: 400px !important; /* ارتفاع ثابت للفيديو العرضي */
    max-height: 400px;
  }
  
  .main-video-1 {
    height: 400px;
  }
}

/* على الجوال - فيديو طولي */
@media only screen and (max-width: 767px) {
  .main-video-1 .main-video {
    height: 600px !important; /* ارتفاع أكبر للفيديو الطولي */
    max-height: 600px;
  }
  
  .main-video-1 {
    height: 600px;
  }
}

/* إخفاء زر التشغيل للفيديو الرئيسي عندما يكون يعمل */
.divider-video.playing .video-overlay {
  opacity: 0;
  pointer-events: none;
}

/* إظهار زر التشغيل للفيديو الرئيسي عند التوقف */
.divider-video:not(.playing) .video-overlay {
  opacity: 1;
  pointer-events: auto;
}

/* Safari-specific fixes to prevent automatic fullscreen */
@supports (-webkit-touch-callout: none) {
  .gallery__video,
  .main-video,
  .service-img {
    -webkit-playsinline: true;
    -webkit-presentation-mode: inline;
  }
  
  /* Force inline mode for Safari */
  video::-webkit-media-controls-fullscreen-button {
    display: none !important;
  }
  
  video::-webkit-media-controls-panel {
    display: none !important;
  }
}

/* Additional Safari fixes */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
  .gallery__video,
  .main-video,
  .service-img {
    -webkit-playsinline: true;
  }
}
