/* Gallery panel — template selector overlay */

.gallery-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-panel {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  width: 700px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.gallery-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.gallery-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 16px;
  border-radius: 4px;
}

.gallery-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Category tabs */
.gallery-categories-bar {
  display: flex;
  gap: 2px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  flex-shrink: 0;
}

.gallery-cat-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}

.gallery-cat-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.gallery-cat-btn.active {
  background: var(--accent-bg);
  color: var(--accent-color);
  border-color: var(--accent-color);
}

/* Thumbnail grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.gallery-item {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
  background: var(--bg-secondary);
}

.gallery-item:hover {
  border-color: var(--accent-color);
  box-shadow: 0 2px 8px rgba(124, 92, 191, 0.2);
}

.gallery-item-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  overflow: hidden;
}

.gallery-item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.gallery-item-thumb .gallery-icon-placeholder {
  font-size: 32px;
  color: var(--text-secondary);
  opacity: 0.5;
}

.gallery-item-label {
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: center;
  border-top: 1px solid var(--border-color);
}

/* Loading state */
.gallery-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* Empty state */
.gallery-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-secondary);
  font-size: 13px;
  gap: 8px;
}

.gallery-empty i {
  font-size: 24px;
  opacity: 0.5;
}
