/* ============================================
   GALLERY - Style cho bộ sưu tập QR code
   Chức năng: Grid layout, gallery items, stats cards
   ============================================ */

/* Gallery toolbar — tìm kiếm, phân trang, xóa theo lô */
.gallery-toolbar {
  margin-top: var(--spacing-md);
  padding: var(--spacing-md);
  background: var(--surface-alt, #f8fafc);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border, #e2e8f0);
}

.gallery-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
}

.gallery-toolbar-row:last-of-type {
  margin-bottom: 0;
}

.gallery-toolbar-search {
  width: 100%;
}

.gallery-search-input {
  flex: 1;
  min-width: 160px;
  padding: 8px 12px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
}

.gallery-page-size {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border, #e2e8f0);
  font-size: var(--font-size-sm);
}

.gallery-toolbar-actions {
  gap: 8px;
}

.gallery-toolbar-pagination {
  justify-content: center;
  margin-top: var(--spacing-xs);
}

.gallery-page-info {
  font-size: var(--font-size-sm);
  color: var(--muted);
  min-width: 12rem;
  text-align: center;
}

.gallery-count-hint {
  margin: var(--spacing-sm) 0 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

.gallery-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}

.gallery-item-select {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}

.gallery-item-select input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Số thứ tự tạo — góc phải hàng trên, không đè lên ảnh QR */
.gallery-item-index {
  flex-shrink: 0;
  min-width: 1.75rem;
  height: 1.75rem;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: #fff;
  background: linear-gradient(145deg, var(--accent, #2563eb) 0%, #1d4ed8 100%);
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  line-height: 1;
  user-select: none;
  pointer-events: none;
}

/* Modal trùng nội dung bộ sưu tập */
.gallery-dup-modal-content {
  max-width: 440px;
}

.gallery-dup-modal-body {
  text-align: left;
}

.gallery-dup-lead {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text, #1e293b);
}

.gallery-dup-snippet {
  margin: 0 0 10px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.35;
  word-break: break-all;
  color: var(--muted, #64748b);
  background: var(--surface-alt, #f1f5f9);
  border-radius: var(--radius-sm, 6px);
  border: 1px solid var(--border, #e2e8f0);
}

.gallery-dup-names {
  margin: 0;
  font-size: 12px;
  color: var(--muted, #64748b);
  line-height: 1.4;
}

.gallery-dup-names-label {
  font-weight: 600;
  color: var(--text-secondary, #475569);
}

.gallery-dup-footer {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 8px;
}

.gallery-dup-footer .btn {
  width: 100%;
  justify-content: center;
}

/* Modal xuất danh sách (Excel / PDF / HTML / …) */
.gallery-export-modal-content {
  max-width: 420px;
}

.gallery-export-modal-body {
  text-align: left;
}

.gallery-export-hint {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted, #64748b);
}

.gallery-export-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gallery-export-actions .btn {
  width: 100%;
  justify-content: center;
  gap: 8px;
}

.gallery-value-preview {
  font-size: 10px;
  color: var(--muted);
  word-break: break-word;
  line-height: 1.25;
  margin-top: 4px;
  max-height: 2.5em;
  overflow: hidden;
}

.gallery-value-link {
  display: block;
  font-size: 10px;
  color: var(--accent, #2563eb);
  word-break: break-all;
  line-height: 1.3;
  margin-top: 4px;
  text-decoration: underline;
  max-height: 2.6em;
  overflow: hidden;
}

.gallery-value-link:hover {
  opacity: 0.88;
}

.gallery-item-qr-img {
  cursor: pointer;
}

/* Gallery Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--spacing-md);
  margin-top: var(--spacing-md);
  width: 100%;
  box-sizing: border-box;
}

/* Gallery Item */
.gallery-item {
  background: white;
  border-radius: var(--radius-sm);
  padding: var(--spacing-sm);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all var(--transition-base);
}

.gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.gallery-item img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin-bottom: var(--spacing-sm);
}

.gallery-item-info {
  font-size: var(--font-size-xs);
  color: var(--muted);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--spacing-md);
  margin-top: var(--spacing-md);
  width: 100%;
  box-sizing: border-box;
}

/* Stat Card */
.stat-card {
  background: linear-gradient(135deg, var(--accent) 0%, #0a5bb8 100%);
  color: white;
  padding: var(--spacing-md);
  border-radius: var(--radius);
  text-align: center;
}

.stat-value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  margin-bottom: var(--spacing-xs);
}

.stat-label {
  font-size: var(--font-size-sm);
  opacity: 0.9;
}

/* Responsive */
@media (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .gallery-item {
    padding: 12px;
  }
  
  .gallery-item:hover {
    transform: none; /* Tắt hover effect trên mobile */
  }
  
  .stats-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 12px;
  }
  
  .stat-card {
    padding: 16px;
  }
  
  .stat-value {
    font-size: 24px;
  }
  
  .stat-label {
    font-size: 13px;
  }
  
  @media (max-width: 480px) {
    .gallery-grid {
      grid-template-columns: 1fr;
      gap: 8px;
    }
    
    .gallery-item {
      padding: 10px;
    }
  }
}

