/* ===================================
   Modal Container
   =================================== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

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

/* ===================================
   Modal Overlay
   =================================== */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
}

/* ===================================
   Modal Content
   =================================== */
.modal-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  z-index: 1001;
}

.modal-image {
  max-width: 90%;
  max-height: 90vh;
  object-fit: contain;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  transition: opacity 0.15s ease-in-out;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}

/* ===================================
   Modal Controls (Buttons)
   =================================== */
.modal-close,
.modal-prev,
.modal-next {
  position: absolute;
  background: white;
  border: 1px solid var(--color-border);
  cursor: pointer;
  font-size: 2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease-in-out;
  z-index: 1002;
  color: var(--color-text);
  user-select: none;
  -webkit-user-select: none;
}

.modal-close:hover,
.modal-prev:hover,
.modal-next:hover {
  background: var(--color-text);
  color: white;
  transform: scale(1.05);
}

.modal-close:active,
.modal-prev:active,
.modal-next:active {
  transform: scale(0.95);
}

.modal-close:focus-visible,
.modal-prev:focus-visible,
.modal-next:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

/* Close Button */
.modal-close {
  top: 2rem;
  right: 2rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 2rem;
}

/* Previous Button */
.modal-prev {
  left: 2rem;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 2.5rem;
}

.modal-prev:hover {
  transform: translateY(-50%) scale(1.05);
}

.modal-prev:active {
  transform: translateY(-50%) scale(0.95);
}

/* Next Button */
.modal-next {
  right: 2rem;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 2.5rem;
}

.modal-next:hover {
  transform: translateY(-50%) scale(1.05);
}

.modal-next:active {
  transform: translateY(-50%) scale(0.95);
}

/* ===================================
   Modal Counter
   =================================== */
.modal-counter {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  border: 1px solid var(--color-border);
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 1002;
  color: var(--color-text);
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.modal-counter .current-index {
  font-weight: 600;
}

/* ===================================
   Modal Animations
   =================================== */
@keyframes modalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal.active .modal-image {
  animation: modalSlideUp 0.3s ease-out;
}

/* ===================================
   Responsive Design - Tablet
   =================================== */
@media (max-width: 992px) {
  .modal-content {
    padding: 1.5rem;
  }

  .modal-image {
    max-width: 95%;
    max-height: 85vh;
  }

  .modal-close {
    top: 1.5rem;
    right: 1.5rem;
    width: 38px;
    height: 38px;
  }

  .modal-prev,
  .modal-next {
    width: 45px;
    height: 45px;
  }

  .modal-prev {
    left: 1.5rem;
  }

  .modal-next {
    right: 1.5rem;
  }

  .modal-counter {
    bottom: 1.5rem;
  }
}

/* ===================================
   Responsive Design - Mobile
   =================================== */
@media (max-width: 576px) {
  .modal-content {
    padding: 1rem;
  }

  .modal-image {
    max-width: 95%;
    max-height: 80vh;
  }

  .modal-close {
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    font-size: 1.75rem;
  }

  .modal-prev,
  .modal-next {
    width: 40px;
    height: 40px;
    font-size: 2rem;
  }

  .modal-prev {
    left: 0.5rem;
  }

  .modal-next {
    right: 0.5rem;
  }

  .modal-counter {
    bottom: 1rem;
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
  }

  .modal-overlay {
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
  }
}

/* ===================================
   Touch Device Optimizations
   =================================== */
@media (hover: none) and (pointer: coarse) {
  .modal-close,
  .modal-prev,
  .modal-next {
    /* Larger touch targets for mobile */
    min-width: 44px;
    min-height: 44px;
  }

  .modal-close:hover,
  .modal-prev:hover,
  .modal-next:hover {
    /* Disable hover effects on touch devices */
    background: white;
    color: var(--color-text);
    transform: none;
  }

  .modal-prev:hover {
    transform: translateY(-50%);
  }

  .modal-next:hover {
    transform: translateY(-50%);
  }
}

/* ===================================
   Accessibility - Reduce Motion
   =================================== */
@media (prefers-reduced-motion: reduce) {
  .modal,
  .modal-image,
  .modal-close,
  .modal-prev,
  .modal-next {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

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