/* ==========================================================================
   QCM IMAGES VIEWER & GALLERY (IndexedDB Powered)
   ========================================================================== */

/* Toolbar Image Button Indicator Badge */
#toolToggleImage {
  position: relative;
}

#toolToggleImage.has-images::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #06b6d4;
  box-shadow: 0 0 6px #06b6d4;
}

#toolToggleImage .image-count-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #0284c7;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  min-width: 15px;
  height: 15px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  pointer-events: none;
}

/* Fullscreen Modal Backdrop */
.qcm-image-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  background: rgba(11, 15, 25, 0.94);
  color: #f8fafc;
  overflow: hidden;
  animation: fadeInViewer 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

@keyframes fadeInViewer {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

/* Modal Header */
.qcm-img-header {
  height: 60px;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: transparent;
  border-bottom: none;
  z-index: 20;
  justify-content: center;
}

.qcm-img-header-title {
  display: none !important;
}

.qcm-img-preview-label {
  font-size: 13px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80%;
  background: rgba(15, 23, 42, 0.65);
  padding: 4px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.qcm-img-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.qcm-img-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  border: 1px solid transparent;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.07);
}

.qcm-img-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  transform: translateY(-1px);
}

.qcm-img-btn-primary {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
  border: 1px solid rgba(56, 189, 248, 0.4);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
}

.qcm-img-btn-primary:hover {
  background: linear-gradient(135deg, #0369a1, #1d4ed8);
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.45);
}

.qcm-img-btn-icon {
  width: 36px;
  padding: 0;
  border-radius: 9px;
}

.qcm-img-btn-close {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.qcm-img-btn-close:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
}

/* Modal Body / Main Area */
.qcm-img-body {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: radial-gradient(circle at center, rgba(30, 41, 59, 0.3) 0%, rgba(15, 23, 42, 0.8) 100%);
}

/* Empty State / Upload Zone */
.qcm-img-empty-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 30px;
  border: 2px dashed rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.02);
  max-width: 520px;
  width: 90%;
  transition: all 0.25s ease;
  cursor: pointer;
}

.qcm-img-empty-zone:hover,
.qcm-img-empty-zone.dragover {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.06);
  transform: scale(1.02);
}

.qcm-img-empty-icon {
  width: 76px;
  height: 76px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(37, 99, 235, 0.15));
  border: 1px solid rgba(56, 189, 248, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #38bdf8;
  margin-bottom: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.qcm-img-empty-title {
  font-size: 18px;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 8px;
}

.qcm-img-empty-desc {
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.5;
  margin-bottom: 20px;
}

.qcm-img-empty-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #64748b;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.qcm-img-empty-hint kbd {
  background: rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Image Stage & Viewer Container */
.qcm-img-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  cursor: grab;
}

.qcm-img-stage.is-panning {
  cursor: grabbing;
}

.qcm-img-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease-out;
  transform-origin: center center;
  user-select: none;
}

.qcm-img-element {
  max-width: 90vw;
  max-height: 72vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

/* Navigation Arrows (Prev / Next) */
.qcm-img-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 15;
}

.qcm-img-nav-btn:hover {
  background: rgba(56, 189, 248, 0.3);
  border-color: #38bdf8;
  color: #fff;
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.35);
}

.qcm-img-nav-prev {
  left: 20px;
}

.qcm-img-nav-next {
  right: 20px;
}

.qcm-img-counter-pill {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Floating Controls (Zoom & Actions) */
.qcm-img-floating-bar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 6px 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 25;
}

.qcm-img-bar-add-btn {
  height: 32px !important;
  padding: 0 12px !important;
  font-size: 12px !important;
  border-radius: 8px !important;
}

.qcm-img-ctrl-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: #cbd5e1;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.qcm-img-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transform: scale(1.1);
}

.qcm-img-ctrl-btn.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.qcm-img-ctrl-divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.12);
  margin: 0 4px;
}

.qcm-img-zoom-label {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  min-width: 42px;
  text-align: center;
}

/* Thumbnail Strip / Carousel at Bottom (Deleted per Image 5) */
.qcm-img-thumbs-drawer {
  display: none !important;
}

.qcm-img-thumbs-drawer::-webkit-scrollbar {
  height: 4px;
}

.qcm-img-thumbs-drawer::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.qcm-img-thumb {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  background: #0f172a;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0.6;
}

.qcm-img-thumb:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

.qcm-img-thumb.active {
  opacity: 1;
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
  transform: translateY(-2px) scale(1.05);
}

.qcm-img-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.qcm-img-thumb-add {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  border: 2px dashed rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #94a3b8;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.qcm-img-thumb-add span {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.qcm-img-thumb-add:hover {
  border-color: #38bdf8;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
  .qcm-img-header {
    height: 52px;
    padding: 0 12px;
  }
  .qcm-img-preview-label {
    display: none;
  }
  .qcm-img-btn span {
    display: none;
  }
  .qcm-img-btn {
    padding: 0 10px;
    height: 32px;
  }
  .qcm-img-nav-btn {
    width: 38px;
    height: 38px;
    font-size: 14px;
  }
  .qcm-img-nav-prev {
    left: 8px;
  }
  .qcm-img-nav-next {
    right: 8px;
  }
  .qcm-img-thumbs-drawer {
    height: 70px;
    min-height: 70px;
    padding: 0 10px;
    gap: 8px;
  }
  .qcm-img-thumb, .qcm-img-thumb-add {
    width: 52px;
    height: 52px;
  }
  .qcm-img-floating-bar {
    bottom: 12px;
    padding: 4px 8px;
    gap: 4px;
  }
  .qcm-img-ctrl-btn {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }
}
