/**
 * Lightbox Image Viewer - Modern Glassmorphism Styling
 * Khoa Sư phạm Toán - Tin (MIT)
 */

.mit-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 15, 29, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 999999;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s ease;
  user-select: none;
}

.mit-lightbox.active {
  opacity: 1;
  visibility: visible;
}

/* Header Toolbar */
.mit-lightbox-header {
  height: 64px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, transparent 100%);
  z-index: 10;
  gap: 15px;
}

.mit-lightbox-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mit-lightbox-counter {
  background: rgba(255, 255, 255, 0.15);
  color: #f8fafc;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  border: 1px solid rgba(255, 255, 255, 0.2);
  white-space: nowrap;
}

.mit-lightbox-title {
  color: #ffffff;
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.mit-lightbox-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mit-lb-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffffff;
  height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.mit-lb-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
  color: #ffffff;
}

.mit-lb-btn-download {
  background: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
}

.mit-lb-btn-download:hover {
  background: #0369a1;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

.mit-lb-btn-close {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  width: 40px;
  padding: 0;
}

.mit-lb-btn-close:hover {
  background: #dc2626;
  border-color: #ef4444;
  color: #ffffff;
  transform: rotate(90deg);
}

/* Stage Area */
.mit-lightbox-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 80px;
  overflow: hidden;
}

.mit-lightbox-img-wrapper {
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.mit-lightbox-img {
  max-width: 90vw;
  max-height: calc(100vh - 160px);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transition: opacity 0.25s ease;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: high-quality;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
  cursor: zoom-in;
}

.mit-lightbox-img.loaded {
  opacity: 1;
}

.mit-lightbox.is-zoomed .mit-lightbox-img {
  cursor: grab;
}

.mit-lightbox.is-zoomed .mit-lightbox-stage {
  overflow: hidden;
}

/* Navigation Arrows */
.mit-lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 10;
  outline: none;
}

.mit-lb-nav:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-50%) scale(1.1);
}

.mit-lb-prev {
  left: 20px;
}

.mit-lb-next {
  right: 20px;
}

/* Bottom Caption Bar */
.mit-lightbox-footer {
  padding: 15px 30px 25px;
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 100%);
  text-align: center;
  z-index: 10;
}

.mit-lightbox-caption {
  color: #e2e8f0;
  font-size: 0.95rem;
  line-height: 1.5;
  max-width: 800px;
  margin: 0 auto;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

/* Spinner */
.mit-lightbox-spinner {
  position: absolute;
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: mitLbSpin 0.8s linear infinite;
}

@keyframes mitLbSpin {
  to { transform: rotate(360deg); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .mit-lightbox-stage {
    padding: 10px;
  }
  .mit-lb-nav {
    width: 42px;
    height: 42px;
    font-size: 1rem;
    background: rgba(0,0,0,0.5);
  }
  .mit-lb-prev { left: 8px; }
  .mit-lb-next { right: 8px; }
  .mit-lb-btn span { display: none; }
  .mit-lb-btn { padding: 0 10px; }
  .mit-lightbox-img {
    max-height: calc(100vh - 160px);
  }
}

/* Pointer cursor for zoomable items */
.lightbox-trigger, 
[data-lightbox], 
.album-card img,
.post-detail img,
.content-body img,
.article-content img {
  cursor: zoom-in;
}
