/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Gallery Trigger Styles */
[data-function="lightbox"] {
  margin: 0;
}

[lightbox-data-view] {
  cursor: pointer;
}

[lightbox-data-view]:hover {
  opacity: 1;
}

/* Hide content sections by default */
[lightbox-data-content] {
  display: none;
}

/* Lightbox Styles */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.4s ease;
  backdrop-filter: blur(10px);
  background: rgba(0, 0, 0, 0.6);
  touch-action: none;
}

/* Single Item State */
.lightbox.single-item .lightbox-progress-bar,
.lightbox.single-item .lightbox-prev-btn,
.lightbox.single-item .lightbox-next-btn,
.lightbox.single-item .lightbox-counter {
  display: none !important;
}

/* Light Theme */
.lightbox[lightbox-theme="light"] {
  background: rgba(255, 255, 255, 0.95);
}

.lightbox[lightbox-theme="light"] .lightbox-control {
  color: #444;
}

.lightbox[lightbox-theme="light"] .lightbox-control:hover {
  color: #000;
}

.lightbox[lightbox-theme="light"] .lightbox-info {
  color: #333;
}

.lightbox[lightbox-theme="light"] .lightbox-counter {
  color: rgba(0, 0, 0, 0.6);
}

.lightbox[lightbox-theme="light"] .lightbox-loading {
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-top-color: #555;
}

/* Dark Theme (default) */
.lightbox[lightbox-theme="dark"] {
  background: rgba(0, 0, 0, 0.9);
}

.lightbox[lightbox-theme="dark"] .lightbox-control {
  color: #eee;
  background: rgba(30, 30, 30, 0.8);
}

.lightbox[lightbox-theme="dark"] .lightbox-control:hover {
  background: rgba(50, 50, 50, 0.9);
  color: #fff;
}

.lightbox[lightbox-theme="dark"] .lightbox-info {
  color: #eee;
}

.lightbox[lightbox-theme="dark"] .lightbox-counter {
  color: rgba(255, 255, 255, 0.6);
}

.lightbox[lightbox-theme="dark"] .lightbox-loading {
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: #eee;
}

.lightbox.active {
  display: flex;
  opacity: 1;
}

.lightbox-content {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  animation: fadeInUp 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  transform-origin: center;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.lightbox-media-container {
  position: relative;
  max-width: 100%;
  max-height: 80vh;
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: none;
  cursor: grab;
}

.lightbox-media-container.grabbing {
  cursor: grabbing;
}

.lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  display: none;
  touch-action: none;
  transition: transform 0.3s ease-out;
  will-change: transform;
}

.lightbox-video {
  border: none;
  max-width: 100%;
  max-height: 80vh;
  display: none;
  touch-action: none;
  transition: transform 0.3s ease-out;
  will-change: transform;
}

.lightbox-html-content {
  max-width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  display: none;
  touch-action: none;
  transition: transform 0.3s ease-out;
  will-change: transform;
}

/* Drag Slide Overlay */
.drag-slide-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  display: none;
}

/* Control Divs */
.lightbox-control {
  position: absolute;
  cursor: pointer;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  outline: none;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.8);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  border: none;
  background: none;
}

.lightbox-control:focus {
  outline: 2px solid rgba(0, 123, 255, 0.5);
  outline-offset: 2px;
}

.lightbox-control.visible {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

.lightbox-control:hover {
  transform: scale(1.1) !important;
}

.lightbox-close-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  font-size: 28px;
}

.lightbox-prev-btn {
  position: fixed;
  left: 20px;
  top: 50%;
  transform: translateY(-50%) scale(0.8);
}

.lightbox-next-btn {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%) scale(0.8);
}

/* Info Section */
.lightbox-info {
  padding: 16px 24px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: 0 0 12px 12px;
}

.lightbox-info.visible {
  opacity: 1;
}

.lightbox-caption {
  font-size: 16px;
  margin-bottom: 4px;
  font-weight: 500;
}

.lightbox-counter {
  font-size: 13px;
  letter-spacing: 0.5px;
}

/* Loading Indicator */
.lightbox-loading {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 1s cubic-bezier(0.65, 0, 0.35, 1) infinite;
  z-index: 5;
}

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

/* Progress Bar */
.lightbox-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
  z-index: 11;
  transition: width 0.1s linear, opacity 0.2s ease;
  opacity: 0;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .lightbox-content {
    max-width: 100%;
    max-height: 100%;
  }

  .lightbox-control {
    width: 42px;
    height: 42px;
    font-size: 22px;
  }

  .lightbox-prev-btn {
    left: 12px;
  }

  .lightbox-next-btn {
    right: 12px;
  }

  .lightbox-info {
    padding: 14px 16px;
  }
}
