/* ============================================
   IMAGE GALLERY MODAL & CAROUSEL
   Современное модальное окно для просмотра изображений
   ============================================ */

/* Modal Overlay */
.image-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.95);
  z-index: 9999;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.image-modal-overlay.active {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
}

/* Modal Container */
.image-modal-container {
  position: relative;
  width: 90%;
  max-width: 1200px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.image-modal-overlay.active .image-modal-container {
  transform: scale(1);
}

/* Modal Header */
.image-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.image-modal-title {
  color: #ffffff;
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
}

.image-modal-counter {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.875rem;
  margin-left: 1rem;
}

.modal-close-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  font-size: 1.5rem;
  line-height: 1;
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

.modal-close-btn:active {
  transform: rotate(90deg) scale(0.95);
}

/* Main Carousel Container */
.image-modal-body {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 400px;
}

/* Carousel Wrapper */
.modal-carousel-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-carousel-track {
  display: flex;
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

/* Carousel Item */
.modal-carousel-item {
  flex-shrink: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.modal-carousel-item img {
  max-width: 100%;
  max-height: 70vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
  user-select: none;
  -webkit-user-drag: none;
}

/* Navigation Buttons */
.modal-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 10;
  font-size: 1.5rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.modal-nav-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-50%) scale(1.1);
}

.modal-nav-btn:active:not(:disabled) {
  transform: translateY(-50%) scale(0.95);
}

.modal-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.modal-nav-btn.prev {
  left: 1.5rem;
}

.modal-nav-btn.next {
  right: 1.5rem;
}

/* Thumbnail Preview Strip */
.image-modal-footer {
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-thumbnails-wrapper {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.5rem 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
  scroll-behavior: smooth;
}

.modal-thumbnails-wrapper::-webkit-scrollbar {
  height: 6px;
}

.modal-thumbnails-wrapper::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.modal-thumbnails-wrapper::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.modal-thumbnails-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

.modal-thumbnail {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border: 3px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
  background: rgba(255, 255, 255, 0.05);
  position: relative;
}

.modal-thumbnail::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  transition: background 0.3s ease;
  z-index: 1;
}

.modal-thumbnail:hover::before {
  background: rgba(0, 0, 0, 0.3);
}

.modal-thumbnail.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.modal-thumbnail.active::before {
  background: rgba(0, 0, 0, 0);
}

.modal-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}

/* Loading Spinner */
.modal-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: modal-spin 0.8s linear infinite;
  z-index: 5;
}

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

/* Touch/Swipe Indicators */
.modal-swipe-hint {
  position: absolute;
  bottom: 6rem;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: modal-fade-in-out 2s ease-in-out infinite;
}

@keyframes modal-fade-in-out {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.7; }
}

.modal-swipe-hint i {
  font-size: 1rem;
}

/* Zoom Controls */
.modal-zoom-controls {
  position: absolute;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  gap: 0.5rem;
  z-index: 15;
}

.modal-zoom-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.modal-zoom-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.modal-zoom-btn:active {
  transform: scale(0.95);
}

/* Fullscreen Mode */
.image-modal-overlay.fullscreen {
  background-color: #000000;
}

.image-modal-overlay.fullscreen .image-modal-header,
.image-modal-overlay.fullscreen .image-modal-footer {
  background: transparent;
  border: none;
}

/* Keyboard Shortcuts Hint */
.modal-shortcuts-hint {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.75rem;
  background: rgba(0, 0, 0, 0.5);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.modal-shortcuts-hint.show {
  opacity: 1;
}

.modal-shortcuts-hint kbd {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: monospace;
  margin: 0 2px;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
  .image-modal-container {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
  }

  .image-modal-header {
    padding: 0.75rem 1rem;
  }

  .image-modal-title {
    font-size: 1rem;
  }

  .modal-close-btn {
    width: 36px;
    height: 36px;
    font-size: 1.25rem;
  }

  .modal-carousel-item {
    padding: 1rem;
  }

  .modal-carousel-item img {
    max-height: 60vh;
  }

  .modal-nav-btn {
    width: 44px;
    height: 44px;
    font-size: 1.25rem;
  }

  .modal-nav-btn.prev {
    left: 0.75rem;
  }

  .modal-nav-btn.next {
    right: 0.75rem;
  }

  .image-modal-footer {
    padding: 1rem;
  }

  .modal-thumbnail {
    width: 60px;
    height: 60px;
  }

  .modal-zoom-controls {
    bottom: 1rem;
    right: 1rem;
  }

  .modal-shortcuts-hint {
    display: none;
  }
}

@media (max-width: 480px) {
  .image-modal-header {
    padding: 0.5rem 0.75rem;
  }

  .image-modal-counter {
    font-size: 0.75rem;
  }

  .modal-close-btn {
    width: 32px;
    height: 32px;
    font-size: 1.125rem;
  }

  .modal-carousel-item {
    padding: 0.5rem;
  }

  .modal-carousel-item img {
    max-height: 55vh;
    border-radius: 4px;
  }

  .modal-nav-btn {
    width: 40px;
    height: 40px;
    font-size: 1.125rem;
  }

  .modal-nav-btn.prev {
    left: 0.5rem;
  }

  .modal-nav-btn.next {
    right: 0.5rem;
  }

  .image-modal-footer {
    padding: 0.75rem;
  }

  .modal-thumbnail {
    width: 50px;
    height: 50px;
    border-width: 2px;
  }

  .modal-thumbnails-wrapper {
    gap: 0.5rem;
  }

  .modal-zoom-controls {
    display: none;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  .image-modal-overlay,
  .image-modal-container,
  .modal-carousel-track,
  .modal-nav-btn,
  .modal-thumbnail,
  .modal-close-btn {
    transition: none;
    animation: none;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .modal-close-btn,
  .modal-nav-btn,
  .modal-zoom-btn {
    border: 2px solid #ffffff;
  }

  .modal-thumbnail.active {
    border-width: 4px;
  }
}

/* Print Styles */
@media print {
  .image-modal-overlay {
    display: none !important;
  }
}