/* Scene Modal Module CSS */

/* Loading Spinner */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Scene Modal Styles */
.scene-modal {
  display: none;
  position: fixed;
  z-index: 1050;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  /* Prevent swipe navigation when modal is open */
  overscroll-behavior: contain;
  -webkit-overscroll-behavior: contain;
}

.scene-modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.scene-modal-content {
  background: white;
  border-radius: 16px;
  max-width: 90vw;
  max-height: 85vh;
  width: 100%;
  overflow: hidden;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}

.scene-modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #000000 0%, #333333 100%);
  color: white;
  flex: 0 0 auto;
}

.scene-modal-title {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: white;
}

.scene-modal-close {
  background: none;
  border: none;
  color: white;
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.scene-modal-close:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.scene-modal-body {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.scene-carousel {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  flex: 0 0 auto;
  /* Prevent browser back/forward navigation on overscroll */
  overscroll-behavior-x: contain;
  -webkit-overscroll-behavior-x: contain;
}

.scene-carousel-wrapper {
  display: flex;
  transition: none;
  cursor: default;
  gap: 8px;
  padding: 15px;
  box-sizing: border-box;
  min-width: 100%;
}

.scene-slide {
  flex: 0 0 auto;
  width: 155px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0;
  box-sizing: border-box;
}

.scene-image {
  width: 140px;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  margin-bottom: 8px;
  position: relative;
}

.scene-image.portrait {
  max-height: 240px;
}

.scene-image.landscape {
  max-height: 100px;
}

.scene-image.square {
  height: 140px;
}

.video-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border-radius: 50%;
  width: 35px;
  height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  pointer-events: none;
  z-index: 3;
}

.avatar-mask {
  position: absolute;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  pointer-events: none;
  z-index: 2;
}

.text-overlay {
  position: absolute;
  color: white;
  font-weight: bold;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 4;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
  word-wrap: break-word;
  overflow: hidden;
  line-height: 1.2;
  -webkit-text-stroke: 1px #000000;
  text-stroke: 1px #000000;
  -webkit-text-fill-color: white;
  paint-order: stroke fill;
}

.scene-image-container {
  position: relative;
  width: 140px;
  margin-bottom: 8px;
}

.scene-badge {
  position: absolute;
  top: 0;
  left: 0;
  background: #000000;
  color: white;
  font-size: 9px;
  font-weight: 600;
  padding: 3px 6px 4px 4px;
  border-radius: 8px 0 10px 0;
  z-index: 5;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.scene-badge.thumbnail {
  background: #28a745;
}

.scene-text {
  background: #f8f9fa;
  padding: 6px 8px;
  border-radius: 6px;
  text-align: center;
  width: 100%;
  border-left: 3px solid #667eea;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 45px;
  max-height: 75px;
  overflow: hidden;
}

.scene-text p {
  margin: 0;
  color: #666;
  line-height: 1.2;
  font-size: 11px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 15px 20px;
  border-top: 1px solid #e9ecef;
  background: white;
  flex-shrink: 0;
}

.scene-edit-note {
  font-size: 11px;
  color: #6c757d;
  text-align: center;
  font-style: italic;
  margin: 0;
  padding: 0 10px;
  line-height: 1.3;
}

/* Mobile styles */
@media (max-width: 768px) {
  .scene-modal-content {
    max-width: 95vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
  }
  
  .scene-modal-header {
    padding: 16px 20px;
    flex-shrink: 0;
  }
  
  .scene-modal-title {
    font-size: 20px;
  }
  
  .scene-modal-body {
    flex: 1;
    min-height: 0;
  }
  
  .scene-carousel {
    overflow-x: auto;
    overflow-y: hidden;
  }
  
  .scene-carousel-wrapper {
    transition: none;
    gap: 8px;
    padding: 15px;
    display: flex;
    width: auto;
    min-width: 100%;
  }
  
  .scene-slide {
    width: 155px;
    flex: 0 0 auto;
    padding: 0;
    box-sizing: border-box;
  }
  
  .modal-actions {
    padding: 12px 15px;
    flex-shrink: 0;
  }
}

/* Loading state for modal */
.scene-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: #666;
  padding: 20px;
}

.scene-loading .loading-spinner {
  width: 40px;
  height: 40px;
  border-width: 4px;
  margin-bottom: 16px;
}

/* Add to existing Scene Modal CSS */

/* Fix for landscape images in portrait video scenes */
.scene-image.landscape-in-portrait {
  height: 240px !important;
  object-fit: cover;
  object-position: center;
  width: 140px;
}

/* Ensure container handles the fixed height properly */
.scene-image-container {
  position: relative;
  width: 140px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
}

/* Keep existing portrait behavior */
.scene-image.portrait {
  max-height: 240px;
  width: 140px;
}

/* Landscape and square remain unchanged */
.scene-image.landscape {
  max-height: 100px;
}

.scene-image.square {
  height: 140px;
}