/* ─────────────────────────────────────────────────────────────────────── */
/* Tags Page — Tag Management, Color Editing                                 */
/* ─────────────────────────────────────────────────────────────────────── */

/* ─────────────────────────────────────────────────────────────────────── */
/* Page Container                                                            */
/* ─────────────────────────────────────────────────────────────────────── */

.page-tags {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
  height: 100%;
  min-width: 0;
  align-items: stretch;
}

/* ─────────────────────────────────────────────────────────────────────── */
/* Tags Sidebar                                                              */
/* ─────────────────────────────────────────────────────────────────────── */

.tags-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 0;
}

.tags-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tags-sidebar-header .page-heading {
  font-size: 16px;
  margin: 0;
}

.tags-app-filter {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  background-color: var(--bg-1);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition-colors);
}

.tags-app-filter:hover {
  border-color: var(--hover-bd);
}

.tags-app-filter:focus {
  outline: none;
  border-color: var(--focus-border);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* ─────────────────────────────────────────────────────────────────────── */
/* Tags List                                                                 */
/* ─────────────────────────────────────────────────────────────────────── */

.tags-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.tags-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background-color: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-colors);
}

.tags-list-item:hover {
  background-color: var(--card-hover-bg);
  border-color: var(--hover-bd);
}

.tags-list-item.active {
  background-color: var(--bg-3);
  border-color: var(--accent);
}

.tags-list-color {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tags-list-name {
  font-size: 13px;
  font-weight: 500;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tags-list-count {
  font-family: var(--font-mono);
  font-size: 10px;
  opacity: 0.7;
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────────────────── */
/* Tags Detail (Main Panel)                                                  */
/* ─────────────────────────────────────────────────────────────────────── */

.tags-detail {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background-color: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-y: auto;
  min-height: 0;
}

.tags-detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.tags-color-picker {
  width: 56px;
  height: 36px;
  padding: 2px;
  background-color: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.tags-color-text {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
}

.tags-description {
  width: 100%;
  min-height: 80px;
  resize: vertical;
  font-size: 13px;
}

.tags-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.tags-detail-color-preview {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  flex-shrink: 0;
  border: 2px solid var(--line);
}

.tags-detail-info {
  flex: 1;
}

.tags-detail-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  margin: 0;
}

.tags-detail-slug {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-mute);
  margin: 2px 0 0 0;
}

.tags-detail-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background-color: var(--t-bug-bg);
  color: var(--t-bug);
  border: 1px solid var(--t-bug-bd);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-colors);
}

.tags-detail-delete:hover {
  background-color: var(--t-bug);
  color: white;
}

/* ─────────────────────────────────────────────────────────────────────── */
/* Color Picker                                                              */
/* ─────────────────────────────────────────────────────────────────────── */

.tags-color-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tags-color-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.tags-color-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.tags-color-swatch {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-colors);
}

.tags-color-swatch:hover {
  transform: scale(1.05);
  border-color: var(--line);
}

.tags-color-swatch.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.tags-color-input-group {
  display: flex;
  gap: 8px;
}

.tags-color-input {
  flex: 1;
}

.tags-color-input input {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 12px;
}

.tags-color-preview-box {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────────────────── */
/* Tag Properties                                                            */
/* ─────────────────────────────────────────────────────────────────────── */

.tags-properties {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tags-property {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tags-property-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.tags-property-label input[type="checkbox"] {
  width: auto;
  cursor: pointer;
}

.tags-property input,
.tags-property textarea {
  width: 100%;
}

/* ─────────────────────────────────────────────────────────────────────── */
/* Empty State                                                               */
/* ─────────────────────────────────────────────────────────────────────── */

.tags-detail.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 48px 24px;
}

.tags-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px 16px;
  margin: auto;
  text-align: center;
}

.tags-empty-icon {
  font-size: 48px;
  opacity: 0.5;
}

.tags-empty-text {
  font-size: 13px;
  color: var(--text-mute);
}

/* ─────────────────────────────────────────────────────────────────────── */
/* Global Tag Badge                                                         */
/* ─────────────────────────────────────────────────────────────────────── */

.badge-global {
  display: inline-block;
  background-color: var(--t-feature-bg);
  color: var(--t-feature);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 6px;
}

/* ─────────────────────────────────────────────────────────────────────── */
/* Responsive                                                                */
/* ─────────────────────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
  .page-tags {
    grid-template-columns: 240px 1fr;
  }

  .tags-color-swatches {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (max-width: 880px) {
  .page-tags {
    grid-template-columns: 1fr;
  }

  .tags-list {
    max-height: 200px;
  }

  .tags-detail {
    max-height: 400px;
  }
}

@media (max-width: 640px) {
  .page-tags {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .tags-color-swatches {
    grid-template-columns: repeat(4, 1fr);
  }

  .tags-detail-header {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }
}
